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:
parent
34b2a0df4f
commit
ab97812ec7
89
C/absmi.c
89
C/absmi.c
@ -10,8 +10,11 @@
|
||||
* *
|
||||
* File: absmi.c *
|
||||
* 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 $
|
||||
* 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
|
||||
* fix debugger to do well nonsource predicates.
|
||||
*
|
||||
@ -303,6 +306,8 @@ push_live_regs(yamop *pco)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if LOW_PROF
|
||||
#include <signal.h>
|
||||
#include <ucontext.h>
|
||||
@ -1691,36 +1696,45 @@ Yap_absmi(int inp)
|
||||
#endif /* TABLING */
|
||||
trim_trail:
|
||||
HBREG = PROTECT_FROZEN_H(B->cp_b);
|
||||
#if TABLING
|
||||
#if FROZEN_STACKS
|
||||
{
|
||||
tr_fr_ptr pt0, pt1, pbase;
|
||||
pbase = B->cp_tr;
|
||||
pt0 = pt1 = TR-1;
|
||||
|
||||
while (pt1 >= pbase) {
|
||||
BEGD(d1);
|
||||
|
||||
d1 = TrailTerm(pt1);
|
||||
if (IsVarTerm(d1)) {
|
||||
if (d1 < (CELL)HBREG || d1 > Unsigned(B->cp_b)) {
|
||||
CELL d2 = TrailVal(pt0);
|
||||
|
||||
TrailVal(pt0) = d2;
|
||||
TrailTerm(pt0) = d1;
|
||||
TrailVal(pt0) = TrailVal(pt1);
|
||||
pt0--;
|
||||
}
|
||||
pt1--;
|
||||
} else if (IsApplTerm(d1)) {
|
||||
TrailTerm(pt0) = TrailTerm(pt0-2) = d1;
|
||||
TrailTerm(pt0-1) = TrailTerm(pt1-1);
|
||||
pt0 -= 3;
|
||||
pt1 -= 3;
|
||||
CELL v2, t3, v4;
|
||||
|
||||
v2 = TrailVal(pt1);
|
||||
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)) {
|
||||
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) {
|
||||
/*
|
||||
skip, this is a problem because we lose information, namely
|
||||
active references
|
||||
*/
|
||||
pt1 = (tr_fr_ptr)pt;
|
||||
} else if ((*pt & (LogUpdMask|IndexMask)) == (LogUpdMask|IndexMask)) {
|
||||
LogUpdIndex *cl = ClauseFlagsToLogUpdIndex(pt);
|
||||
@ -1739,12 +1753,17 @@ Yap_absmi(int inp)
|
||||
setregs();
|
||||
}
|
||||
} else {
|
||||
CELL v = TrailVal(pt0);
|
||||
TrailTerm(pt0) = d1;
|
||||
TrailVal(pt0) = v;
|
||||
pt0--;
|
||||
}
|
||||
pt1--;
|
||||
} else {
|
||||
CELL v = TrailVal(pt0);
|
||||
|
||||
TrailTerm(pt0) = d1;
|
||||
TrailVal(pt0) = v;
|
||||
pt0--;
|
||||
pt1--;
|
||||
}
|
||||
@ -1767,15 +1786,27 @@ Yap_absmi(int inp)
|
||||
d1 = TrailTerm(pt1);
|
||||
if (IsVarTerm(d1)) {
|
||||
if (d1 < (CELL)HBREG || d1 > Unsigned(B->cp_b)) {
|
||||
#if FROZEN_STACKS
|
||||
TrailVal(pt0) = TrailVal(pt1);
|
||||
#endif
|
||||
TrailTerm(pt0) = d1;
|
||||
pt0++;
|
||||
}
|
||||
pt1++;
|
||||
} 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) = TrailTerm(pt0+2) = d1;
|
||||
pt0 += 3;
|
||||
pt1 += 3;
|
||||
#endif
|
||||
} else if (IsPairTerm(d1)) {
|
||||
CELL *pt = RepPair(d1);
|
||||
if ((*pt & (LogUpdMask|IndexMask)) == (LogUpdMask|IndexMask)) {
|
||||
@ -2903,7 +2934,7 @@ Yap_absmi(int inp)
|
||||
/* argument is a variable */
|
||||
BIND(pt0, PREG->u.cc.c1, gatom_2b);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
DO_TRAIL(pt0, PREG->u.cc.c1);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
#endif
|
||||
ENDP(pt0);
|
||||
@ -2960,7 +2991,7 @@ Yap_absmi(int inp)
|
||||
/* argument is a variable */
|
||||
BIND(pt0, PREG->u.ccc.c1, gatom_3b);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
DO_TRAIL(pt0, PREG->u.ccc.c1);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
#endif
|
||||
ENDP(pt0);
|
||||
@ -2983,7 +3014,7 @@ Yap_absmi(int inp)
|
||||
/* argument is a variable */
|
||||
BIND(pt0, PREG->u.ccc.c2, gatom_3c);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
DO_TRAIL(pt0, PREG->u.ccc.c2);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
#endif
|
||||
ENDP(pt0);
|
||||
@ -3040,7 +3071,7 @@ Yap_absmi(int inp)
|
||||
/* argument is a variable */
|
||||
BIND(pt0, PREG->u.cccc.c1, gatom_4b);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
DO_TRAIL(pt0, PREG->u.cccc.c1);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
#endif
|
||||
ENDP(pt0);
|
||||
@ -3063,7 +3094,7 @@ Yap_absmi(int inp)
|
||||
/* argument is a variable */
|
||||
BIND(pt0, PREG->u.cccc.c2, gatom_4c);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
DO_TRAIL(pt0, PREG->u.cccc.c2);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
#endif
|
||||
ENDP(pt0);
|
||||
@ -3086,7 +3117,7 @@ Yap_absmi(int inp)
|
||||
/* argument is a variable */
|
||||
BIND(pt0, PREG->u.cccc.c3, gatom_4d);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
DO_TRAIL(pt0, PREG->u.cccc.c3);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
#endif
|
||||
ENDP(pt0);
|
||||
@ -3143,7 +3174,7 @@ Yap_absmi(int inp)
|
||||
/* argument is a variable */
|
||||
BIND(pt0, PREG->u.ccccc.c1, gatom_5b);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
DO_TRAIL(pt0, PREG->u.ccccc.c1);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
#endif
|
||||
ENDP(pt0);
|
||||
@ -3166,7 +3197,7 @@ Yap_absmi(int inp)
|
||||
/* argument is a variable */
|
||||
BIND(pt0, PREG->u.ccccc.c2, gatom_5c);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
DO_TRAIL(pt0, PREG->u.ccccc.c2);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
#endif
|
||||
ENDP(pt0);
|
||||
@ -3189,7 +3220,7 @@ Yap_absmi(int inp)
|
||||
/* argument is a variable */
|
||||
BIND(pt0, PREG->u.ccccc.c3, gatom_5d);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
DO_TRAIL(pt0, PREG->u.ccccc.c3);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
#endif
|
||||
ENDP(pt0);
|
||||
@ -3212,7 +3243,7 @@ Yap_absmi(int inp)
|
||||
/* argument is a variable */
|
||||
BIND(pt0, PREG->u.ccccc.c4, gatom_5e);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
DO_TRAIL(pt0, PREG->u.ccccc.c4);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
#endif
|
||||
ENDP(pt0);
|
||||
@ -3269,7 +3300,7 @@ Yap_absmi(int inp)
|
||||
/* argument is a variable */
|
||||
BIND(pt0, PREG->u.cccccc.c1, gatom_6b);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
DO_TRAIL(pt0, PREG->u.cccccc.c1);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
#endif
|
||||
ENDP(pt0);
|
||||
@ -3292,7 +3323,7 @@ Yap_absmi(int inp)
|
||||
/* argument is a variable */
|
||||
BIND(pt0, PREG->u.cccccc.c2, gatom_6c);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
DO_TRAIL(pt0, PREG->u.cccccc.c2);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
#endif
|
||||
ENDP(pt0);
|
||||
@ -3315,7 +3346,7 @@ Yap_absmi(int inp)
|
||||
/* argument is a variable */
|
||||
BIND(pt0, PREG->u.cccccc.c3, gatom_6d);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
DO_TRAIL(pt0, PREG->u.cccccc.c3);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
#endif
|
||||
ENDP(pt0);
|
||||
@ -3338,7 +3369,7 @@ Yap_absmi(int inp)
|
||||
/* argument is a variable */
|
||||
BIND(pt0, PREG->u.cccccc.c4, gatom_6e);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
DO_TRAIL(pt0, PREG->u.cccccc.c4);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
#endif
|
||||
ENDP(pt0);
|
||||
@ -3361,7 +3392,7 @@ Yap_absmi(int inp)
|
||||
/* argument is a variable */
|
||||
BIND(pt0, PREG->u.cccccc.c5, gatom_6f);
|
||||
#ifdef COROUTINING
|
||||
DO_TRAIL(pt0, d1);
|
||||
DO_TRAIL(pt0, PREG->u.cccccc.c5);
|
||||
if (pt0 < H0) Yap_WakeUp(pt0);
|
||||
#endif
|
||||
ENDP(pt0);
|
||||
|
11
C/cdmgr.c
11
C/cdmgr.c
@ -11,8 +11,11 @@
|
||||
* File: cdmgr.c *
|
||||
* 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 $
|
||||
* 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
|
||||
* TABLING NEW: better support for incomplete tabling
|
||||
*
|
||||
@ -4124,6 +4127,12 @@ fetch_next_static_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr
|
||||
} else {
|
||||
Term t;
|
||||
|
||||
if (!(pe->PredFlags & SourcePredFlag)) {
|
||||
/* no source */
|
||||
rtn = Yap_MkStaticRefTerm(cl);
|
||||
return Yap_unify(tr, rtn);
|
||||
}
|
||||
|
||||
if (!(pe->PredFlags & SourcePredFlag)) {
|
||||
rtn = Yap_MkStaticRefTerm(cl);
|
||||
return Yap_unify(tr, rtn);
|
||||
|
10
C/heapgc.c
10
C/heapgc.c
@ -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 UInt timestamp; /* an unsigned int */
|
||||
static UInt gc_timestamp; /* an unsigned int */
|
||||
|
||||
static inline unsigned int
|
||||
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);
|
||||
gc_ma_hash_entry *nptr, *optr = NULL;
|
||||
|
||||
if (gc_ma_hash_table[i].timestmp != timestamp) {
|
||||
gc_ma_hash_table[i].timestmp = timestamp;
|
||||
if (gc_ma_hash_table[i].timestmp != gc_timestamp) {
|
||||
gc_ma_hash_table[i].timestmp = gc_timestamp;
|
||||
gc_ma_hash_table[i].addr = addr;
|
||||
gc_ma_hash_table[i].next = NULL;
|
||||
return NULL;
|
||||
@ -341,14 +341,14 @@ gc_lookup_ma_var(CELL *addr, tr_fr_ptr trp) {
|
||||
|
||||
static inline void
|
||||
GC_NEW_MAHASH(gc_ma_hash_entry *top) {
|
||||
UInt time = ++timestamp;
|
||||
UInt time = ++gc_timestamp;
|
||||
if (time == 0) {
|
||||
unsigned int i;
|
||||
|
||||
/* damn, we overflowed */
|
||||
for (i = 0; i < GC_MAVARS_HASH_SIZE; i++)
|
||||
gc_ma_hash_table[i].timestmp = 0L;
|
||||
time = ++timestamp;
|
||||
time = ++gc_timestamp;
|
||||
}
|
||||
gc_ma_h_top = top;
|
||||
cont_top = (cont *)gc_ma_h_top;
|
||||
|
71
C/mavar.c
71
C/mavar.c
@ -110,53 +110,16 @@ p_setarg(void)
|
||||
== 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
|
||||
NewTimedVar(CELL val)
|
||||
{
|
||||
Term out = AbsAppl(H);
|
||||
#if FROZEN_STACKS
|
||||
*H++ = (CELL)FunctorMutable;
|
||||
CreateTimedVar(val);
|
||||
#else
|
||||
timed_var *tv;
|
||||
*H++ = (CELL)FunctorMutable;
|
||||
tv = (timed_var *)H;
|
||||
RESET_VARIABLE(&(tv->clock));
|
||||
tv->value = val;
|
||||
H += sizeof(timed_var)/sizeof(CELL);
|
||||
#endif
|
||||
return(out);
|
||||
}
|
||||
|
||||
@ -170,17 +133,12 @@ Term
|
||||
Yap_NewEmptyTimedVar(void)
|
||||
{
|
||||
Term out = AbsAppl(H);
|
||||
#if FROZEN_STACKS
|
||||
*H++ = (CELL)FunctorMutable;
|
||||
CreateEmptyTimedVar();
|
||||
#else
|
||||
timed_var *tv;
|
||||
*H++ = (CELL)FunctorMutable;
|
||||
tv = (timed_var *)H;
|
||||
RESET_VARIABLE(&(tv->clock));
|
||||
RESET_VARIABLE(&(tv->value));
|
||||
H += sizeof(timed_var)/sizeof(CELL);
|
||||
#endif
|
||||
return(out);
|
||||
}
|
||||
|
||||
@ -204,31 +162,13 @@ UpdateTimedVar(Term inv, Term new)
|
||||
{
|
||||
timed_var *tv = (timed_var *)(RepAppl(inv)+1);
|
||||
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);
|
||||
|
||||
if (B->cp_h <= timestmp) {
|
||||
if (timestmp > B->cp_h
|
||||
#if FROZEN_STACKS
|
||||
&& timestmp > H_FZ
|
||||
#endif
|
||||
) {
|
||||
/* last assignment more recent than last B */
|
||||
#if SBA
|
||||
if (Unsigned((Int)(tv)-(Int)(H_FZ)) >
|
||||
@ -243,7 +183,6 @@ UpdateTimedVar(Term inv, Term new)
|
||||
*H++ = TermFoundVar;
|
||||
MaBind(&(tv->clock), nclock);
|
||||
}
|
||||
#endif
|
||||
return(t);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
Copyright: R. Rocha and NCC - University of Porto, Portugal
|
||||
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"
|
||||
#endif /* !TABLING */
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||
ma_hash_entry ma_hash_table[MAVARS_HASH_SIZE];
|
||||
UInt timestamp; /* an unsigned int */
|
||||
ma_h_inner_struct *ma_h_top;
|
||||
ma_hash_entry Yap_ma_hash_table[MAVARS_HASH_SIZE];
|
||||
UInt Yap_timestamp; /* an unsigned int */
|
||||
ma_h_inner_struct *Yap_ma_h_top;
|
||||
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
||||
#endif /* TABLING || !ACOW */
|
||||
#ifdef ACOW
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
Copyright: R. Rocha and NCC - University of Porto, Portugal
|
||||
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;
|
||||
} 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 struct ma_h_entry *ALLOC_NEW_MASPACE(void);
|
||||
OPT_MAVAR_STATIC int lookup_ma_var(CELL *);
|
||||
OPT_MAVAR_STATIC UInt NEW_MAHASH(ma_h_inner_struct *);
|
||||
OPT_MAVAR_STATIC unsigned int Yap_MAVAR_HASH(CELL *);
|
||||
OPT_MAVAR_STATIC struct ma_h_entry *Yap_ALLOC_NEW_MASPACE(void);
|
||||
OPT_MAVAR_STATIC int Yap_lookup_ma_var(CELL *);
|
||||
OPT_MAVAR_STATIC UInt Yap_NEW_MAHASH(ma_h_inner_struct *);
|
||||
|
||||
OPT_MAVAR_STATIC unsigned int
|
||||
MAVAR_HASH(CELL *addr) {
|
||||
Yap_MAVAR_HASH(CELL *addr) {
|
||||
#if SIZEOF_INT_P==8
|
||||
return((((unsigned int)((CELL)(addr)))>>3)%MAVARS_HASH_SIZE);
|
||||
#else
|
||||
@ -49,56 +49,56 @@ MAVAR_HASH(CELL *addr) {
|
||||
#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 *
|
||||
ALLOC_NEW_MASPACE(void)
|
||||
Yap_ALLOC_NEW_MASPACE(void)
|
||||
{
|
||||
ma_h_inner_struct *new = ma_h_top;
|
||||
ma_h_top++;
|
||||
return(new);
|
||||
ma_h_inner_struct *new = Yap_ma_h_top;
|
||||
Yap_ma_h_top++;
|
||||
return new;
|
||||
}
|
||||
|
||||
OPT_MAVAR_STATIC int
|
||||
lookup_ma_var(CELL *addr) {
|
||||
unsigned int i = MAVAR_HASH(addr);
|
||||
Yap_lookup_ma_var(CELL *addr) {
|
||||
unsigned int i = Yap_MAVAR_HASH(addr);
|
||||
struct ma_h_entry *nptr, *optr;
|
||||
|
||||
if (ma_hash_table[i].timestmp != timestamp) {
|
||||
ma_hash_table[i].timestmp = timestamp;
|
||||
ma_hash_table[i].val.addr = addr;
|
||||
ma_hash_table[i].val.next = NULL;
|
||||
return(FALSE);
|
||||
if (Yap_ma_hash_table[i].timestmp != Yap_timestamp) {
|
||||
Yap_ma_hash_table[i].timestmp = Yap_timestamp;
|
||||
Yap_ma_hash_table[i].val.addr = addr;
|
||||
Yap_ma_hash_table[i].val.next = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
if (ma_hash_table[i].val.addr == addr)
|
||||
return(TRUE);
|
||||
optr = &(ma_hash_table[i].val);
|
||||
nptr = ma_hash_table[i].val.next;
|
||||
if (Yap_ma_hash_table[i].val.addr == addr)
|
||||
return TRUE;
|
||||
optr = &(Yap_ma_hash_table[i].val);
|
||||
nptr = Yap_ma_hash_table[i].val.next;
|
||||
while (nptr != NULL) {
|
||||
if (nptr->addr == addr) {
|
||||
return(TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
optr = nptr;
|
||||
nptr = nptr->next;
|
||||
}
|
||||
nptr = ALLOC_NEW_MASPACE();
|
||||
nptr = Yap_ALLOC_NEW_MASPACE();
|
||||
nptr->addr = addr;
|
||||
nptr->next = optr;
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
OPT_MAVAR_STATIC UInt
|
||||
NEW_MAHASH(ma_h_inner_struct *top) {
|
||||
UInt time = ++timestamp;
|
||||
Yap_NEW_MAHASH(ma_h_inner_struct *top) {
|
||||
UInt time = ++Yap_timestamp;
|
||||
if (time == 0) {
|
||||
unsigned int i;
|
||||
/* damn, we overflowed */
|
||||
for (i = 0; i < MAVARS_HASH_SIZE; i++)
|
||||
ma_hash_table[i].timestmp = 0;
|
||||
time = ++timestamp;
|
||||
Yap_ma_hash_table[i].timestmp = 0;
|
||||
time = ++Yap_timestamp;
|
||||
}
|
||||
ma_h_top = top;
|
||||
return(time);
|
||||
Yap_ma_h_top = top;
|
||||
return time;
|
||||
}
|
||||
|
||||
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
Copyright: R. Rocha and NCC - University of Porto, Portugal
|
||||
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;
|
||||
sg_fr_ptr sg_fr;
|
||||
|
||||
check_trail();
|
||||
check_trail(TR);
|
||||
tab_ent = PREG->u.ld.te;
|
||||
sg_fr = subgoal_search(PREG, &YENV);
|
||||
LOCK(SgFr_lock(sg_fr));
|
||||
@ -468,7 +468,7 @@
|
||||
tab_ent_ptr tab_ent;
|
||||
sg_fr_ptr sg_fr;
|
||||
|
||||
check_trail();
|
||||
check_trail(TR);
|
||||
tab_ent = PREG->u.ld.te;
|
||||
sg_fr = subgoal_search(PREG, &YENV);
|
||||
LOCK(SgFr_lock(sg_fr));
|
||||
@ -578,7 +578,7 @@
|
||||
tab_ent_ptr tab_ent;
|
||||
sg_fr_ptr sg_fr;
|
||||
|
||||
check_trail();
|
||||
check_trail(TR);
|
||||
tab_ent = PREG->u.ld.te;
|
||||
sg_fr = subgoal_search(PREG, &YENV);
|
||||
LOCK(SgFr_lock(sg_fr));
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
Copyright: R. Rocha and NCC - University of Porto, Portugal
|
||||
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)");
|
||||
#endif /* TABLING_ERRORS */
|
||||
/* rebind loop */
|
||||
NEW_MAHASH((ma_h_inner_struct *)H);
|
||||
Yap_NEW_MAHASH((ma_h_inner_struct *)H);
|
||||
while (rebind_tr != end_tr) {
|
||||
CELL ref = (CELL) TrailTerm(--rebind_tr);
|
||||
/* 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
|
||||
} else {
|
||||
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 */
|
||||
*cell_ptr = TrailVal(rebind_tr);
|
||||
}
|
||||
|
19
configure.in
19
configure.in
@ -192,23 +192,6 @@ then
|
||||
AC_DEFINE(MinHeapSpace, (400*SIZEOF_INT_P))
|
||||
AC_DEFINE(MinStackSpace,(300*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
|
||||
then
|
||||
echo
|
||||
@ -259,7 +242,7 @@ then
|
||||
CFLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes"
|
||||
C_INTERF_FLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes"
|
||||
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_PARSER_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes"
|
||||
case "$target_cpu" in
|
||||
|
Reference in New Issue
Block a user