diff --git a/C/adtdefs.c b/C/adtdefs.c index 4085ef29e..29c0b90fa 100644 --- a/C/adtdefs.c +++ b/C/adtdefs.c @@ -652,13 +652,13 @@ Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) p->FunctorOfPred = (Functor)fe; WRITE_UNLOCK(fe->FRWLock); #ifdef LOW_PROF - if (ProfilerOn && - Yap_OffLineProfiler) { - Yap_inform_profiler_of_clause((yamop *)&(p->OpcodeOfPred), (yamop *)(&(p->OpcodeOfPred)+1), p, 1); - if (!(p->PredFlags & (CPredFlag|AsmPredFlag))) { - Yap_inform_profiler_of_clause((yamop *)&(p->cs.p_code.ExpandCode), (yamop *)(&(p->cs.p_code.ExpandCode)+1), p, 1); - } + if (ProfilerOn && + Yap_OffLineProfiler) { + Yap_inform_profiler_of_clause((yamop *)&(p->OpcodeOfPred), (yamop *)(&(p->OpcodeOfPred)+1), p, 1); + if (!(p->PredFlags & (CPredFlag|AsmPredFlag))) { + Yap_inform_profiler_of_clause((yamop *)&(p->cs.p_code.ExpandCode), (yamop *)(&(p->cs.p_code.ExpandCode)+1), p, 1); } + } #endif /* LOW_PROF */ return p0; } diff --git a/C/agc.c b/C/agc.c index 6165741e1..399e098a9 100644 --- a/C/agc.c +++ b/C/agc.c @@ -22,12 +22,13 @@ static char SccsId[] = "@(#)agc.c 1.3 3/15/90"; #include "absmi.h" #include "alloc.h" #include "yapio.h" +#include "iopreds.h" #include "attvar.h" #ifdef DEBUG /* #define DEBUG_RESTORE1 1 */ /* #define DEBUG_RESTORE2 1 */ -#define DEBUG_RESTORE3 1 +/* #define DEBUG_RESTORE3 1 */ #define errout Yap_stderr #endif @@ -36,7 +37,7 @@ STATIC_PROTO(void CleanCode, (PredEntry *)); static int agc_calls; -static unsigned long int agc_collected; +static YAP_ULONG_LONG agc_collected; static Int tot_agc_time = 0; /* total time spent in GC */ @@ -59,9 +60,9 @@ AtomResetMark(AtomEntry *ae) if (c & AtomMarkedBit) { c &= ~AtomMarkedBit; ae->NextOfAE = (Atom)c; - return (TRUE); + return TRUE; } - return (FALSE); + return FALSE; } static inline Atom @@ -69,7 +70,7 @@ CleanAtomMarkedBit(Atom a) { CELL c = (CELL)a; c &= ~AtomMarkedBit; - return((Atom)c); + return (Atom)c; } static inline Functor @@ -164,6 +165,21 @@ rehash(CELL *oldcode, int NOfE, int KindOfEntries) #include "rheap.h" +static void init_reg_copies(void) +{ + OldASP = ASP; + OldLCL0 = LCL0; + OldTR = TR; + OldGlobalBase = (CELL *)Yap_GlobalBase; + OldH = H; + OldH0 = H0; + OldTrailBase = Yap_TrailBase; + OldTrailTop = Yap_TrailTop; + OldHeapBase = Yap_HeapBase; + OldHeapTop = HeapTop; +} + + static void mark_hash_entry(AtomHashEntry *HashPtr) { @@ -175,7 +191,7 @@ mark_hash_entry(AtomHashEntry *HashPtr) do { #ifdef DEBUG_RESTORE1 /* useful during debug */ if (IsWideAtom(atm)) - fprintf(errout, "Restoring %S\n", at->WStrOfAE); + fprintf(errout, "Restoring %S\n", at->WStrOfAE); else fprintf(errout, "Restoring %s\n", at->StrOfAE); #endif @@ -194,8 +210,6 @@ mark_atoms(void) { AtomHashEntry *HashPtr = HashChain; register int i; - AtomEntry *at; - Atom atm; restore_codes(); for (i = 0; i < AtomHashTableSize; ++i) { @@ -207,23 +221,7 @@ mark_atoms(void) mark_hash_entry(HashPtr); HashPtr++; } - - atm = INVISIBLECHAIN.Entry; - at = RepAtom(atm); - if (EndOfPAEntr(at)) { - return; - } - do { -#ifdef DEBUG_RESTORE1 /* useful during debug */ - if (IsWideAtom(atm)) - fprintf(errout, "Restoring %S\n", at->WStrOfAE); - else - fprintf(errout, "Restoring %s\n", at->StrOfAE); -#endif - RestoreEntries(RepProp(at->PropsOfAE)); - atm = at->NextOfAE; - at = RepAtom(CleanAtomMarkedBit(atm)); - } while (!EndOfPAEntr(at)); + mark_hash_entry(&INVISIBLECHAIN); } static void @@ -259,6 +257,9 @@ mark_local(void) if (IsAtomTerm(reg)) { MarkAtomEntry(RepAtom(AtomOfTerm(reg))); } + } else if (IsApplTerm(reg)) { + Functor f = FunctorOfTerm(reg); + FuncAdjust(f); } } } @@ -277,17 +278,15 @@ mark_global_cell(CELL *pt) #else return pt + 3; #endif -#if USE_GMP case (CELL)FunctorBigInt: { - Int sz = 1+ - sizeof(MP_INT)+ - (((MP_INT *)(pt+1))->_mp_alloc*sizeof(mp_limb_t)); - return pt + sz+1; + Int sz = 2 + + (sizeof(MP_INT)+ + (((MP_INT *)(pt+1))->_mp_alloc*sizeof(mp_limb_t)))/sizeof(CELL); + return pt + sz; } -#endif case (CELL)FunctorLongInt: - return pt += 3; + return pt + 3; break; } } else if (IsAtomTerm(reg)) { @@ -313,7 +312,6 @@ mark_global(void) #endif while (pt < H) { pt = mark_global_cell(pt); - pt++; } } @@ -326,17 +324,39 @@ mark_stacks(void) } static void -clean_atom(AtomHashEntry *HashPtr) +mark_streams(void) +{ + int i; + + for (i=0; i < MaxStreams; i++) { + if (!(Stream[i].status & (Free_Stream_f|Socket_Stream_f|InMemory_Stream_f|Pipe_Stream_f))) { + /* This is a file, so it has a name */ + AtomEntry *ae = RepAtom(Stream[i].u.file.name); + MarkAtomEntry(ae); + ae = RepAtom(AtomOfTerm(Stream[i].u.file.user_name)); + MarkAtomEntry(ae); + } + } + for (i=0;iEntry; Atom *patm = &(HashPtr->Entry); while (atm != NIL) { - AtomEntry *at = RepAtom(CleanAtomMarkedBit(atm)); - if (AtomResetMark(at) || (AGCHook != NULL && !AGCHook(atm))) { + AtomEntry *at = RepAtom(atm); + if (AtomResetMark(at) || + at->PropsOfAE != NIL || + (AGCHook != NULL && !AGCHook(atm))) { patm = &(at->NextOfAE); atm = at->NextOfAE; - NOfAtoms--; } else { + NOfAtoms--; if (IsWideAtom(atm)) { #ifdef DEBUG_RESTORE3 fprintf(errout, "Purged %p:%S\n", at, at->WStrOfAE); @@ -344,12 +364,11 @@ clean_atom(AtomHashEntry *HashPtr) agc_collected += sizeof(AtomEntry)+wcslen(at->WStrOfAE); } else { #ifdef DEBUG_RESTORE3 - fprintf(stderr, "Purged %p:%s\n", at, at->StrOfAE); + fprintf(stderr, "Purged %p:%s patm=%p %p\n", at, at->StrOfAE, patm, at->NextOfAE); #endif agc_collected += sizeof(AtomEntry)+strlen(at->StrOfAE); } - *patm = at->NextOfAE; - atm = at->NextOfAE; + *patm = atm = at->NextOfAE; Yap_FreeCodeSpace((char *)at); } } @@ -363,43 +382,19 @@ clean_atoms(void) { AtomHashEntry *HashPtr = HashChain; register int i; - Atom atm; - Atom *patm; - AtomEntry *at; + AtomResetMark(AtomFoundVar); + AtomResetMark(AtomFreeTerm); for (i = 0; i < AtomHashTableSize; ++i) { - clean_atom(HashPtr); + clean_atom_list(HashPtr); HashPtr++; } + HashPtr = WideHashChain; for (i = 0; i < WideAtomHashTableSize; ++i) { - clean_atom(HashPtr); + clean_atom_list(HashPtr); HashPtr++; } - patm = &(INVISIBLECHAIN.Entry); - atm = INVISIBLECHAIN.Entry; - while (atm != NIL) { - at = RepAtom(CleanAtomMarkedBit(atm)); - if (AtomResetMark(at) || (AGCHook != NULL && !AGCHook(atm))) { - patm = &(atm->NextOfAE); - NOfAtoms--; - atm = at->NextOfAE; - } else { - if (IsWideAtom(atm)) { -#ifdef DEBUG_RESTORE3 - fprintf(errout, "Purged %p:%S\n", at, at->WStrOfAE); -#endif - agc_collected += sizeof(AtomEntry)+wcslen(at->WStrOfAE); - } else { -#ifdef DEBUG_RESTORE3 - fprintf(stderr, "Purged %p:%s\n", at, at->StrOfAE); -#endif - agc_collected += sizeof(AtomEntry)+strlen(at->StrOfAE); - } - *patm = at->NextOfAE; - atm = at->NextOfAE; - Yap_FreeCodeSpace((char *)at); - } - } + clean_atom_list(&INVISIBLECHAIN); } static void @@ -414,6 +409,7 @@ atom_gc(void) gc_trace = 1; agc_calls++; agc_collected = 0; + if (gc_trace) { fprintf(Yap_stderr, "%% agc:\n"); } else if (gc_verbose) { @@ -422,15 +418,18 @@ atom_gc(void) time_start = Yap_cputime(); /* get the number of active registers */ YAPEnterCriticalSection(); + init_reg_copies(); mark_stacks(); + mark_streams(); mark_atoms(); clean_atoms(); + AGcLastCall = NOfAtoms; YAPLeaveCriticalSection(); agc_time = Yap_cputime()-time_start; tot_agc_time += agc_time; tot_agc_recovered += agc_collected; if (gc_verbose) { - fprintf(Yap_stderr, "%% Collected %ld bytes.\n", agc_collected); + fprintf(Yap_stderr, "%% Collected %lld bytes.\n", agc_collected); fprintf(Yap_stderr, "%% GC %d took %g sec, total of %g sec doing GC so far.\n", agc_calls, (double)agc_time/1000, (double)tot_agc_time/1000); } } @@ -444,7 +443,6 @@ Yap_atom_gc(void) static Int p_atom_gc(void) { - return TRUE; #ifndef FIXED_STACKS atom_gc(); #endif /* FIXED_STACKS */ @@ -462,9 +460,31 @@ p_inform_agc(void) } +static Int +p_agc_threshold(void) +{ + Term t = Deref(ARG1); + if (IsVarTerm(t)) { + return Yap_unify(ARG1, MkIntegerTerm(AGcThreshold)); + } else if (!IsIntegerTerm(t)) { + Yap_Error(TYPE_ERROR_INTEGER,t,"prolog_flag/2 agc_margin"); + return FALSE; + } else { + Int i = IntegerOfTerm(t); + if (i<0) { + Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,t,"prolog_flag/2 agc_margin"); + return FALSE; + } else { + AGcThreshold = i; + return TRUE; + } + } +} + void Yap_init_agc(void) { Yap_InitCPred("$atom_gc", 0, p_atom_gc, HiddenPredFlag); Yap_InitCPred("$inform_agc", 3, p_inform_agc, HiddenPredFlag); + Yap_InitCPred("$agc_threshold", 1, p_agc_threshold, HiddenPredFlag|SafePredFlag); } diff --git a/C/arrays.c b/C/arrays.c index f48ebe776..ed426921b 100644 --- a/C/arrays.c +++ b/C/arrays.c @@ -2148,7 +2148,7 @@ p_compile_array_refs(void) static Int p_array_refs_compiled(void) { - return (compile_arrays); + return compile_arrays; } static Int diff --git a/C/grow.c b/C/grow.c index ef2159dd0..ca4ca01d2 100644 --- a/C/grow.c +++ b/C/grow.c @@ -116,8 +116,10 @@ SetHeapRegs(void) AuxSp = PtoDelayAdjust(AuxSp); AuxTop = (ADDR)PtoDelayAdjust((CELL *)AuxTop); #endif +#if !USE_SYSTEM_MALLOC if (HeapLim) HeapLim = DelayAddrAdjust(HeapLim); +#endif /* The registers pointing to one of the stacks */ if (ENV) ENV = PtoLocAdjust(ENV); @@ -975,11 +977,47 @@ do_growheap(int fix_code, UInt in_size, struct intermediates *cip) return FALSE; } +static void +init_new_table(AtomHashEntry *ntb, UInt nsize) +{ + UInt i; + + for (i = 0; i < nsize; ++i) { + INIT_RWLOCK(ntb[i].AERWLock); + ntb[i].Entry = NIL; + } +} + +static void +cp_atom_table(AtomHashEntry *ntb, UInt nsize) +{ + UInt i; + + for (i = 0; i < AtomHashTableSize; i++) { + Atom catom; + + READ_LOCK(HashChain[i].AERWLock); + catom = HashChain[i].Entry; + while (catom != NIL) { + AtomEntry *ap = RepAtom(catom); + Atom natom; + CELL hash; + + hash = HashFunction((unsigned char *)ap->StrOfAE) % nsize; + natom = ap->NextOfAE; + ap->NextOfAE = ntb[hash].Entry; + ntb[hash].Entry = catom; + catom = natom; + } + READ_UNLOCK(HashChain[i].AERWLock); + } +} + static int growatomtable(void) { AtomHashEntry *ntb; - UInt nsize = 4*AtomHashTableSize-1, i; + UInt nsize = 4*AtomHashTableSize-1; UInt start_growth_time = Yap_cputime(), growth_time; int gc_verbose = Yap_is_gc_verbose(); @@ -1002,28 +1040,8 @@ growatomtable(void) fprintf(Yap_stderr, "%% growing the atom table to %ld entries\n", (long int)(nsize)); } YAPEnterCriticalSection(); - for (i = 0; i < nsize; ++i) { - INIT_RWLOCK(ntb[i].AERWLock); - ntb[i].Entry = NIL; - } - for (i = 0; i < AtomHashTableSize; i++) { - Atom catom; - - READ_LOCK(HashChain[i].AERWLock); - catom = HashChain[i].Entry; - while (catom != NIL) { - AtomEntry *ap = RepAtom(catom); - Atom natom; - CELL hash; - - hash = HashFunction((unsigned char *)ap->StrOfAE) % nsize; - natom = ap->NextOfAE; - ap->NextOfAE = ntb[hash].Entry; - ntb[hash].Entry = catom; - catom = natom; - } - READ_UNLOCK(HashChain[i].AERWLock); - } + init_new_table(ntb, nsize); + cp_atom_table(ntb, nsize); Yap_FreeCodeSpace((char *)HashChain); HashChain = ntb; AtomHashTableSize = nsize; @@ -1056,11 +1074,25 @@ Yap_growheap(int fix_code, UInt in_size, void *cip) { int res; - Yap_PrologMode |= GrowHeapMode; if (NOfAtoms > 2*AtomHashTableSize) { + UInt n = NOfAtoms; + if (AGcThreshold) + Yap_atom_gc(); + /* check if we have a significant improvement from agc */ + if (n > NOfAtoms+ NOfAtoms/10 || + NOfAtoms > 2*AtomHashTableSize) { res = growatomtable(); - Yap_PrologMode &= ~GrowHeapMode; - return res; + } else { + LOCK(SignalLock); + if (ActiveSignals == YAP_CDOVF_SIGNAL) { + CreepFlag = CalculateStackGap(); + } + ActiveSignals &= ~YAP_CDOVF_SIGNAL; + UNLOCK(SignalLock); + return TRUE; + } + Yap_PrologMode &= ~GrowHeapMode; + return res; } res=do_growheap(fix_code, in_size, (struct intermediates *)cip); Yap_PrologMode &= ~GrowHeapMode; @@ -1423,8 +1455,8 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr /* Used by do_goal() when we're short of stack space */ int Yap_growtrail(long size, int contiguous_only) -{ - return do_growtrail(size, contiguous_only, FALSE, NULL, NULL, NULL); +{ + return do_growtrail(size, contiguous_only, FALSE, NULL, NULL, NULL); } int @@ -1527,7 +1559,7 @@ p_growstack(void) static Int p_inform_stack_overflows(void) -{ +{ /* */ Term tn = MkIntTerm(stack_overflows); Term tt = MkIntegerTerm(total_stack_overflow_time); diff --git a/C/init.c b/C/init.c index 7a161d787..6cbccfc8b 100644 --- a/C/init.c +++ b/C/init.c @@ -268,7 +268,8 @@ OpDec(int p, char *type, Atom a, Term m) WRITE_UNLOCK(ae->ARWLock); } if (i <= 3) { - if (info->Posfix != 0) /* there is a posfix operator */ { + if (yap_flags[STRICT_ISO_FLAG] && + info->Posfix != 0) /* there is a posfix operator */ { /* ISO dictates */ WRITE_UNLOCK(info->OpRWLock); Yap_Error(PERMISSION_ERROR_CREATE_OPERATOR,MkAtomTerm(a),"op/3"); @@ -276,7 +277,8 @@ OpDec(int p, char *type, Atom a, Term m) } info->Infix = p; } else if (i <= 5) { - if (info->Infix != 0) /* there is an infix operator */ { + if (yap_flags[STRICT_ISO_FLAG] && + info->Infix != 0) /* there is an infix operator */ { /* ISO dictates */ WRITE_UNLOCK(info->OpRWLock); Yap_Error(PERMISSION_ERROR_CREATE_OPERATOR,MkAtomTerm(a),"op/3"); @@ -1041,11 +1043,11 @@ InitCodes(void) Yap_heap_regs->system_profiling = FALSE; Yap_heap_regs->system_call_counting = FALSE; Yap_heap_regs->system_pred_goal_expansion_all = FALSE; - Yap_heap_regs->system_pred_goal_expansion_func = FALSE; Yap_heap_regs->system_pred_goal_expansion_on = FALSE; Yap_heap_regs->update_mode = UPDATE_MODE_LOGICAL; Yap_heap_regs->compiler_compile_mode = 0; /* fast will be for native code */ Yap_heap_regs->compiler_optimizer_on = TRUE; + Yap_heap_regs->compiler_compile_arrays = FALSE; Yap_heap_regs->maxdepth = 0; Yap_heap_regs->maxlist = 0; Yap_heap_regs->maxwriteargs = 0; @@ -1221,6 +1223,9 @@ InitCodes(void) Yap_heap_regs->file_aliases = NULL; Yap_heap_regs->foreign_code_loaded = NULL; Yap_heap_regs->yap_lib_dir = NULL; + Yap_heap_regs->agc_last_call = 0; + /* should be 10000 */ + Yap_heap_regs->agc_threshold = 0; Yap_heap_regs->agc_hook = NULL; Yap_heap_regs->parser_error_style = EXCEPTION_ON_PARSER_ERROR; Yap_heap_regs->size_of_overflow = 0; @@ -1351,6 +1356,9 @@ Yap_InitWorkspace(int Heap, int Stack, int Trail, int max_table_size, Yap_LUIndexSpace_CP = 0; Yap_LUIndexSpace_EXT = 0; Yap_LUIndexSpace_SW = 0; +#if USE_THREADED_CODE + Yap_heap_regs->op_rtable = NULL; +#endif #if defined(YAPOR) || defined(TABLING) Yap_init_global(max_table_size, n_workers, sch_loop, delay_load); #endif /* YAPOR || TABLING */ @@ -1392,6 +1400,21 @@ Yap_InitWorkspace(int Heap, int Stack, int Trail, int max_table_size, Yap_LookupAtomWithAddress(".",&(SF_STORE->AtDot)); #endif /* InitAbsmi must be done before InitCodes */ + /* This must be done before initialising predicates */ + Yap_heap_regs->system_pred_goal_expansion_func = FALSE; + for (i = 0; i <= TABLING_MODE_FLAG; i++) { + yap_flags[i] = 0; + } + GcCalls = 0; +#ifdef LOW_PROF + ProfilerOn = FALSE; +#endif + ActiveSignals = 0; + DoingUndefp = FALSE; + FPreds = NULL; + DBErasedList = NULL; + DBErasedIList = NULL; + Yap_heap_regs->IntLUKeys = NULL; #ifdef MPW Yap_InitAbsmi(REGS, FunctorList); #else diff --git a/C/iopreds.c b/C/iopreds.c index e9f10db31..5fbbe7695 100644 --- a/C/iopreds.c +++ b/C/iopreds.c @@ -202,6 +202,7 @@ GetFreeStreamD(void) if (sno == MaxStreams) { return -1; } + Stream[sno].encoding = DefaultEncoding(); INIT_LOCK(Stream[sno].streamlock); return sno; } @@ -385,6 +386,7 @@ InitStdStream (int sno, SMALLUNSGN flags, YP_File file) s->linepos = 0; s->linecount = 1; s->charcount = 0; + s->encoding = DefaultEncoding(); INIT_LOCK(s->streamlock); unix_upd_stream_info (s); /* Getting streams to prompt is a mess because we need for cooperation @@ -2459,6 +2461,7 @@ p_open_mem_read_stream (void) /* $open_mem_read_stream(+List,-Stream) */ ti = TailOfTerm(ti); } nbuf[nchars] = '\0'; + fprintf(stderr,"nbuf=%s\n",nbuf); sno = open_buf_read_stream(nbuf, nchars); t = MkStream (sno); return (Yap_unify (ARG2, t)); diff --git a/C/save.c b/C/save.c index 0afcc0881..64ec3322f 100644 --- a/C/save.c +++ b/C/save.c @@ -114,7 +114,6 @@ STATIC_PROTO(void CleanClauses, (yamop *, yamop *,PredEntry *)); STATIC_PROTO(void rehash, (CELL *, int, int)); STATIC_PROTO(void CleanCode, (PredEntry *)); STATIC_PROTO(void RestoreEntries, (PropEntry *)); -STATIC_PROTO(void RestoreInvisibleAtoms, (void)); STATIC_PROTO(void RestoreFreeSpace, (void)); STATIC_PROTO(void restore_heap, (void)); #ifdef DEBUG_RESTORE3 @@ -1260,14 +1259,11 @@ RestoreFreeSpace(void) #endif } -/* restore the atom entries which are invisible for the user */ -static void -RestoreInvisibleAtoms(void) +static void +RestoreAtomList(Atom atm) { AtomEntry *at; - Atom atm = INVISIBLECHAIN.Entry; - INVISIBLECHAIN.Entry = atm = AtomAdjust(atm); at = RepAtom(atm); if (EndOfPAEntr(at)) return; @@ -1284,6 +1280,7 @@ RestoreInvisibleAtoms(void) while (!EndOfPAEntr(at)); } + /* * This is the really tough part, to restore the whole of the heap */ @@ -1293,43 +1290,18 @@ restore_heap(void) AtomHashEntry *HashPtr = HashChain; register int i; for (i = 0; i < AtomHashTableSize; ++i) { - Atom atm = HashPtr->Entry; - if (atm) { - AtomEntry *at; - HashPtr->Entry = atm = AtomAdjust(atm); - at = RepAtom(atm); - do { -#ifdef DEBUG_RESTORE2 /* useful during debug */ - fprintf(errout, "Restoring %s\n", at->StrOfAE); -#endif - at->PropsOfAE = PropAdjust(at->PropsOfAE); - RestoreEntries(RepProp(at->PropsOfAE)); - atm = at->NextOfAE = AtomAdjust(at->NextOfAE); - at = RepAtom(atm); - } while (!EndOfPAEntr(at)); - } + HashPtr->Entry = AtomAdjust(HashPtr->Entry); + RestoreAtomList(HashPtr->Entry); HashPtr++; } HashPtr = WideHashChain; for (i = 0; i < WideAtomHashTableSize; ++i) { - Atom atm = HashPtr->Entry; - if (atm) { - AtomEntry *at; - HashPtr->Entry = atm = AtomAdjust(atm); - at = RepAtom(atm); - do { -#ifdef DEBUG_RESTORE2 /* useful during debug */ - fprintf(errout, "Restoring %s\n", at->StrOfAE); -#endif - at->PropsOfAE = PropAdjust(at->PropsOfAE); - RestoreEntries(RepProp(at->PropsOfAE)); - atm = at->NextOfAE = AtomAdjust(at->NextOfAE); - at = RepAtom(atm); - } while (!EndOfPAEntr(at)); - } + HashPtr->Entry = AtomAdjust(HashPtr->Entry); + RestoreAtomList(HashPtr->Entry); HashPtr++; } - RestoreInvisibleAtoms(); + INVISIBLECHAIN.Entry = AtomAdjust(INVISIBLECHAIN.Entry); + RestoreAtomList(INVISIBLECHAIN.Entry); RestoreForeignCodeStructure(); RestoreIOStructures(); } diff --git a/H/Heap.h b/H/Heap.h index 82f8e97ad..0797094f4 100644 --- a/H/Heap.h +++ b/H/Heap.h @@ -10,7 +10,7 @@ * File: Heap.h * * mods: * * comments: Heap Init Structure * -* version: $Id: Heap.h,v 1.112 2006-12-29 01:57:50 vsc Exp $ * +* version: $Id: Heap.h,v 1.113 2007-02-18 00:26:36 vsc Exp $ * *************************************************************************/ /* information that can be stored in Code Space */ @@ -521,6 +521,8 @@ typedef struct various_codes { #endif /* LOW_PROF */ struct reduction_counters call_counters; char *yap_lib_dir; + UInt agc_last_call; /* amount of space recovered in all garbage collections */ + UInt agc_threshold; /* amount of space recovered in all garbage collections */ Agc_hook agc_hook; void *foreign_code_loaded; ADDR foreign_code_base; @@ -824,6 +826,8 @@ struct various_codes *Yap_heap_regs; #define PredEntriesCounterOn Yap_heap_regs->call_counters.reductions_retries_on #define RetriesCounterOn Yap_heap_regs->call_counters.retries_on #define Yap_LibDir Yap_heap_regs->yap_lib_dir +#define AGcLastCall Yap_heap_regs->agc_last_call +#define AGcThreshold Yap_heap_regs->agc_threshold #define AGCHook Yap_heap_regs->agc_hook #define ParserErrorStyle Yap_heap_regs->parser_error_style #ifdef COROUTINING diff --git a/H/Yap.h b/H/Yap.h index a6476ccae..18a584d1e 100644 --- a/H/Yap.h +++ b/H/Yap.h @@ -10,7 +10,7 @@ * File: Yap.h.m4 * * mods: * * comments: main header file for YAP * -* version: $Id: Yap.h,v 1.19 2007-01-29 10:18:15 vsc Exp $ * +* version: $Id: Yap.h,v 1.20 2007-02-18 00:26:36 vsc Exp $ * *************************************************************************/ #include "config.h" @@ -515,6 +515,7 @@ typedef enum FAST_BOOT_FLAG = 16, STACK_DUMP_ON_ERROR_FLAG = 17, INDEXING_MODE_FLAG = 18, + /* let this be the last one */ TABLING_MODE_FLAG = 19 } yap_flags; @@ -555,7 +556,8 @@ typedef enum YAP_BREAK_SIGNAL = 0x2000, /* received break signal */ YAP_STACK_DUMP_SIGNAL = 0x4000, /* received stack dump signal */ YAP_STATISTICS_SIGNAL = 0x8000, /* received statistics */ - YAP_DELAY_CREEP_SIGNAL = 0x10000 /* received a creep but should not do it */ + YAP_DELAY_CREEP_SIGNAL = 0x10000, /* received a creep but should not do it */ + YAP_AGC_SIGNAL = 0x20000 /* call atom garbage collector asap */ } yap_signals; #define NUMBER_OF_YAP_FLAGS TABLING_MODE_FLAG + 1 diff --git a/H/rheap.h b/H/rheap.h index 245cf0759..a1e3cf438 100644 --- a/H/rheap.h +++ b/H/rheap.h @@ -11,8 +11,12 @@ * File: rheap.h * * comments: walk through heap code * * * -* Last rev: $Date: 2007-01-08 08:27:19 $,$Author: vsc $ * +* Last rev: $Date: 2007-02-18 00:26:36 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.72 2007/01/08 08:27:19 vsc +* fix restore (Trevor) +* make indexing a bit faster on IDB +* * Revision 1.71 2006/11/27 17:42:03 vsc * support for UNICODE, and other bug fixes. * @@ -896,8 +900,14 @@ RestoreBB(BlackBoardEntry *pp) { Term t = pp->Element; if (t) { - if (!IsVarTerm(t) && !IsAtomicTerm(t)) { - RestoreLUClause((LogUpdClause *)DBRefOfTerm(t),NULL); + if (!IsVarTerm(t)) { + if (IsAtomicTerm(t)) { + if (IsAtomTerm(t)) { + pp->Element = AtomTermAdjust(t); + } + } else { + RestoreLUClause((LogUpdClause *)DBRefOfTerm(t),NULL); + } } } pp->KeyOfBB = AtomAdjust(pp->KeyOfBB); @@ -1209,8 +1219,8 @@ RestoreEntries(PropEntry *pp) { DBEntry *de = (DBEntry *) pp; de->NextOfPE = - PropAdjust(de->NextOfPE); if (HDiff) - RestoreDB(de); + PropAdjust(de->NextOfPE); + RestoreDB(de); } break; case BBProperty: @@ -1218,8 +1228,7 @@ RestoreEntries(PropEntry *pp) BlackBoardEntry *bb = (BlackBoardEntry *) pp; bb->NextOfPE = PropAdjust(bb->NextOfPE); - if (HDiff) - RestoreBB(bb); + RestoreBB(bb); } break; case GlobalProperty: diff --git a/changes-5.1.html b/changes-5.1.html index 03f8fdb84..7f7f39e9b 100644 --- a/changes-5.1.html +++ b/changes-5.1.html @@ -16,6 +16,8 @@

Yap-5.1.2: