From 9a0d481528442d60bdab4a6e418875c036dff452 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Tue, 10 Feb 2009 23:42:26 +0000 Subject: [PATCH] avoid too many discontiguous warnings by keeping track of last clause predicate. --- C/cdmgr.c | 15 +++++++++++---- H/Heap.h | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/C/cdmgr.c b/C/cdmgr.c index 2d44f77cb..2c6355a3a 100644 --- a/C/cdmgr.c +++ b/C/cdmgr.c @@ -1918,6 +1918,9 @@ not_was_reconsulted(PredEntry *p, Term t, int mode) register consult_obj *fp; Prop p0 = AbsProp((PropEntry *)p); + if (p == LastAssertedPred) + return FALSE; + LastAssertedPred = p; if (p->cs.p_code.NOfClauses) { for (fp = ConsultSp; fp < ConsultBase; ++fp) if (fp->p == p0) @@ -1926,7 +1929,7 @@ not_was_reconsulted(PredEntry *p, Term t, int mode) fp = ConsultBase; } if (fp != ConsultBase) - return (FALSE); + return FALSE; if (mode) { if (ConsultSp == ConsultLow+1) { expand_consult(); @@ -2375,7 +2378,7 @@ p_in_this_f_before(void) p0 = PredPropByFunc(Yap_MkFunctor(at, arity), mod); else p0 = PredPropByAtom(at, mod); - if (ConsultSp == ConsultBase || (fp = ConsultSp)->p == p0) + if (ConsultSp == ConsultBase || LastAssertedPred == RepPredProp(p0) || (fp = ConsultSp)->p == p0) return FALSE; else fp++; @@ -2413,12 +2416,14 @@ p_first_cl_in_f(void) p0 = PredPropByFunc(Yap_MkFunctor(at, arity),mod); else p0 = PredPropByAtom(at, mod); + if (LastAssertedPred == RepPredProp(p0)) + return FALSE; for (fp = ConsultSp; fp < ConsultBase; ++fp) if (fp->p == p0) break; if (fp != ConsultBase) - return (FALSE); - return (TRUE); + return FALSE; + return TRUE; } #if EMACS @@ -2547,6 +2552,7 @@ init_consult(int mode, char *file) do_toggle_static_predicates_in_use(TRUE); */ #endif consult_level++; + LastAssertedPred = NULL; } void @@ -2584,6 +2590,7 @@ end_consult(void) ConsultBase = ConsultSp+ConsultSp->c; ConsultSp += 3; consult_level--; + LastAssertedPred = NULL; #if !defined(YAPOR) && !defined(SBA) /* if (consult_level == 0) do_toggle_static_predicates_in_use(FALSE);*/ diff --git a/H/Heap.h b/H/Heap.h index a4dd7d38e..394c85a77 100644 --- a/H/Heap.h +++ b/H/Heap.h @@ -117,6 +117,7 @@ typedef struct worker_local_struct { union CONSULT_OBJ *consultsp; union CONSULT_OBJ *consultbase; union CONSULT_OBJ *consultlow; + struct pred_entry *last_asserted_pred; int debug_on; UInt consultcapacity; UInt active_signals; @@ -680,6 +681,7 @@ extern struct various_codes *Yap_heap_regs; #define ConsultBase Yap_heap_regs->WL.consultbase /* low-water mark for consult */ #define ConsultLow Yap_heap_regs->WL.consultlow +#define LastAssertedPred Yap_heap_regs->WL.last_asserted_pred /* current maximum number of cells in consult stack */ #define ConsultCapacity Yap_heap_regs->WL.consultcapacity #define DebugOn Yap_heap_regs->WL.debug_on