first steps to allow mavars with tabling

fix trailing for tabling with multiple get_cons


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1356 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2005-08-05 14:55:03 +00:00
parent 34b2a0df4f
commit ab97812ec7
10 changed files with 2470 additions and 1366 deletions

View File

@ -10,8 +10,11 @@
* * * *
* File: absmi.c * * File: absmi.c *
* comments: Portable abstract machine interpreter * * comments: Portable abstract machine interpreter *
* Last rev: $Date: 2005-08-04 15:45:49 $,$Author: ricroc $ * * Last rev: $Date: 2005-08-05 14:55:02 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $ * $Log: not supported by cvs2svn $
* Revision 1.173 2005/08/04 15:45:49 ricroc
* TABLING NEW: support to limit the table space size
*
* Revision 1.172 2005/08/02 03:09:48 vsc * Revision 1.172 2005/08/02 03:09:48 vsc
* fix debugger to do well nonsource predicates. * fix debugger to do well nonsource predicates.
* *
@ -303,6 +306,8 @@ push_live_regs(yamop *pco)
} }
#endif #endif
#if LOW_PROF #if LOW_PROF
#include <signal.h> #include <signal.h>
#include <ucontext.h> #include <ucontext.h>
@ -1691,36 +1696,45 @@ Yap_absmi(int inp)
#endif /* TABLING */ #endif /* TABLING */
trim_trail: trim_trail:
HBREG = PROTECT_FROZEN_H(B->cp_b); HBREG = PROTECT_FROZEN_H(B->cp_b);
#if TABLING #if FROZEN_STACKS
{ {
tr_fr_ptr pt0, pt1, pbase; tr_fr_ptr pt0, pt1, pbase;
pbase = B->cp_tr; pbase = B->cp_tr;
pt0 = pt1 = TR - 1; pt0 = pt1 = TR-1;
while (pt1 >= pbase) { while (pt1 >= pbase) {
BEGD(d1); BEGD(d1);
d1 = TrailTerm(pt1); d1 = TrailTerm(pt1);
if (IsVarTerm(d1)) { if (IsVarTerm(d1)) {
if (d1 < (CELL)HBREG || d1 > Unsigned(B->cp_b)) { if (d1 < (CELL)HBREG || d1 > Unsigned(B->cp_b)) {
CELL d2 = TrailVal(pt0);
TrailVal(pt0) = d2;
TrailTerm(pt0) = d1; TrailTerm(pt0) = d1;
TrailVal(pt0) = TrailVal(pt1);
pt0--; pt0--;
} }
pt1--; pt1--;
} else if (IsApplTerm(d1)) { } else if (IsApplTerm(d1)) {
TrailTerm(pt0) = TrailTerm(pt0-2) = d1; CELL v2, t3, v4;
TrailTerm(pt0-1) = TrailTerm(pt1-1);
pt0 -= 3; v2 = TrailVal(pt1);
pt1 -= 3; t3 = TrailTerm(pt1-1);
v4 = TrailVal(pt1-1);
TrailTerm(pt0) = d1;
TrailVal(pt0) = v2;
TrailTerm(pt0-1) = t3;
TrailVal(pt0-1) = v4;
pt0 -= 2;
pt1 -= 2;
} else if (IsPairTerm(d1)) { } else if (IsPairTerm(d1)) {
CELL *pt = RepPair(d1); CELL *pt = RepPair(d1);
#ifdef LIMIT_TABLING
if ((ADDR) pt == Yap_TrailBase) {
sg_fr_ptr sg_fr = (sg_fr_ptr) TrailVal(pt1);
SgFr_state(sg_fr)--; /* complete_in_use --> complete : compiled_in_use --> compiled */
insert_into_global_sg_fr_list(sg_fr);
} else
#endif /* LIMIT_TABLING */
if ((ADDR) pt >= Yap_TrailBase) { if ((ADDR) pt >= Yap_TrailBase) {
/*
skip, this is a problem because we lose information, namely
active references
*/
pt1 = (tr_fr_ptr)pt; pt1 = (tr_fr_ptr)pt;
} else if ((*pt & (LogUpdMask|IndexMask)) == (LogUpdMask|IndexMask)) { } else if ((*pt & (LogUpdMask|IndexMask)) == (LogUpdMask|IndexMask)) {
LogUpdIndex *cl = ClauseFlagsToLogUpdIndex(pt); LogUpdIndex *cl = ClauseFlagsToLogUpdIndex(pt);
@ -1739,12 +1753,17 @@ Yap_absmi(int inp)
setregs(); setregs();
} }
} else { } else {
CELL v = TrailVal(pt0);
TrailTerm(pt0) = d1; TrailTerm(pt0) = d1;
TrailVal(pt0) = v;
pt0--; pt0--;
} }
pt1--; pt1--;
} else { } else {
CELL v = TrailVal(pt0);
TrailTerm(pt0) = d1; TrailTerm(pt0) = d1;
TrailVal(pt0) = v;
pt0--; pt0--;
pt1--; pt1--;
} }
@ -1767,15 +1786,27 @@ Yap_absmi(int inp)
d1 = TrailTerm(pt1); d1 = TrailTerm(pt1);
if (IsVarTerm(d1)) { if (IsVarTerm(d1)) {
if (d1 < (CELL)HBREG || d1 > Unsigned(B->cp_b)) { if (d1 < (CELL)HBREG || d1 > Unsigned(B->cp_b)) {
#if FROZEN_STACKS
TrailVal(pt0) = TrailVal(pt1);
#endif
TrailTerm(pt0) = d1; TrailTerm(pt0) = d1;
pt0++; pt0++;
} }
pt1++; pt1++;
} else if (IsApplTerm(d1)) { } else if (IsApplTerm(d1)) {
#if FROZEN_STACKS
TrailVal(pt0) = TrailVal(pt1);
TrailTerm(pt0) = TrailTerm(pt0+2) = d1;
TrailVal(pt0+1) = TrailVal(pt1+1);
TrailTerm(pt0+1) = TrailTerm(pt1+1);
pt0 += 2;
pt1 += 2;
#else
TrailTerm(pt0+1) = TrailTerm(pt1+1); TrailTerm(pt0+1) = TrailTerm(pt1+1);
TrailTerm(pt0) = TrailTerm(pt0+2) = d1; TrailTerm(pt0) = TrailTerm(pt0+2) = d1;
pt0 += 3; pt0 += 3;
pt1 += 3; pt1 += 3;
#endif
} else if (IsPairTerm(d1)) { } else if (IsPairTerm(d1)) {
CELL *pt = RepPair(d1); CELL *pt = RepPair(d1);
if ((*pt & (LogUpdMask|IndexMask)) == (LogUpdMask|IndexMask)) { if ((*pt & (LogUpdMask|IndexMask)) == (LogUpdMask|IndexMask)) {
@ -2903,7 +2934,7 @@ Yap_absmi(int inp)
/* argument is a variable */ /* argument is a variable */
BIND(pt0, PREG->u.cc.c1, gatom_2b); BIND(pt0, PREG->u.cc.c1, gatom_2b);
#ifdef COROUTINING #ifdef COROUTINING
DO_TRAIL(pt0, d1); DO_TRAIL(pt0, PREG->u.cc.c1);
if (pt0 < H0) Yap_WakeUp(pt0); if (pt0 < H0) Yap_WakeUp(pt0);
#endif #endif
ENDP(pt0); ENDP(pt0);
@ -2960,7 +2991,7 @@ Yap_absmi(int inp)
/* argument is a variable */ /* argument is a variable */
BIND(pt0, PREG->u.ccc.c1, gatom_3b); BIND(pt0, PREG->u.ccc.c1, gatom_3b);
#ifdef COROUTINING #ifdef COROUTINING
DO_TRAIL(pt0, d1); DO_TRAIL(pt0, PREG->u.ccc.c1);
if (pt0 < H0) Yap_WakeUp(pt0); if (pt0 < H0) Yap_WakeUp(pt0);
#endif #endif
ENDP(pt0); ENDP(pt0);
@ -2983,7 +3014,7 @@ Yap_absmi(int inp)
/* argument is a variable */ /* argument is a variable */
BIND(pt0, PREG->u.ccc.c2, gatom_3c); BIND(pt0, PREG->u.ccc.c2, gatom_3c);
#ifdef COROUTINING #ifdef COROUTINING
DO_TRAIL(pt0, d1); DO_TRAIL(pt0, PREG->u.ccc.c2);
if (pt0 < H0) Yap_WakeUp(pt0); if (pt0 < H0) Yap_WakeUp(pt0);
#endif #endif
ENDP(pt0); ENDP(pt0);
@ -3040,7 +3071,7 @@ Yap_absmi(int inp)
/* argument is a variable */ /* argument is a variable */
BIND(pt0, PREG->u.cccc.c1, gatom_4b); BIND(pt0, PREG->u.cccc.c1, gatom_4b);
#ifdef COROUTINING #ifdef COROUTINING
DO_TRAIL(pt0, d1); DO_TRAIL(pt0, PREG->u.cccc.c1);
if (pt0 < H0) Yap_WakeUp(pt0); if (pt0 < H0) Yap_WakeUp(pt0);
#endif #endif
ENDP(pt0); ENDP(pt0);
@ -3063,7 +3094,7 @@ Yap_absmi(int inp)
/* argument is a variable */ /* argument is a variable */
BIND(pt0, PREG->u.cccc.c2, gatom_4c); BIND(pt0, PREG->u.cccc.c2, gatom_4c);
#ifdef COROUTINING #ifdef COROUTINING
DO_TRAIL(pt0, d1); DO_TRAIL(pt0, PREG->u.cccc.c2);
if (pt0 < H0) Yap_WakeUp(pt0); if (pt0 < H0) Yap_WakeUp(pt0);
#endif #endif
ENDP(pt0); ENDP(pt0);
@ -3086,7 +3117,7 @@ Yap_absmi(int inp)
/* argument is a variable */ /* argument is a variable */
BIND(pt0, PREG->u.cccc.c3, gatom_4d); BIND(pt0, PREG->u.cccc.c3, gatom_4d);
#ifdef COROUTINING #ifdef COROUTINING
DO_TRAIL(pt0, d1); DO_TRAIL(pt0, PREG->u.cccc.c3);
if (pt0 < H0) Yap_WakeUp(pt0); if (pt0 < H0) Yap_WakeUp(pt0);
#endif #endif
ENDP(pt0); ENDP(pt0);
@ -3143,7 +3174,7 @@ Yap_absmi(int inp)
/* argument is a variable */ /* argument is a variable */
BIND(pt0, PREG->u.ccccc.c1, gatom_5b); BIND(pt0, PREG->u.ccccc.c1, gatom_5b);
#ifdef COROUTINING #ifdef COROUTINING
DO_TRAIL(pt0, d1); DO_TRAIL(pt0, PREG->u.ccccc.c1);
if (pt0 < H0) Yap_WakeUp(pt0); if (pt0 < H0) Yap_WakeUp(pt0);
#endif #endif
ENDP(pt0); ENDP(pt0);
@ -3166,7 +3197,7 @@ Yap_absmi(int inp)
/* argument is a variable */ /* argument is a variable */
BIND(pt0, PREG->u.ccccc.c2, gatom_5c); BIND(pt0, PREG->u.ccccc.c2, gatom_5c);
#ifdef COROUTINING #ifdef COROUTINING
DO_TRAIL(pt0, d1); DO_TRAIL(pt0, PREG->u.ccccc.c2);
if (pt0 < H0) Yap_WakeUp(pt0); if (pt0 < H0) Yap_WakeUp(pt0);
#endif #endif
ENDP(pt0); ENDP(pt0);
@ -3189,7 +3220,7 @@ Yap_absmi(int inp)
/* argument is a variable */ /* argument is a variable */
BIND(pt0, PREG->u.ccccc.c3, gatom_5d); BIND(pt0, PREG->u.ccccc.c3, gatom_5d);
#ifdef COROUTINING #ifdef COROUTINING
DO_TRAIL(pt0, d1); DO_TRAIL(pt0, PREG->u.ccccc.c3);
if (pt0 < H0) Yap_WakeUp(pt0); if (pt0 < H0) Yap_WakeUp(pt0);
#endif #endif
ENDP(pt0); ENDP(pt0);
@ -3212,7 +3243,7 @@ Yap_absmi(int inp)
/* argument is a variable */ /* argument is a variable */
BIND(pt0, PREG->u.ccccc.c4, gatom_5e); BIND(pt0, PREG->u.ccccc.c4, gatom_5e);
#ifdef COROUTINING #ifdef COROUTINING
DO_TRAIL(pt0, d1); DO_TRAIL(pt0, PREG->u.ccccc.c4);
if (pt0 < H0) Yap_WakeUp(pt0); if (pt0 < H0) Yap_WakeUp(pt0);
#endif #endif
ENDP(pt0); ENDP(pt0);
@ -3269,7 +3300,7 @@ Yap_absmi(int inp)
/* argument is a variable */ /* argument is a variable */
BIND(pt0, PREG->u.cccccc.c1, gatom_6b); BIND(pt0, PREG->u.cccccc.c1, gatom_6b);
#ifdef COROUTINING #ifdef COROUTINING
DO_TRAIL(pt0, d1); DO_TRAIL(pt0, PREG->u.cccccc.c1);
if (pt0 < H0) Yap_WakeUp(pt0); if (pt0 < H0) Yap_WakeUp(pt0);
#endif #endif
ENDP(pt0); ENDP(pt0);
@ -3292,7 +3323,7 @@ Yap_absmi(int inp)
/* argument is a variable */ /* argument is a variable */
BIND(pt0, PREG->u.cccccc.c2, gatom_6c); BIND(pt0, PREG->u.cccccc.c2, gatom_6c);
#ifdef COROUTINING #ifdef COROUTINING
DO_TRAIL(pt0, d1); DO_TRAIL(pt0, PREG->u.cccccc.c2);
if (pt0 < H0) Yap_WakeUp(pt0); if (pt0 < H0) Yap_WakeUp(pt0);
#endif #endif
ENDP(pt0); ENDP(pt0);
@ -3315,7 +3346,7 @@ Yap_absmi(int inp)
/* argument is a variable */ /* argument is a variable */
BIND(pt0, PREG->u.cccccc.c3, gatom_6d); BIND(pt0, PREG->u.cccccc.c3, gatom_6d);
#ifdef COROUTINING #ifdef COROUTINING
DO_TRAIL(pt0, d1); DO_TRAIL(pt0, PREG->u.cccccc.c3);
if (pt0 < H0) Yap_WakeUp(pt0); if (pt0 < H0) Yap_WakeUp(pt0);
#endif #endif
ENDP(pt0); ENDP(pt0);
@ -3338,7 +3369,7 @@ Yap_absmi(int inp)
/* argument is a variable */ /* argument is a variable */
BIND(pt0, PREG->u.cccccc.c4, gatom_6e); BIND(pt0, PREG->u.cccccc.c4, gatom_6e);
#ifdef COROUTINING #ifdef COROUTINING
DO_TRAIL(pt0, d1); DO_TRAIL(pt0, PREG->u.cccccc.c4);
if (pt0 < H0) Yap_WakeUp(pt0); if (pt0 < H0) Yap_WakeUp(pt0);
#endif #endif
ENDP(pt0); ENDP(pt0);
@ -3361,7 +3392,7 @@ Yap_absmi(int inp)
/* argument is a variable */ /* argument is a variable */
BIND(pt0, PREG->u.cccccc.c5, gatom_6f); BIND(pt0, PREG->u.cccccc.c5, gatom_6f);
#ifdef COROUTINING #ifdef COROUTINING
DO_TRAIL(pt0, d1); DO_TRAIL(pt0, PREG->u.cccccc.c5);
if (pt0 < H0) Yap_WakeUp(pt0); if (pt0 < H0) Yap_WakeUp(pt0);
#endif #endif
ENDP(pt0); ENDP(pt0);

View File

@ -11,8 +11,11 @@
* File: cdmgr.c * * File: cdmgr.c *
* comments: Code manager * * comments: Code manager *
* * * *
* Last rev: $Date: 2005-08-02 03:09:49 $,$Author: vsc $ * * Last rev: $Date: 2005-08-05 14:55:02 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $ * $Log: not supported by cvs2svn $
* Revision 1.167 2005/08/02 03:09:49 vsc
* fix debugger to do well nonsource predicates.
*
* Revision 1.166 2005/08/01 15:40:37 ricroc * Revision 1.166 2005/08/01 15:40:37 ricroc
* TABLING NEW: better support for incomplete tabling * TABLING NEW: better support for incomplete tabling
* *
@ -4123,6 +4126,12 @@ fetch_next_static_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr
return TRUE; return TRUE;
} else { } else {
Term t; Term t;
if (!(pe->PredFlags & SourcePredFlag)) {
/* no source */
rtn = Yap_MkStaticRefTerm(cl);
return Yap_unify(tr, rtn);
}
if (!(pe->PredFlags & SourcePredFlag)) { if (!(pe->PredFlags & SourcePredFlag)) {
rtn = Yap_MkStaticRefTerm(cl); rtn = Yap_MkStaticRefTerm(cl);

View File

@ -284,7 +284,7 @@ typedef struct gc_ma_hash_entry_struct {
static gc_ma_hash_entry gc_ma_hash_table[GC_MAVARS_HASH_SIZE]; static gc_ma_hash_entry gc_ma_hash_table[GC_MAVARS_HASH_SIZE];
static UInt timestamp; /* an unsigned int */ static UInt gc_timestamp; /* an unsigned int */
static inline unsigned int static inline unsigned int
GC_MAVAR_HASH(CELL *addr) { GC_MAVAR_HASH(CELL *addr) {
@ -318,8 +318,8 @@ gc_lookup_ma_var(CELL *addr, tr_fr_ptr trp) {
unsigned int i = GC_MAVAR_HASH(addr); unsigned int i = GC_MAVAR_HASH(addr);
gc_ma_hash_entry *nptr, *optr = NULL; gc_ma_hash_entry *nptr, *optr = NULL;
if (gc_ma_hash_table[i].timestmp != timestamp) { if (gc_ma_hash_table[i].timestmp != gc_timestamp) {
gc_ma_hash_table[i].timestmp = timestamp; gc_ma_hash_table[i].timestmp = gc_timestamp;
gc_ma_hash_table[i].addr = addr; gc_ma_hash_table[i].addr = addr;
gc_ma_hash_table[i].next = NULL; gc_ma_hash_table[i].next = NULL;
return NULL; return NULL;
@ -341,14 +341,14 @@ gc_lookup_ma_var(CELL *addr, tr_fr_ptr trp) {
static inline void static inline void
GC_NEW_MAHASH(gc_ma_hash_entry *top) { GC_NEW_MAHASH(gc_ma_hash_entry *top) {
UInt time = ++timestamp; UInt time = ++gc_timestamp;
if (time == 0) { if (time == 0) {
unsigned int i; unsigned int i;
/* damn, we overflowed */ /* damn, we overflowed */
for (i = 0; i < GC_MAVARS_HASH_SIZE; i++) for (i = 0; i < GC_MAVARS_HASH_SIZE; i++)
gc_ma_hash_table[i].timestmp = 0L; gc_ma_hash_table[i].timestmp = 0L;
time = ++timestamp; time = ++gc_timestamp;
} }
gc_ma_h_top = top; gc_ma_h_top = top;
cont_top = (cont *)gc_ma_h_top; cont_top = (cont *)gc_ma_h_top;

View File

@ -110,53 +110,16 @@ p_setarg(void)
== B->TR) we will add a little something ;-). == B->TR) we will add a little something ;-).
*/ */
#if FROZEN_STACKS
static void
CreateTimedVar(Term val)
{
timed_var *tv = (timed_var *)H;
tv->clock = MkIntegerTerm(B->cp_tr-(tr_fr_ptr)Yap_TrailBase);
if (B->cp_tr == TR) {
/* we run the risk of not making non-determinate bindings before
the end of the night */
/* so we just init a TR cell that will not harm anyone */
Bind((CELL *)(TR+1),AbsAppl(H-1));
}
tv->value = val;
H += sizeof(timed_var)/sizeof(CELL);
}
static void
CreateEmptyTimedVar(void)
{
timed_var *tv = (timed_var *)H;
tv->clock = MkIntegerTerm(B->cp_tr-(tr_fr_ptr)Yap_TrailBase);
if (B->cp_tr == TR) {
/* we run the risk of not making non-determinate bindings before
the end of the night */
/* so we just init a TR cell that will not harm anyone */
Bind((CELL *)(TR+1),AbsAppl(H-1));
}
RESET_VARIABLE(&(tv->value));
H += sizeof(timed_var)/sizeof(CELL);
}
#endif
static Term static Term
NewTimedVar(CELL val) NewTimedVar(CELL val)
{ {
Term out = AbsAppl(H); Term out = AbsAppl(H);
#if FROZEN_STACKS
*H++ = (CELL)FunctorMutable;
CreateTimedVar(val);
#else
timed_var *tv; timed_var *tv;
*H++ = (CELL)FunctorMutable; *H++ = (CELL)FunctorMutable;
tv = (timed_var *)H; tv = (timed_var *)H;
RESET_VARIABLE(&(tv->clock)); RESET_VARIABLE(&(tv->clock));
tv->value = val; tv->value = val;
H += sizeof(timed_var)/sizeof(CELL); H += sizeof(timed_var)/sizeof(CELL);
#endif
return(out); return(out);
} }
@ -170,17 +133,12 @@ Term
Yap_NewEmptyTimedVar(void) Yap_NewEmptyTimedVar(void)
{ {
Term out = AbsAppl(H); Term out = AbsAppl(H);
#if FROZEN_STACKS
*H++ = (CELL)FunctorMutable;
CreateEmptyTimedVar();
#else
timed_var *tv; timed_var *tv;
*H++ = (CELL)FunctorMutable; *H++ = (CELL)FunctorMutable;
tv = (timed_var *)H; tv = (timed_var *)H;
RESET_VARIABLE(&(tv->clock)); RESET_VARIABLE(&(tv->clock));
RESET_VARIABLE(&(tv->value)); RESET_VARIABLE(&(tv->value));
H += sizeof(timed_var)/sizeof(CELL); H += sizeof(timed_var)/sizeof(CELL);
#endif
return(out); return(out);
} }
@ -204,31 +162,13 @@ UpdateTimedVar(Term inv, Term new)
{ {
timed_var *tv = (timed_var *)(RepAppl(inv)+1); timed_var *tv = (timed_var *)(RepAppl(inv)+1);
CELL t = tv->value; CELL t = tv->value;
#if FROZEN_STACKS
tr_fr_ptr timestmp = (tr_fr_ptr)Yap_TrailBase + IntegerOfTerm(tv->clock);
if (B->cp_tr <= timestmp && timestmp <= TR) {
/* last assignment more recent than last B */
#if SBA
if (Unsigned((Int)(tv)-(Int)(H_FZ)) >
Unsigned((Int)(B_FZ)-(Int)(H_FZ)))
*STACK_TO_SBA(&(tv->value)) = new;
else
#endif
tv->value = new;
if (Unsigned((Int)(tv)-(Int)(HBREG)) >
Unsigned(BBREG)-(Int)(HBREG))
TrailVal(timestmp-1) = new;
} else {
Term nclock;
MaBind(&(tv->value), new);
nclock = MkIntegerTerm(TR-(tr_fr_ptr)Yap_TrailBase);
MaBind(&(tv->clock), nclock);
}
#else
CELL* timestmp = (CELL *)(tv->clock); CELL* timestmp = (CELL *)(tv->clock);
if (B->cp_h <= timestmp) { if (timestmp > B->cp_h
#if FROZEN_STACKS
&& timestmp > H_FZ
#endif
) {
/* last assignment more recent than last B */ /* last assignment more recent than last B */
#if SBA #if SBA
if (Unsigned((Int)(tv)-(Int)(H_FZ)) > if (Unsigned((Int)(tv)-(Int)(H_FZ)) >
@ -243,7 +183,6 @@ UpdateTimedVar(Term inv, Term new)
*H++ = TermFoundVar; *H++ = TermFoundVar;
MaBind(&(tv->clock), nclock); MaBind(&(tv->clock), nclock);
} }
#endif
return(t); return(t);
} }

View File

@ -5,7 +5,7 @@
Copyright: R. Rocha and NCC - University of Porto, Portugal Copyright: R. Rocha and NCC - University of Porto, Portugal
File: opt.init.c File: opt.init.c
version: $Id: opt.init.c,v 1.10 2005-08-04 15:45:55 ricroc Exp $ version: $Id: opt.init.c,v 1.11 2005-08-05 14:55:03 vsc Exp $
**********************************************************************/ **********************************************************************/
@ -31,9 +31,9 @@
#include "opt.mavar.h" #include "opt.mavar.h"
#endif /* !TABLING */ #endif /* !TABLING */
#ifdef MULTI_ASSIGNMENT_VARIABLES #ifdef MULTI_ASSIGNMENT_VARIABLES
ma_hash_entry ma_hash_table[MAVARS_HASH_SIZE]; ma_hash_entry Yap_ma_hash_table[MAVARS_HASH_SIZE];
UInt timestamp; /* an unsigned int */ UInt Yap_timestamp; /* an unsigned int */
ma_h_inner_struct *ma_h_top; ma_h_inner_struct *Yap_ma_h_top;
#endif /* MULTI_ASSIGNMENT_VARIABLES */ #endif /* MULTI_ASSIGNMENT_VARIABLES */
#endif /* TABLING || !ACOW */ #endif /* TABLING || !ACOW */
#ifdef ACOW #ifdef ACOW

View File

@ -5,7 +5,7 @@
Copyright: R. Rocha and NCC - University of Porto, Portugal Copyright: R. Rocha and NCC - University of Porto, Portugal
File: opt.mavar.h File: opt.mavar.h
version: $Id: opt.mavar.h,v 1.3 2005-05-31 08:24:24 ricroc Exp $ version: $Id: opt.mavar.h,v 1.4 2005-08-05 14:55:03 vsc Exp $
**********************************************************************/ **********************************************************************/
@ -31,17 +31,17 @@ typedef struct {
struct ma_h_entry val; struct ma_h_entry val;
} ma_hash_entry; } ma_hash_entry;
extern ma_hash_entry ma_hash_table[MAVARS_HASH_SIZE]; extern ma_hash_entry Yap_ma_hash_table[MAVARS_HASH_SIZE];
extern UInt timestamp; /* an unsigned int */ extern UInt Yap_timestamp; /* an unsigned int */
OPT_MAVAR_STATIC unsigned int MAVAR_HASH(CELL *); OPT_MAVAR_STATIC unsigned int Yap_MAVAR_HASH(CELL *);
OPT_MAVAR_STATIC struct ma_h_entry *ALLOC_NEW_MASPACE(void); OPT_MAVAR_STATIC struct ma_h_entry *Yap_ALLOC_NEW_MASPACE(void);
OPT_MAVAR_STATIC int lookup_ma_var(CELL *); OPT_MAVAR_STATIC int Yap_lookup_ma_var(CELL *);
OPT_MAVAR_STATIC UInt NEW_MAHASH(ma_h_inner_struct *); OPT_MAVAR_STATIC UInt Yap_NEW_MAHASH(ma_h_inner_struct *);
OPT_MAVAR_STATIC unsigned int OPT_MAVAR_STATIC unsigned int
MAVAR_HASH(CELL *addr) { Yap_MAVAR_HASH(CELL *addr) {
#if SIZEOF_INT_P==8 #if SIZEOF_INT_P==8
return((((unsigned int)((CELL)(addr)))>>3)%MAVARS_HASH_SIZE); return((((unsigned int)((CELL)(addr)))>>3)%MAVARS_HASH_SIZE);
#else #else
@ -49,56 +49,56 @@ MAVAR_HASH(CELL *addr) {
#endif #endif
} }
extern ma_h_inner_struct *ma_h_top; extern ma_h_inner_struct *Yap_ma_h_top;
OPT_MAVAR_STATIC struct ma_h_entry * OPT_MAVAR_STATIC struct ma_h_entry *
ALLOC_NEW_MASPACE(void) Yap_ALLOC_NEW_MASPACE(void)
{ {
ma_h_inner_struct *new = ma_h_top; ma_h_inner_struct *new = Yap_ma_h_top;
ma_h_top++; Yap_ma_h_top++;
return(new); return new;
} }
OPT_MAVAR_STATIC int OPT_MAVAR_STATIC int
lookup_ma_var(CELL *addr) { Yap_lookup_ma_var(CELL *addr) {
unsigned int i = MAVAR_HASH(addr); unsigned int i = Yap_MAVAR_HASH(addr);
struct ma_h_entry *nptr, *optr; struct ma_h_entry *nptr, *optr;
if (ma_hash_table[i].timestmp != timestamp) { if (Yap_ma_hash_table[i].timestmp != Yap_timestamp) {
ma_hash_table[i].timestmp = timestamp; Yap_ma_hash_table[i].timestmp = Yap_timestamp;
ma_hash_table[i].val.addr = addr; Yap_ma_hash_table[i].val.addr = addr;
ma_hash_table[i].val.next = NULL; Yap_ma_hash_table[i].val.next = NULL;
return(FALSE); return FALSE;
} }
if (ma_hash_table[i].val.addr == addr) if (Yap_ma_hash_table[i].val.addr == addr)
return(TRUE); return TRUE;
optr = &(ma_hash_table[i].val); optr = &(Yap_ma_hash_table[i].val);
nptr = ma_hash_table[i].val.next; nptr = Yap_ma_hash_table[i].val.next;
while (nptr != NULL) { while (nptr != NULL) {
if (nptr->addr == addr) { if (nptr->addr == addr) {
return(TRUE); return TRUE;
} }
optr = nptr; optr = nptr;
nptr = nptr->next; nptr = nptr->next;
} }
nptr = ALLOC_NEW_MASPACE(); nptr = Yap_ALLOC_NEW_MASPACE();
nptr->addr = addr; nptr->addr = addr;
nptr->next = optr; nptr->next = optr;
return(FALSE); return FALSE;
} }
OPT_MAVAR_STATIC UInt OPT_MAVAR_STATIC UInt
NEW_MAHASH(ma_h_inner_struct *top) { Yap_NEW_MAHASH(ma_h_inner_struct *top) {
UInt time = ++timestamp; UInt time = ++Yap_timestamp;
if (time == 0) { if (time == 0) {
unsigned int i; unsigned int i;
/* damn, we overflowed */ /* damn, we overflowed */
for (i = 0; i < MAVARS_HASH_SIZE; i++) for (i = 0; i < MAVARS_HASH_SIZE; i++)
ma_hash_table[i].timestmp = 0; Yap_ma_hash_table[i].timestmp = 0;
time = ++timestamp; time = ++Yap_timestamp;
} }
ma_h_top = top; Yap_ma_h_top = top;
return(time); return time;
} }
#endif /* MULTI_ASSIGNMENT_VARIABLES */ #endif /* MULTI_ASSIGNMENT_VARIABLES */

View File

@ -5,7 +5,7 @@
Copyright: R. Rocha and NCC - University of Porto, Portugal Copyright: R. Rocha and NCC - University of Porto, Portugal
File: tab.insts.i File: tab.insts.i
version: $Id: tab.insts.i,v 1.19 2005-08-04 15:45:55 ricroc Exp $ version: $Id: tab.insts.i,v 1.20 2005-08-05 14:55:03 vsc Exp $
**********************************************************************/ **********************************************************************/
@ -358,7 +358,7 @@
tab_ent_ptr tab_ent; tab_ent_ptr tab_ent;
sg_fr_ptr sg_fr; sg_fr_ptr sg_fr;
check_trail(); check_trail(TR);
tab_ent = PREG->u.ld.te; tab_ent = PREG->u.ld.te;
sg_fr = subgoal_search(PREG, &YENV); sg_fr = subgoal_search(PREG, &YENV);
LOCK(SgFr_lock(sg_fr)); LOCK(SgFr_lock(sg_fr));
@ -468,7 +468,7 @@
tab_ent_ptr tab_ent; tab_ent_ptr tab_ent;
sg_fr_ptr sg_fr; sg_fr_ptr sg_fr;
check_trail(); check_trail(TR);
tab_ent = PREG->u.ld.te; tab_ent = PREG->u.ld.te;
sg_fr = subgoal_search(PREG, &YENV); sg_fr = subgoal_search(PREG, &YENV);
LOCK(SgFr_lock(sg_fr)); LOCK(SgFr_lock(sg_fr));
@ -578,7 +578,7 @@
tab_ent_ptr tab_ent; tab_ent_ptr tab_ent;
sg_fr_ptr sg_fr; sg_fr_ptr sg_fr;
check_trail(); check_trail(TR);
tab_ent = PREG->u.ld.te; tab_ent = PREG->u.ld.te;
sg_fr = subgoal_search(PREG, &YENV); sg_fr = subgoal_search(PREG, &YENV);
LOCK(SgFr_lock(sg_fr)); LOCK(SgFr_lock(sg_fr));

View File

@ -5,7 +5,7 @@
Copyright: R. Rocha and NCC - University of Porto, Portugal Copyright: R. Rocha and NCC - University of Porto, Portugal
File: tab.macros.h File: tab.macros.h
version: $Id: tab.macros.h,v 1.18 2005-08-04 15:45:55 ricroc Exp $ version: $Id: tab.macros.h,v 1.19 2005-08-05 14:55:03 vsc Exp $
**********************************************************************/ **********************************************************************/
@ -417,7 +417,7 @@ void rebind_variables(tr_fr_ptr rebind_tr, tr_fr_ptr end_tr) {
TABLING_ERROR_MESSAGE("rebind_tr < end_tr (function rebind_variables)"); TABLING_ERROR_MESSAGE("rebind_tr < end_tr (function rebind_variables)");
#endif /* TABLING_ERRORS */ #endif /* TABLING_ERRORS */
/* rebind loop */ /* rebind loop */
NEW_MAHASH((ma_h_inner_struct *)H); Yap_NEW_MAHASH((ma_h_inner_struct *)H);
while (rebind_tr != end_tr) { while (rebind_tr != end_tr) {
CELL ref = (CELL) TrailTerm(--rebind_tr); CELL ref = (CELL) TrailTerm(--rebind_tr);
/* check for global or local variables */ /* check for global or local variables */
@ -439,7 +439,7 @@ void rebind_variables(tr_fr_ptr rebind_tr, tr_fr_ptr end_tr) {
#ifdef MULTI_ASSIGNMENT_VARIABLES #ifdef MULTI_ASSIGNMENT_VARIABLES
} else { } else {
CELL *cell_ptr = RepAppl(ref); CELL *cell_ptr = RepAppl(ref);
if (!lookup_ma_var(cell_ptr)) { if (!Yap_lookup_ma_var(cell_ptr)) {
/* first time we found the variable, let's put the new value */ /* first time we found the variable, let's put the new value */
*cell_ptr = TrailVal(rebind_tr); *cell_ptr = TrailVal(rebind_tr);
} }

3546
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -192,23 +192,6 @@ then
AC_DEFINE(MinHeapSpace, (400*SIZEOF_INT_P)) AC_DEFINE(MinHeapSpace, (400*SIZEOF_INT_P))
AC_DEFINE(MinStackSpace,(300*SIZEOF_INT_P)) AC_DEFINE(MinStackSpace,(300*SIZEOF_INT_P))
AC_DEFINE(MinTrailSpace,( 48*SIZEOF_INT_P)) AC_DEFINE(MinTrailSpace,( 48*SIZEOF_INT_P))
if test "$coroutining" = yes
then
echo
echo
echo "********************************************************"
echo
echo
echo "!!!!!! ERROR !!!!!"
echo "Coroutining is currently incompatible with Tabling/Parallelism/Threads"
echo "Please contact ricroc@ncc.up.pt for help"
echo
echo
echo "********************************************************"
echo
echo
exit 1
fi
if test "$depthlimit" = yes -a "$tabling" = yes if test "$depthlimit" = yes -a "$tabling" = yes
then then
echo echo
@ -259,7 +242,7 @@ then
CFLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes" CFLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes"
C_INTERF_FLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes" C_INTERF_FLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes"
else else
CFLAGS="-O3 -fomit-frame-pointer -Wall -Wstrict-prototypes -Wmissing-prototypes" CFLAGS="-O3 -fno-gcse -fno-crossjumping -fomit-frame-pointer -Wall -Wstrict-prototypes -Wmissing-prototypes"
C_INTERF_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes" C_INTERF_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes"
C_PARSER_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes" C_PARSER_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes"
case "$target_cpu" in case "$target_cpu" in