cache abstra machine register in threaded mode.
This commit is contained in:
parent
9c3041f1e3
commit
90d93fdbdd
30
C/absmi.c
30
C/absmi.c
@ -492,6 +492,7 @@
|
||||
|
||||
|
||||
#define IN_ABSMI_C 1
|
||||
#define HAS_CACHE_REGS 1
|
||||
|
||||
#include "absmi.h"
|
||||
#include "heapgc.h"
|
||||
@ -542,6 +543,7 @@ creep_allowed(PredEntry *p, PredEntry *p0)
|
||||
static Term
|
||||
push_live_regs(yamop *pco)
|
||||
{
|
||||
CACHE_REGS
|
||||
CELL *lab = (CELL *)(pco->u.l.l);
|
||||
CELL max = lab[0];
|
||||
CELL curr = lab[1];
|
||||
@ -610,6 +612,7 @@ char *Yap_op_names[_std_top + 1] =
|
||||
Int
|
||||
Yap_absmi(int inp)
|
||||
{
|
||||
CACHE_REGS
|
||||
#if BP_FREE
|
||||
/* some function might be using bp for an internal variable, it is the
|
||||
callee's responsability to save it */
|
||||
@ -688,7 +691,11 @@ Yap_absmi(int inp)
|
||||
#if PUSH_REGS
|
||||
old_regs = &Yap_REGS;
|
||||
init_absmi_regs(&absmi_regs);
|
||||
#if THREADS
|
||||
regcache = Yap_regp
|
||||
#else
|
||||
Yap_regp = &absmi_regs;
|
||||
#endif
|
||||
#endif
|
||||
CACHE_A1();
|
||||
PREG=bpEntry->CodeOfPred;
|
||||
@ -719,6 +726,7 @@ Yap_absmi(int inp)
|
||||
#ifdef THREADS
|
||||
pthread_setspecific(Yap_yaamregs_key, (const void *)&absmi_regs);
|
||||
MY_ThreadHandle.current_yaam_regs = &absmi_regs;
|
||||
regcache = &absmi_regs;
|
||||
#else
|
||||
Yap_regp = &absmi_regs;
|
||||
#endif
|
||||
@ -7480,7 +7488,7 @@ Yap_absmi(int inp)
|
||||
CPredicate f = PREG->u.Osbpp.p->cs.f_code;
|
||||
PREG = NEXTOP(PREG, Osbpp);
|
||||
saveregs();
|
||||
d0 = (f)();
|
||||
d0 = (f)(PASS_REGS1);
|
||||
setregs();
|
||||
#ifdef SHADOW_S
|
||||
SREG = Yap_REGS.S_;
|
||||
@ -7548,7 +7556,7 @@ Yap_absmi(int inp)
|
||||
CPredicate f = PREG->u.pp.p->cs.f_code;
|
||||
yamop *oldPREG = PREG;
|
||||
saveregs();
|
||||
d0 = (f)();
|
||||
d0 = (f)(PASS_REGS1);
|
||||
setregs();
|
||||
#ifdef SHADOW_S
|
||||
SREG = Yap_REGS.S_;
|
||||
@ -7607,7 +7615,7 @@ Yap_absmi(int inp)
|
||||
/* make sure that we can still have access to our old PREG after calling user defined goals and backtracking or failing */
|
||||
yamop *savedP;
|
||||
|
||||
Yap_StartSlots();
|
||||
Yap_StartSlots( PASS_REGS1 );
|
||||
Yap_PrologMode = UserCCallMode;
|
||||
{
|
||||
PredEntry *p = PREG->u.Osbpp.p;
|
||||
@ -7619,7 +7627,7 @@ Yap_absmi(int inp)
|
||||
|
||||
SREG = (CELL *) YAP_Execute(p, p->cs.f_code);
|
||||
}
|
||||
Yap_CloseSlots();
|
||||
Yap_CloseSlots( PASS_REGS1 );
|
||||
setregs();
|
||||
Yap_PrologMode = UserMode;
|
||||
restore_machine_regs();
|
||||
@ -7673,7 +7681,7 @@ Yap_absmi(int inp)
|
||||
{
|
||||
CPredicate f = PREG->u.slp.p->cs.f_code;
|
||||
saveregs();
|
||||
SREG = (CELL *)((f)());
|
||||
SREG = (CELL *)((f)(PASS_REGS1));
|
||||
setregs();
|
||||
}
|
||||
if (!SREG) {
|
||||
@ -7711,7 +7719,7 @@ Yap_absmi(int inp)
|
||||
{
|
||||
CPredicate f = (CPredicate)(PREG->u.OtapFs.f);
|
||||
saveregs();
|
||||
SREG = (CELL *) ((f) ());
|
||||
SREG = (CELL *) ((f) (PASS_REGS1));
|
||||
/* This last instruction changes B B*/
|
||||
#ifdef CUT_C
|
||||
while (POP_CHOICE_POINT(B)){
|
||||
@ -7792,7 +7800,7 @@ Yap_absmi(int inp)
|
||||
Yap_PrologMode = UserCCallMode;
|
||||
ASP = YREG;
|
||||
/* for slots to work */
|
||||
Yap_StartSlots();
|
||||
Yap_StartSlots( PASS_REGS1 );
|
||||
saveregs();
|
||||
save_machine_regs();
|
||||
SREG = (CELL *) YAP_ExecuteFirst(PREG->u.OtapFs.p, (CPredicate)(PREG->u.OtapFs.f));
|
||||
@ -7800,7 +7808,7 @@ Yap_absmi(int inp)
|
||||
restore_machine_regs();
|
||||
setregs();
|
||||
Yap_PrologMode = UserMode;
|
||||
Yap_CloseSlots();
|
||||
Yap_CloseSlots( PASS_REGS1 );
|
||||
if (!SREG) {
|
||||
FAIL();
|
||||
}
|
||||
@ -7835,7 +7843,7 @@ Yap_absmi(int inp)
|
||||
Yap_PrologMode = UserCCallMode;
|
||||
SET_ASP(YREG, E_CB*sizeof(CELL));
|
||||
/* for slots to work */
|
||||
Yap_StartSlots();
|
||||
Yap_StartSlots( PASS_REGS1 );
|
||||
saveregs();
|
||||
save_machine_regs();
|
||||
SREG = (CELL *) YAP_ExecuteNext(PREG->u.OtapFs.p, (CPredicate)(PREG->u.OtapFs.f));
|
||||
@ -7843,7 +7851,7 @@ Yap_absmi(int inp)
|
||||
restore_machine_regs();
|
||||
setregs();
|
||||
Yap_PrologMode = UserMode;
|
||||
Yap_CloseSlots();
|
||||
Yap_CloseSlots( PASS_REGS1 );
|
||||
if (!SREG) {
|
||||
#ifdef CUT_C
|
||||
/* Removes the cut functions from the stack
|
||||
@ -7959,7 +7967,7 @@ Yap_absmi(int inp)
|
||||
BOp(thread_local, e);
|
||||
{
|
||||
PredEntry *ap = PredFromDefCode(PREG);
|
||||
ap = Yap_GetThreadPred(ap);
|
||||
ap = Yap_GetThreadPred(ap PASS_REGS);
|
||||
PREG = ap->CodeOfPred;
|
||||
/* for profiler */
|
||||
save_pc();
|
||||
|
37
C/adtdefs.c
37
C/adtdefs.c
@ -489,7 +489,7 @@ Yap_HasOp(Atom a)
|
||||
}
|
||||
|
||||
OpEntry *
|
||||
Yap_GetOpProp(Atom a, op_type type)
|
||||
Yap_GetOpProp(Atom a, op_type type USES_REGS)
|
||||
{ /* look property list of atom a for kind */
|
||||
AtomEntry *ae = RepAtom(a);
|
||||
PropEntry *pp;
|
||||
@ -546,7 +546,7 @@ GetPredPropByAtomHavingLock(AtomEntry* ae, Term cur_mod)
|
||||
#if THREADS
|
||||
/* Thread Local Predicates */
|
||||
if (pe->PredFlags & ThreadLocalPredFlag) {
|
||||
return AbsPredProp(Yap_GetThreadPred(pe));
|
||||
return AbsPredProp(Yap_GetThreadPred(pe INIT_REGS));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -582,7 +582,7 @@ GetPredPropByAtomHavingLockInThisModule(AtomEntry* ae, Term cur_mod)
|
||||
#if THREADS
|
||||
/* Thread Local Predicates */
|
||||
if (pe->PredFlags & ThreadLocalPredFlag) {
|
||||
return AbsPredProp(Yap_GetThreadPred(pe));
|
||||
return AbsPredProp(Yap_GetThreadPred(pe INIT_REGS));
|
||||
}
|
||||
#endif
|
||||
return(p0);
|
||||
@ -808,7 +808,7 @@ Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod)
|
||||
|
||||
#if THREADS
|
||||
Prop
|
||||
Yap_NewThreadPred(PredEntry *ap)
|
||||
Yap_NewThreadPred(PredEntry *ap USES_REGS)
|
||||
{
|
||||
PredEntry *p = (PredEntry *) Yap_AllocAtomSpace(sizeof(*p));
|
||||
|
||||
@ -1121,6 +1121,7 @@ Yap_PutValue(Atom a, Term v)
|
||||
Term
|
||||
Yap_StringToList(char *s)
|
||||
{
|
||||
CACHE_REGS
|
||||
register Term t;
|
||||
register unsigned char *cp = (unsigned char *)s + strlen(s);
|
||||
|
||||
@ -1134,6 +1135,7 @@ Yap_StringToList(char *s)
|
||||
Term
|
||||
Yap_NStringToList(char *s, size_t len)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t;
|
||||
unsigned char *cp = (unsigned char *)s + len;
|
||||
|
||||
@ -1147,6 +1149,7 @@ Yap_NStringToList(char *s, size_t len)
|
||||
Term
|
||||
Yap_WideStringToList(wchar_t *s)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t;
|
||||
wchar_t *cp = s + wcslen(s);
|
||||
|
||||
@ -1160,6 +1163,7 @@ Yap_WideStringToList(wchar_t *s)
|
||||
Term
|
||||
Yap_NWideStringToList(wchar_t *s, size_t len)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t;
|
||||
wchar_t *cp = s + len;
|
||||
|
||||
@ -1171,7 +1175,7 @@ Yap_NWideStringToList(wchar_t *s, size_t len)
|
||||
}
|
||||
|
||||
Term
|
||||
Yap_StringToDiffList(char *s, Term t)
|
||||
Yap_StringToDiffList(char *s, Term t USES_REGS)
|
||||
{
|
||||
register unsigned char *cp = (unsigned char *)s + strlen(s);
|
||||
|
||||
@ -1187,6 +1191,7 @@ Yap_StringToDiffList(char *s, Term t)
|
||||
Term
|
||||
Yap_NStringToDiffList(char *s, Term t, size_t len)
|
||||
{
|
||||
CACHE_REGS
|
||||
register unsigned char *cp = (unsigned char *)s + len;
|
||||
|
||||
t = Yap_Globalise(t);
|
||||
@ -1199,6 +1204,7 @@ Yap_NStringToDiffList(char *s, Term t, size_t len)
|
||||
Term
|
||||
Yap_WideStringToDiffList(wchar_t *s, Term t)
|
||||
{
|
||||
CACHE_REGS
|
||||
wchar_t *cp = s + wcslen(s);
|
||||
|
||||
t = Yap_Globalise(t);
|
||||
@ -1211,6 +1217,7 @@ Yap_WideStringToDiffList(wchar_t *s, Term t)
|
||||
Term
|
||||
Yap_NWideStringToDiffList(wchar_t *s, Term t, size_t len)
|
||||
{
|
||||
CACHE_REGS
|
||||
wchar_t *cp = s + len;
|
||||
|
||||
t = Yap_Globalise(t);
|
||||
@ -1223,6 +1230,7 @@ Yap_NWideStringToDiffList(wchar_t *s, Term t, size_t len)
|
||||
Term
|
||||
Yap_StringToListOfAtoms(char *s)
|
||||
{
|
||||
CACHE_REGS
|
||||
register Term t;
|
||||
char so[2];
|
||||
register unsigned char *cp = (unsigned char *)s + strlen(s);
|
||||
@ -1239,6 +1247,7 @@ Yap_StringToListOfAtoms(char *s)
|
||||
Term
|
||||
Yap_NStringToListOfAtoms(char *s, size_t len)
|
||||
{
|
||||
CACHE_REGS
|
||||
register Term t;
|
||||
char so[2];
|
||||
register unsigned char *cp = (unsigned char *)s + len;
|
||||
@ -1255,6 +1264,7 @@ Yap_NStringToListOfAtoms(char *s, size_t len)
|
||||
Term
|
||||
Yap_WideStringToListOfAtoms(wchar_t *s)
|
||||
{
|
||||
CACHE_REGS
|
||||
register Term t;
|
||||
wchar_t so[2];
|
||||
wchar_t *cp = s + wcslen(s);
|
||||
@ -1271,6 +1281,7 @@ Yap_WideStringToListOfAtoms(wchar_t *s)
|
||||
Term
|
||||
Yap_NWideStringToListOfAtoms(wchar_t *s, size_t len)
|
||||
{
|
||||
CACHE_REGS
|
||||
register Term t;
|
||||
wchar_t so[2];
|
||||
wchar_t *cp = s + len;
|
||||
@ -1287,6 +1298,7 @@ Yap_NWideStringToListOfAtoms(wchar_t *s, size_t len)
|
||||
Term
|
||||
Yap_NWideStringToDiffListOfAtoms(wchar_t *s, Term t0, size_t len)
|
||||
{
|
||||
CACHE_REGS
|
||||
register Term t;
|
||||
wchar_t so[2];
|
||||
wchar_t *cp = s + len;
|
||||
@ -1303,6 +1315,7 @@ Yap_NWideStringToDiffListOfAtoms(wchar_t *s, Term t0, size_t len)
|
||||
Term
|
||||
Yap_ArrayToList(register Term *tp, int nof)
|
||||
{
|
||||
CACHE_REGS
|
||||
register Term *pt = tp + nof;
|
||||
register Term t;
|
||||
|
||||
@ -1379,7 +1392,7 @@ ArgsOfSFTerm(Term t)
|
||||
#endif
|
||||
|
||||
Int
|
||||
Yap_NewSlots(int n)
|
||||
Yap_NewSlots(int n USES_REGS)
|
||||
{
|
||||
Int old_slots = IntOfTerm(ASP[0]), oldn = n;
|
||||
while (n > 0) {
|
||||
@ -1393,7 +1406,7 @@ Yap_NewSlots(int n)
|
||||
}
|
||||
|
||||
Int
|
||||
Yap_InitSlot(Term t)
|
||||
Yap_InitSlot(Term t USES_REGS)
|
||||
{
|
||||
Int old_slots = IntOfTerm(ASP[0]);
|
||||
*ASP = t;
|
||||
@ -1404,7 +1417,7 @@ Yap_InitSlot(Term t)
|
||||
}
|
||||
|
||||
int
|
||||
Yap_RecoverSlots(int n)
|
||||
Yap_RecoverSlots(int n USES_REGS)
|
||||
{
|
||||
Int old_slots = IntOfTerm(ASP[0]);
|
||||
if (old_slots - n < 0) {
|
||||
@ -1417,25 +1430,25 @@ Yap_RecoverSlots(int n)
|
||||
}
|
||||
|
||||
Term
|
||||
Yap_GetFromSlot(Int slot)
|
||||
Yap_GetFromSlot(Int slot USES_REGS)
|
||||
{
|
||||
return(Deref(LCL0[slot]));
|
||||
}
|
||||
|
||||
Term
|
||||
Yap_GetPtrFromSlot(Int slot)
|
||||
Yap_GetPtrFromSlot(Int slot USES_REGS)
|
||||
{
|
||||
return(LCL0[slot]);
|
||||
}
|
||||
|
||||
Term *
|
||||
Yap_AddressFromSlot(Int slot)
|
||||
Yap_AddressFromSlot(Int slot USES_REGS)
|
||||
{
|
||||
return(LCL0+slot);
|
||||
}
|
||||
|
||||
void
|
||||
Yap_PutInSlot(Int slot, Term t)
|
||||
Yap_PutInSlot(Int slot, Term t USES_REGS)
|
||||
{
|
||||
LCL0[slot] = t;
|
||||
}
|
||||
|
54
C/agc.c
54
C/agc.c
@ -33,8 +33,8 @@ static char SccsId[] = "@(#)agc.c 1.3 3/15/90";
|
||||
#define errout Yap_stderr
|
||||
#endif
|
||||
|
||||
STATIC_PROTO(void RestoreEntries, (PropEntry *, int));
|
||||
STATIC_PROTO(void CleanCode, (PredEntry *));
|
||||
STATIC_PROTO(void RestoreEntries, (PropEntry *, int USES_REGS));
|
||||
STATIC_PROTO(void CleanCode, (PredEntry * USES_REGS));
|
||||
|
||||
static int agc_calls;
|
||||
|
||||
@ -112,8 +112,6 @@ AtomAdjust(Atom a)
|
||||
return(a);
|
||||
}
|
||||
|
||||
static Term AdjustDBTerm(Term, Term *);
|
||||
|
||||
#define IsOldCode(P) FALSE
|
||||
#define IsOldCodeCellPtr(P) FALSE
|
||||
#define IsOldDelay(P) FALSE
|
||||
@ -201,10 +199,8 @@ static Term AdjustDBTerm(Term, Term *);
|
||||
|
||||
#include "rheap.h"
|
||||
|
||||
|
||||
|
||||
static void
|
||||
RestoreHashPreds(void)
|
||||
RestoreHashPreds( USES_REGS1 )
|
||||
{
|
||||
UInt i;
|
||||
|
||||
@ -219,14 +215,14 @@ RestoreHashPreds(void)
|
||||
if (p->NextOfPE)
|
||||
p->NextOfPE = PropAdjust(p->NextOfPE);
|
||||
nextp = p->NextOfPE;
|
||||
CleanCode(p);
|
||||
CleanCode(p PASS_REGS);
|
||||
p = RepPredProp(nextp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void init_reg_copies(void)
|
||||
static void init_reg_copies(USES_REGS1)
|
||||
{
|
||||
OldASP = ASP;
|
||||
OldLCL0 = LCL0;
|
||||
@ -242,7 +238,7 @@ static void init_reg_copies(void)
|
||||
|
||||
|
||||
static void
|
||||
RestoreAtomList(Atom atm)
|
||||
RestoreAtomList(Atom atm USES_REGS)
|
||||
{
|
||||
AtomEntry *at;
|
||||
|
||||
@ -250,7 +246,7 @@ RestoreAtomList(Atom atm)
|
||||
if (EndOfPAEntr(at))
|
||||
return;
|
||||
do {
|
||||
RestoreAtom(atm);
|
||||
RestoreAtom(atm PASS_REGS);
|
||||
atm = CleanAtomMarkedBit(at->NextOfAE);
|
||||
at = RepAtom(atm);
|
||||
} while (!EndOfPAEntr(at));
|
||||
@ -259,7 +255,7 @@ RestoreAtomList(Atom atm)
|
||||
|
||||
|
||||
static void
|
||||
mark_trail(void)
|
||||
mark_trail(USES_REGS1)
|
||||
{
|
||||
register tr_fr_ptr pt;
|
||||
|
||||
@ -279,7 +275,7 @@ mark_trail(void)
|
||||
}
|
||||
|
||||
static void
|
||||
mark_registers(void)
|
||||
mark_registers(USES_REGS1)
|
||||
{
|
||||
CELL *pt;
|
||||
|
||||
@ -297,7 +293,7 @@ mark_registers(void)
|
||||
}
|
||||
|
||||
static void
|
||||
mark_local(void)
|
||||
mark_local(USES_REGS1)
|
||||
{
|
||||
CELL *pt;
|
||||
|
||||
@ -355,7 +351,7 @@ mark_global_cell(CELL *pt)
|
||||
}
|
||||
|
||||
static void
|
||||
mark_global(void)
|
||||
mark_global(USES_REGS1)
|
||||
{
|
||||
CELL *pt;
|
||||
|
||||
@ -370,12 +366,12 @@ mark_global(void)
|
||||
}
|
||||
|
||||
static void
|
||||
mark_stacks(void)
|
||||
mark_stacks(USES_REGS1)
|
||||
{
|
||||
mark_registers();
|
||||
mark_trail();
|
||||
mark_local();
|
||||
mark_global();
|
||||
mark_registers(PASS_REGS1);
|
||||
mark_trail(PASS_REGS1);
|
||||
mark_local(PASS_REGS1);
|
||||
mark_global(PASS_REGS1);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -433,7 +429,7 @@ clean_atoms(void)
|
||||
}
|
||||
|
||||
static void
|
||||
atom_gc(void)
|
||||
atom_gc(USES_REGS1)
|
||||
{
|
||||
int gc_verbose = Yap_is_gc_verbose();
|
||||
int gc_trace = 0;
|
||||
@ -457,8 +453,8 @@ atom_gc(void)
|
||||
time_start = Yap_cputime();
|
||||
/* get the number of active registers */
|
||||
YAPEnterCriticalSection();
|
||||
init_reg_copies();
|
||||
mark_stacks();
|
||||
init_reg_copies(PASS_REGS1);
|
||||
mark_stacks(PASS_REGS1);
|
||||
restore_codes();
|
||||
clean_atoms();
|
||||
AGcLastCall = NOfAtoms;
|
||||
@ -477,22 +473,22 @@ atom_gc(void)
|
||||
}
|
||||
|
||||
void
|
||||
Yap_atom_gc(void)
|
||||
Yap_atom_gc(USES_REGS1)
|
||||
{
|
||||
atom_gc();
|
||||
atom_gc(PASS_REGS1);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_atom_gc(void)
|
||||
p_atom_gc(USES_REGS1)
|
||||
{
|
||||
#ifndef FIXED_STACKS
|
||||
atom_gc();
|
||||
atom_gc(PASS_REGS1);
|
||||
#endif /* FIXED_STACKS */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_inform_agc(void)
|
||||
p_inform_agc(USES_REGS1)
|
||||
{
|
||||
Term tn = MkIntegerTerm(tot_agc_time);
|
||||
Term tt = MkIntegerTerm(agc_calls);
|
||||
@ -505,7 +501,7 @@ p_inform_agc(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_agc_threshold(void)
|
||||
p_agc_threshold(USES_REGS1)
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
if (IsVarTerm(t)) {
|
||||
|
@ -240,6 +240,7 @@ Yap_FreeAtomSpace(char *p)
|
||||
ADDR
|
||||
Yap_InitPreAllocCodeSpace(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
char *ptr;
|
||||
UInt sz = ScratchPad.msz;
|
||||
if (ScratchPad.ptr == NULL) {
|
||||
@ -287,6 +288,7 @@ Yap_InitPreAllocCodeSpace(void)
|
||||
ADDR
|
||||
Yap_ExpandPreAllocCodeSpace(UInt sz0, void *cip, int safe)
|
||||
{
|
||||
CACHE_REGS
|
||||
char *ptr;
|
||||
UInt sz = ScratchPad.msz;
|
||||
if (sz0 < SCRATCH_INC_SIZE)
|
||||
@ -331,6 +333,7 @@ struct various_codes *Yap_heap_regs;
|
||||
static void
|
||||
InitHeap(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
Yap_heap_regs = (struct various_codes *)calloc(1, sizeof(struct various_codes));
|
||||
#if defined(YAPOR) || defined(TABLING)
|
||||
LOCAL = REMOTE; /* point to the first area */
|
||||
@ -348,6 +351,7 @@ Yap_InitHeap(void *heap_addr)
|
||||
static void
|
||||
InitExStacks(int Trail, int Stack)
|
||||
{
|
||||
CACHE_REGS
|
||||
UInt pm, sa;
|
||||
|
||||
/* sanity checking for data areas */
|
||||
@ -421,6 +425,7 @@ Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack)
|
||||
int
|
||||
Yap_ExtendWorkSpace(Int s)
|
||||
{
|
||||
CACHE_REGS
|
||||
void *basebp = (void *)Yap_GlobalBase, *nbp;
|
||||
UInt s0 = (char *)Yap_TrailTop-(char *)Yap_GlobalBase;
|
||||
nbp = realloc(basebp, s+s0);
|
||||
|
35
C/amasm.c
35
C/amasm.c
@ -257,7 +257,7 @@ STATIC_PROTO(yamop *a_either, (op_numbers, CELL, CELL, int, int, yamop *, int, s
|
||||
STATIC_PROTO(yamop *a_try, (op_numbers, CELL, CELL, yamop *, int, struct intermediates *));
|
||||
STATIC_PROTO(yamop *a_either, (op_numbers, CELL, CELL, yamop *, int, struct intermediates *));
|
||||
#endif /* YAPOR */
|
||||
STATIC_PROTO(yamop *a_gl, (op_numbers, yamop *, int, struct PSEUDO *, struct intermediates *));
|
||||
STATIC_PROTO(yamop *a_gl, (op_numbers, yamop *, int, struct PSEUDO *, struct intermediates * CACHE_TYPE));
|
||||
STATIC_PROTO(yamop *a_bfunc, (CELL, clause_info *, yamop *, int, struct intermediates *));
|
||||
STATIC_PROTO(
|
||||
COUNT compile_cmp_flags, (char *));
|
||||
@ -266,7 +266,7 @@ STATIC_PROTO(yamop *a_xigl, (op_numbers, yamop *, int, struct PSEUDO *));
|
||||
STATIC_PROTO(yamop *a_ucons, (int *, compiler_vm_op, yamop *, int, struct intermediates *));
|
||||
STATIC_PROTO(yamop *a_uvar, (yamop *, int, struct intermediates *));
|
||||
STATIC_PROTO(yamop *a_wvar, (yamop *, int, struct intermediates *));
|
||||
STATIC_PROTO(yamop *do_pass, (int, yamop **, int, int *, int *,struct intermediates *, UInt));
|
||||
STATIC_PROTO(yamop *do_pass, (int, yamop **, int, int *, int *,struct intermediates *, UInt CACHE_TYPE));
|
||||
#ifdef DEBUG_OPCODES
|
||||
STATIC_PROTO(void DumpOpCodes, (void));
|
||||
#endif
|
||||
@ -2193,7 +2193,7 @@ a_either(op_numbers opcode, CELL opr, CELL lab, yamop *code_p, int pass_no, stru
|
||||
}
|
||||
|
||||
static yamop *
|
||||
a_gl(op_numbers opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc, struct intermediates *cip)
|
||||
a_gl(op_numbers opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc, struct intermediates *cip USES_REGS)
|
||||
{
|
||||
#ifdef YAPOR
|
||||
return a_try(opcode, cpc->rnd1, IPredArity, cpc->rnd2 >> 1, cpc->rnd2 & 1, code_p, pass_no, cip);
|
||||
@ -2989,7 +2989,7 @@ a_special_label(yamop *code_p, int pass_no, struct intermediates *cip)
|
||||
#endif /* YAPOR */
|
||||
|
||||
static yamop *
|
||||
do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp, int *clause_has_dbtermp, struct intermediates *cip, UInt size)
|
||||
do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp, int *clause_has_dbtermp, struct intermediates *cip, UInt size USES_REGS)
|
||||
{
|
||||
#ifdef YAPOR
|
||||
#define MAX_DISJ_BRANCHES 256
|
||||
@ -3152,7 +3152,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
||||
code_p = a_n(_table_new_answer, (int) cip->cpc->rnd2, code_p, pass_no);
|
||||
break;
|
||||
case table_try_single_op:
|
||||
code_p = a_gl(_table_try_single, code_p, pass_no, cip->cpc, cip);
|
||||
code_p = a_gl(_table_try_single, code_p, pass_no, cip->cpc, cip PASS_REGS);
|
||||
break;
|
||||
#endif /* TABLING */
|
||||
#ifdef TABLING_INNER_CUTS
|
||||
@ -3451,10 +3451,10 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
||||
}
|
||||
#ifdef TABLING
|
||||
if (tabled)
|
||||
code_p = a_gl(_table_try, code_p, pass_no, cip->cpc, cip);
|
||||
code_p = a_gl(_table_try, code_p, pass_no, cip->cpc, cip PASS_REGS);
|
||||
else
|
||||
#endif
|
||||
code_p = a_gl(_try_clause, code_p, pass_no, cip->cpc, cip);
|
||||
code_p = a_gl(_try_clause, code_p, pass_no, cip->cpc, cip PASS_REGS);
|
||||
break;
|
||||
case retry_op:
|
||||
if (log_update) {
|
||||
@ -3462,10 +3462,10 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
||||
}
|
||||
#ifdef TABLING
|
||||
if (tabled)
|
||||
code_p = a_gl(_table_retry, code_p, pass_no, cip->cpc, cip);
|
||||
code_p = a_gl(_table_retry, code_p, pass_no, cip->cpc, cip PASS_REGS);
|
||||
else
|
||||
#endif
|
||||
code_p = a_gl(_retry, code_p, pass_no, cip->cpc, cip);
|
||||
code_p = a_gl(_retry, code_p, pass_no, cip->cpc, cip PASS_REGS);
|
||||
break;
|
||||
case trust_op:
|
||||
if (log_update) {
|
||||
@ -3473,10 +3473,10 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
||||
}
|
||||
#ifdef TABLING
|
||||
if (tabled)
|
||||
code_p = a_gl(_table_trust, code_p, pass_no, cip->cpc, cip);
|
||||
code_p = a_gl(_table_trust, code_p, pass_no, cip->cpc, cip PASS_REGS);
|
||||
else
|
||||
#endif
|
||||
code_p = a_gl(_trust, code_p, pass_no, cip->cpc, cip);
|
||||
code_p = a_gl(_trust, code_p, pass_no, cip->cpc, cip PASS_REGS);
|
||||
break;
|
||||
case try_in_op:
|
||||
code_p = a_il(cip->cpc->rnd1, _try_in, code_p, pass_no, cip);
|
||||
@ -3774,7 +3774,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
||||
|
||||
|
||||
static DBTerm *
|
||||
fetch_clause_space(Term* tp, UInt size, struct intermediates *cip, UInt *osizep)
|
||||
fetch_clause_space(Term* tp, UInt size, struct intermediates *cip, UInt *osizep USES_REGS)
|
||||
{
|
||||
CELL *h0 = H;
|
||||
DBTerm *x;
|
||||
@ -3848,6 +3848,7 @@ init_dbterms_list(yamop *code_p, PredEntry *ap)
|
||||
yamop *
|
||||
Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates *cip, UInt max_label)
|
||||
{
|
||||
CACHE_REGS
|
||||
/*
|
||||
* the assembly proccess is done in two passes: 1 - a first pass
|
||||
* computes labels offsets and total code size 2 - the second pass
|
||||
@ -3883,7 +3884,7 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
||||
cip->label_offset = (Int *)cip->freep;
|
||||
#endif
|
||||
cip->code_addr = NULL;
|
||||
code_p = do_pass(0, &entry_code, mode, &clause_has_blobs, &clause_has_dbterm, cip, size);
|
||||
code_p = do_pass(0, &entry_code, mode, &clause_has_blobs, &clause_has_dbterm, cip, size PASS_REGS);
|
||||
if (clause_has_dbterm) {
|
||||
cip->dbterml = init_dbterms_list(code_p, ap);
|
||||
}
|
||||
@ -3900,7 +3901,7 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
||||
LogUpdClause *cl;
|
||||
UInt osize;
|
||||
|
||||
if(!(x = fetch_clause_space(&t,size,cip,&osize))){
|
||||
if(!(x = fetch_clause_space(&t, size, cip, &osize PASS_REGS))){
|
||||
return NULL;
|
||||
}
|
||||
cl = (LogUpdClause *)((CODEADDR)x-(UInt)size);
|
||||
@ -3914,12 +3915,12 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
||||
DBTerm *x;
|
||||
StaticClause *cl;
|
||||
UInt osize;
|
||||
if(!(x = fetch_clause_space(&t,size,cip,&osize))) {
|
||||
if(!(x = fetch_clause_space(&t, size, cip, &osize PASS_REGS))) {
|
||||
return NULL;
|
||||
}
|
||||
cl = (StaticClause *)((CODEADDR)x-(UInt)size);
|
||||
cip->code_addr = (yamop *)cl;
|
||||
code_p = do_pass(1, &entry_code, mode, &clause_has_blobs, &clause_has_dbterm, cip, size);
|
||||
code_p = do_pass(1, &entry_code, mode, &clause_has_blobs, &clause_has_dbterm, cip, size PASS_REGS);
|
||||
/* make sure we copy after second pass */
|
||||
cl->usc.ClSource = x;
|
||||
cl->ClSize = osize;
|
||||
@ -3946,7 +3947,7 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
||||
Yap_IndexSpace_Tree += size;
|
||||
}
|
||||
}
|
||||
code_p = do_pass(1, &entry_code, mode, &clause_has_blobs, &clause_has_dbterm, cip, size);
|
||||
code_p = do_pass(1, &entry_code, mode, &clause_has_blobs, &clause_has_dbterm, cip, size PASS_REGS);
|
||||
ProfEnd=code_p;
|
||||
#ifdef LOW_PROF
|
||||
if (ProfilerOn &&
|
||||
|
@ -56,6 +56,7 @@ static char SccsId[] = "%W% %G%";
|
||||
|
||||
static Term
|
||||
eval0(Int fi) {
|
||||
CACHE_REGS
|
||||
arith0_op fop = fi;
|
||||
switch (fop) {
|
||||
case op_pi:
|
||||
|
@ -745,7 +745,7 @@ static InitUnEntry InitUnTab[] = {
|
||||
};
|
||||
|
||||
static Int
|
||||
p_unary_is(void)
|
||||
p_unary_is( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
Term t = Deref(ARG2);
|
||||
Term top;
|
||||
@ -790,7 +790,7 @@ p_unary_is(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_unary_op_as_integer(void)
|
||||
p_unary_op_as_integer( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
Term t = Deref(ARG1);
|
||||
|
||||
|
38
C/arith2.c
38
C/arith2.c
@ -1050,7 +1050,7 @@ static InitBinEntry InitBinTab[] = {
|
||||
};
|
||||
|
||||
static Int
|
||||
p_binary_is(void)
|
||||
p_binary_is( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
Term t = Deref(ARG2);
|
||||
Term t1, t2;
|
||||
@ -1099,7 +1099,7 @@ p_binary_is(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
do_arith23(arith2_op op)
|
||||
do_arith23(arith2_op op USES_REGS)
|
||||
{ /* X is Y */
|
||||
Term t = Deref(ARG1);
|
||||
Int out;
|
||||
@ -1121,55 +1121,55 @@ do_arith23(arith2_op op)
|
||||
}
|
||||
|
||||
static Int
|
||||
export_p_plus(void)
|
||||
export_p_plus( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
return do_arith23(op_plus);
|
||||
return do_arith23(op_plus PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
export_p_minus(void)
|
||||
export_p_minus( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
return do_arith23(op_minus);
|
||||
return do_arith23(op_minus PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
export_p_times(void)
|
||||
export_p_times( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
return do_arith23(op_times);
|
||||
return do_arith23(op_times PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
export_p_div(void)
|
||||
export_p_div( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
return do_arith23(op_div);
|
||||
return do_arith23(op_div PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
export_p_and(void)
|
||||
export_p_and( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
return do_arith23(op_and);
|
||||
return do_arith23(op_and PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
export_p_or(void)
|
||||
export_p_or( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
return do_arith23(op_or);
|
||||
return do_arith23(op_or PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
export_p_slr(void)
|
||||
export_p_slr( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
return do_arith23(op_slr);
|
||||
return do_arith23(op_slr PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
export_p_sll(void)
|
||||
export_p_sll( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
return do_arith23(op_sll);
|
||||
return do_arith23(op_sll PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_binary_op_as_integer(void)
|
||||
p_binary_op_as_integer( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
Term t = Deref(ARG1);
|
||||
|
||||
|
332
C/arrays.c
332
C/arrays.c
@ -34,9 +34,9 @@ extern int errno;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
STATIC_PROTO(Int p_compile_array_refs, (void));
|
||||
STATIC_PROTO(Int p_array_refs_compiled, (void));
|
||||
STATIC_PROTO(Int p_sync_mmapped_arrays, (void));
|
||||
STATIC_PROTO(Int p_compile_array_refs, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_array_refs_compiled, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_sync_mmapped_arrays, ( USES_REGS1 ));
|
||||
|
||||
/*
|
||||
*
|
||||
@ -122,28 +122,117 @@ STATIC_PROTO(Int p_sync_mmapped_arrays, (void));
|
||||
*
|
||||
*/
|
||||
|
||||
STATIC_PROTO(Term AccessNamedArray, (Atom, Int));
|
||||
STATIC_PROTO(void InitNamedArray, (ArrayEntry *, Int));
|
||||
STATIC_PROTO(void CreateNamedArray, (PropEntry *, Int, AtomEntry *));
|
||||
STATIC_PROTO(void ResizeStaticArray, (StaticArrayEntry *, Int));
|
||||
STATIC_PROTO(Int p_create_array, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_create_mmapped_array, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_array_references, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_create_static_array, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_resize_static_array, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_close_static_array, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_access_array, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_assign_static, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_assign_dynamic, ( USES_REGS1 ));
|
||||
|
||||
#if HAVE_MMAP
|
||||
STATIC_PROTO(Int CloseMmappedArray, (StaticArrayEntry *, void *));
|
||||
STATIC_PROTO(void ResizeMmappedArray, (StaticArrayEntry *, Int, void *));
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#if HAVE_SYS_MMAN_H
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#if HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#if HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
/* keep a list of mmaped blocks to synch on exit */
|
||||
|
||||
typedef struct MMAP_ARRAY_BLOCK {
|
||||
Atom name;
|
||||
void *start;
|
||||
size_t size;
|
||||
Int items;
|
||||
int fd;
|
||||
struct MMAP_ARRAY_BLOCK *next;
|
||||
} mmap_array_block;
|
||||
|
||||
static mmap_array_block *mmap_arrays = NULL;
|
||||
|
||||
static Int
|
||||
CloseMmappedArray(StaticArrayEntry *pp, void *area USES_REGS)
|
||||
{
|
||||
mmap_array_block *ptr = mmap_arrays, *optr = mmap_arrays;
|
||||
|
||||
while (ptr != NULL && ptr->start != area) {
|
||||
ptr = ptr->next;
|
||||
optr = ptr;
|
||||
}
|
||||
if (ptr == NULL) {
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (array chain incoherent)", strerror(errno));
|
||||
return(FALSE);
|
||||
}
|
||||
if (munmap(ptr->start, ptr->size) == -1) {
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (munmap: %s)", strerror(errno));
|
||||
return(FALSE);
|
||||
}
|
||||
optr->next = ptr->next;
|
||||
pp->ValueOfVE.ints = NULL;
|
||||
pp->ArrayEArity = 0;
|
||||
if (close(ptr->fd) < 0) {
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (close: %s)", strerror(errno));
|
||||
return(FALSE);
|
||||
}
|
||||
Yap_FreeAtomSpace((char *)ptr);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
ResizeMmappedArray(StaticArrayEntry *pp, Int dim, void *area USES_REGS)
|
||||
{
|
||||
mmap_array_block *ptr = mmap_arrays;
|
||||
size_t total_size;
|
||||
while (ptr != NULL && ptr->start != area) {
|
||||
ptr = ptr->next;
|
||||
}
|
||||
if (ptr == NULL)
|
||||
return;
|
||||
/* This is a very stupid algorithm to change size for an array.
|
||||
|
||||
First, we unmap it, then we actually change the size for the file,
|
||||
and last we initialise again
|
||||
*/
|
||||
if (munmap(ptr->start, ptr->size) == -1) {
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (munmap: %s)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
total_size = (ptr->size / ptr->items)*dim;
|
||||
if (ftruncate(ptr->fd, total_size) < 0) {
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (ftruncate: %s)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
if (lseek(ptr->fd, total_size-1, SEEK_SET) < 0) {
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (lseek: %s)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
if (write(ptr->fd, "", 1) < 0) {
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (write: %s)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
if ((ptr->start = (void *)mmap(0, (size_t) total_size, PROT_READ | PROT_WRITE, MAP_SHARED, ptr->fd, 0)) == (void *) - 1) {
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (mmap: %s)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
ptr->size = total_size;
|
||||
ptr->items = dim;
|
||||
pp->ValueOfVE.chars = ptr->start;
|
||||
}
|
||||
|
||||
#endif
|
||||
STATIC_PROTO(Int p_create_array, (void));
|
||||
STATIC_PROTO(Int p_create_mmapped_array, (void));
|
||||
STATIC_PROTO(void replace_array_references_complex, (CELL *, CELL *, CELL *, Term));
|
||||
STATIC_PROTO(Term replace_array_references, (Term));
|
||||
STATIC_PROTO(Int p_array_references, (void));
|
||||
STATIC_PROTO(Int p_create_static_array, (void));
|
||||
STATIC_PROTO(Int p_resize_static_array, (void));
|
||||
STATIC_PROTO(Int p_close_static_array, (void));
|
||||
STATIC_PROTO(Int p_access_array, (void));
|
||||
STATIC_PROTO(Int p_assign_static, (void));
|
||||
STATIC_PROTO(Int p_assign_dynamic, (void));
|
||||
|
||||
static Term
|
||||
GetTermFromArray(DBTerm *ref)
|
||||
GetTermFromArray(DBTerm *ref USES_REGS)
|
||||
{
|
||||
if (ref != NULL) {
|
||||
Term TRef;
|
||||
@ -171,7 +260,7 @@ GetTermFromArray(DBTerm *ref)
|
||||
}
|
||||
|
||||
static Term
|
||||
GetNBTerm(live_term *ar, Int indx)
|
||||
GetNBTerm(live_term *ar, Int indx USES_REGS)
|
||||
{
|
||||
/* The object is now in use */
|
||||
Term livet = ar[indx].tlive;
|
||||
@ -196,7 +285,7 @@ GetNBTerm(live_term *ar, Int indx)
|
||||
livet = termt;
|
||||
} else {
|
||||
DBTerm *ref = (DBTerm *)RepAppl(termt);
|
||||
if ((livet = GetTermFromArray(ref)) == TermNil) {
|
||||
if ((livet = GetTermFromArray(ref PASS_REGS)) == TermNil) {
|
||||
return TermNil;
|
||||
}
|
||||
}
|
||||
@ -206,7 +295,7 @@ GetNBTerm(live_term *ar, Int indx)
|
||||
}
|
||||
|
||||
static Term
|
||||
AccessNamedArray(Atom a, Int indx)
|
||||
AccessNamedArray(Atom a, Int indx USES_REGS)
|
||||
{
|
||||
AtomEntry *ae = RepAtom(a);
|
||||
ArrayEntry *pp;
|
||||
@ -332,7 +421,7 @@ AccessNamedArray(Atom a, Int indx)
|
||||
case array_of_nb_terms:
|
||||
{
|
||||
/* The object is now in use */
|
||||
Term out = GetNBTerm(ptr->ValueOfVE.lterms, indx);
|
||||
Term out = GetNBTerm(ptr->ValueOfVE.lterms, indx PASS_REGS);
|
||||
|
||||
READ_UNLOCK(ptr->ArRWLock);
|
||||
return out;
|
||||
@ -343,7 +432,7 @@ AccessNamedArray(Atom a, Int indx)
|
||||
DBTerm *ref = ptr->ValueOfVE.terms[indx];
|
||||
|
||||
READ_UNLOCK(ptr->ArRWLock);
|
||||
return GetTermFromArray(ref);
|
||||
return GetTermFromArray(ref PASS_REGS);
|
||||
}
|
||||
default:
|
||||
READ_UNLOCK(ptr->ArRWLock);
|
||||
@ -359,7 +448,7 @@ AccessNamedArray(Atom a, Int indx)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_access_array(void)
|
||||
p_access_array( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
Term ti = Deref(ARG2);
|
||||
@ -389,7 +478,7 @@ p_access_array(void)
|
||||
}
|
||||
tf = (RepAppl(t))[indx + 1];
|
||||
} else if (IsAtomTerm(t)) {
|
||||
tf = AccessNamedArray(AtomOfTerm(t), indx);
|
||||
tf = AccessNamedArray(AtomOfTerm(t), indx PASS_REGS);
|
||||
if (tf == MkAtomTerm(AtomFoundVar)) {
|
||||
return(FALSE);
|
||||
}
|
||||
@ -405,7 +494,7 @@ p_access_array(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_array_arg(void)
|
||||
p_array_arg( USES_REGS1 )
|
||||
{
|
||||
register Term ti = Deref(ARG3), t;
|
||||
register Int indx;
|
||||
@ -430,7 +519,7 @@ p_array_arg(void)
|
||||
return (Yap_unify(((RepAppl(t))[indx + 1]), ARG1));
|
||||
}
|
||||
else if (IsAtomTerm(t)) {
|
||||
Term tf = AccessNamedArray(AtomOfTerm(t), indx);
|
||||
Term tf = AccessNamedArray(AtomOfTerm(t), indx PASS_REGS);
|
||||
if (tf == MkAtomTerm(AtomFoundVar)) {
|
||||
return(FALSE);
|
||||
}
|
||||
@ -447,7 +536,7 @@ p_array_arg(void)
|
||||
}
|
||||
|
||||
static void
|
||||
InitNamedArray(ArrayEntry * p, Int dim)
|
||||
InitNamedArray(ArrayEntry * p, Int dim USES_REGS)
|
||||
{
|
||||
Term *tp;
|
||||
|
||||
@ -470,7 +559,7 @@ InitNamedArray(ArrayEntry * p, Int dim)
|
||||
|
||||
/* we assume the atom ae is already locked */
|
||||
static void
|
||||
CreateNamedArray(PropEntry * pp, Int dim, AtomEntry *ae)
|
||||
CreateNamedArray(PropEntry * pp, Int dim, AtomEntry *ae USES_REGS)
|
||||
{
|
||||
ArrayEntry *p;
|
||||
|
||||
@ -484,12 +573,12 @@ CreateNamedArray(PropEntry * pp, Int dim, AtomEntry *ae)
|
||||
#endif
|
||||
p->NextAE = DynamicArrays;
|
||||
DynamicArrays = p;
|
||||
InitNamedArray(p, dim);
|
||||
InitNamedArray(p, dim PASS_REGS);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
AllocateStaticArraySpace(StaticArrayEntry *p, static_array_types atype, Int array_size)
|
||||
AllocateStaticArraySpace(StaticArrayEntry *p, static_array_types atype, Int array_size USES_REGS)
|
||||
{
|
||||
Int asize = 0;
|
||||
switch (atype) {
|
||||
@ -529,7 +618,7 @@ AllocateStaticArraySpace(StaticArrayEntry *p, static_array_types atype, Int arra
|
||||
|
||||
/* ae and p are assumed to be locked, if they exist */
|
||||
static StaticArrayEntry *
|
||||
CreateStaticArray(AtomEntry *ae, Int dim, static_array_types type, CODEADDR start_addr, StaticArrayEntry *p)
|
||||
CreateStaticArray(AtomEntry *ae, Int dim, static_array_types type, CODEADDR start_addr, StaticArrayEntry *p USES_REGS)
|
||||
{
|
||||
if (EndOfPAEntr(p)) {
|
||||
while ((p = (StaticArrayEntry *) Yap_AllocAtomSpace(sizeof(*p))) == NULL) {
|
||||
@ -551,7 +640,7 @@ CreateStaticArray(AtomEntry *ae, Int dim, static_array_types type, CODEADDR star
|
||||
if (start_addr == NULL) {
|
||||
int i;
|
||||
|
||||
AllocateStaticArraySpace(p, type, dim);
|
||||
AllocateStaticArraySpace(p, type, dim PASS_REGS);
|
||||
if (p->ValueOfVE.ints == NULL) {
|
||||
WRITE_UNLOCK(p->ArRWLock);
|
||||
return p;
|
||||
@ -602,7 +691,7 @@ CreateStaticArray(AtomEntry *ae, Int dim, static_array_types type, CODEADDR star
|
||||
}
|
||||
|
||||
static void
|
||||
ResizeStaticArray(StaticArrayEntry *pp, Int dim)
|
||||
ResizeStaticArray(StaticArrayEntry *pp, Int dim USES_REGS)
|
||||
{
|
||||
statarray_elements old_v = pp->ValueOfVE;
|
||||
static_array_types type = pp->ArrayType;
|
||||
@ -618,12 +707,12 @@ ResizeStaticArray(StaticArrayEntry *pp, Int dim)
|
||||
#if HAVE_MMAP
|
||||
if (pp->ValueOfVE.chars < (char *)Yap_HeapBase ||
|
||||
pp->ValueOfVE.chars > (char *)HeapTop) {
|
||||
ResizeMmappedArray(pp, dim, (void *)(pp->ValueOfVE.chars));
|
||||
ResizeMmappedArray(pp, dim, (void *)(pp->ValueOfVE.chars) PASS_REGS);
|
||||
WRITE_UNLOCK(pp->ArRWLock);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
AllocateStaticArraySpace(pp, type, dim);
|
||||
AllocateStaticArraySpace(pp, type, dim PASS_REGS);
|
||||
switch(type) {
|
||||
case array_of_ints:
|
||||
for (i = 0; i <mindim; i++)
|
||||
@ -779,7 +868,7 @@ ClearStaticArray(StaticArrayEntry *pp)
|
||||
|
||||
/* create an array (?Name, + Size) */
|
||||
static Int
|
||||
p_create_array(void)
|
||||
p_create_array( USES_REGS1 )
|
||||
{
|
||||
Term ti;
|
||||
Term t;
|
||||
@ -852,7 +941,7 @@ p_create_array(void)
|
||||
} else
|
||||
goto restart;
|
||||
}
|
||||
CreateNamedArray(pp, size, ae);
|
||||
CreateNamedArray(pp, size, ae PASS_REGS);
|
||||
WRITE_UNLOCK(ae->ARWLock);
|
||||
return (TRUE);
|
||||
} else {
|
||||
@ -874,7 +963,7 @@ p_create_array(void)
|
||||
} else
|
||||
goto restart;
|
||||
}
|
||||
InitNamedArray(app, size);
|
||||
InitNamedArray(app, size PASS_REGS);
|
||||
return (TRUE);
|
||||
}
|
||||
}
|
||||
@ -884,7 +973,7 @@ p_create_array(void)
|
||||
|
||||
/* create an array (+Name, + Size, +Props) */
|
||||
static Int
|
||||
p_create_static_array(void)
|
||||
p_create_static_array( USES_REGS1 )
|
||||
{
|
||||
Term ti = Deref(ARG2);
|
||||
Term t = Deref(ARG1);
|
||||
@ -955,7 +1044,7 @@ p_create_static_array(void)
|
||||
|
||||
app = (ArrayEntry *) pp;
|
||||
if (EndOfPAEntr(pp) || pp->ValueOfVE.ints == NULL) {
|
||||
pp = CreateStaticArray(ae, size, props, NULL, pp);
|
||||
pp = CreateStaticArray(ae, size, props, NULL, pp PASS_REGS);
|
||||
if (pp == NULL || pp->ValueOfVE.ints == NULL) {
|
||||
WRITE_UNLOCK(ae->ARWLock);
|
||||
return FALSE;
|
||||
@ -964,7 +1053,7 @@ p_create_static_array(void)
|
||||
return TRUE;
|
||||
} else if (ArrayIsDynamic(app)) {
|
||||
if (IsVarTerm(app->ValueOfVE) && IsUnboundVar(&app->ValueOfVE)) {
|
||||
pp = CreateStaticArray(ae, size, props, NULL, pp);
|
||||
pp = CreateStaticArray(ae, size, props, NULL, pp PASS_REGS);
|
||||
WRITE_UNLOCK(ae->ARWLock);
|
||||
if (pp == NULL) {
|
||||
return FALSE;
|
||||
@ -992,7 +1081,7 @@ p_create_static_array(void)
|
||||
|
||||
/* has a static array associated (+Name) */
|
||||
static Int
|
||||
p_static_array_properties(void)
|
||||
p_static_array_properties( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
|
||||
@ -1046,7 +1135,7 @@ p_static_array_properties(void)
|
||||
/* resize a static array (+Name, + Size, +Props) */
|
||||
/* does not work for mmap arrays yet */
|
||||
static Int
|
||||
p_resize_static_array(void)
|
||||
p_resize_static_array( USES_REGS1 )
|
||||
{
|
||||
Term ti = Deref(ARG3);
|
||||
Term t = Deref(ARG1);
|
||||
@ -1082,7 +1171,7 @@ p_resize_static_array(void)
|
||||
return(FALSE);
|
||||
} else {
|
||||
Int osize = - pp->ArrayEArity;
|
||||
ResizeStaticArray(pp, size);
|
||||
ResizeStaticArray(pp, size PASS_REGS);
|
||||
return(Yap_unify(ARG2,MkIntegerTerm(osize)));
|
||||
}
|
||||
} else {
|
||||
@ -1094,7 +1183,7 @@ p_resize_static_array(void)
|
||||
/* resize a static array (+Name, + Size, +Props) */
|
||||
/* does not work for mmap arrays yet */
|
||||
static Int
|
||||
p_clear_static_array(void)
|
||||
p_clear_static_array( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
|
||||
@ -1124,7 +1213,7 @@ p_clear_static_array(void)
|
||||
|
||||
/* Close a named array (+Name) */
|
||||
static Int
|
||||
p_close_static_array(void)
|
||||
p_close_static_array( USES_REGS1 )
|
||||
{
|
||||
/* does not work for mmap arrays yet */
|
||||
Term t = Deref(ARG1);
|
||||
@ -1151,7 +1240,7 @@ p_close_static_array(void)
|
||||
#if HAVE_MMAP
|
||||
if (ptr->ValueOfVE.chars < (char *)Yap_HeapBase ||
|
||||
ptr->ValueOfVE.chars > (char *)HeapTop) {
|
||||
return(CloseMmappedArray(ptr, (void *)ptr->ValueOfVE.chars));
|
||||
return(CloseMmappedArray(ptr, (void *)ptr->ValueOfVE.chars PASS_REGS));
|
||||
}
|
||||
#endif
|
||||
Yap_FreeAtomSpace((char *)(ptr->ValueOfVE.ints));
|
||||
@ -1168,110 +1257,9 @@ p_close_static_array(void)
|
||||
}
|
||||
}
|
||||
|
||||
#if HAVE_MMAP
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#if HAVE_SYS_MMAN_H
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#if HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#if HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
STATIC_PROTO(void ResizeMmappedArray, (StaticArrayEntry *,Int ,void *));
|
||||
|
||||
/* keep a list of mmaped blocks to synch on exit */
|
||||
|
||||
typedef struct MMAP_ARRAY_BLOCK {
|
||||
Atom name;
|
||||
void *start;
|
||||
size_t size;
|
||||
Int items;
|
||||
int fd;
|
||||
struct MMAP_ARRAY_BLOCK *next;
|
||||
} mmap_array_block;
|
||||
|
||||
static mmap_array_block *mmap_arrays = NULL;
|
||||
|
||||
static Int
|
||||
CloseMmappedArray(StaticArrayEntry *pp, void *area)
|
||||
{
|
||||
mmap_array_block *ptr = mmap_arrays, *optr = mmap_arrays;
|
||||
|
||||
while (ptr != NULL && ptr->start != area) {
|
||||
ptr = ptr->next;
|
||||
optr = ptr;
|
||||
}
|
||||
if (ptr == NULL) {
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (array chain incoherent)", strerror(errno));
|
||||
return(FALSE);
|
||||
}
|
||||
if (munmap(ptr->start, ptr->size) == -1) {
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (munmap: %s)", strerror(errno));
|
||||
return(FALSE);
|
||||
}
|
||||
optr->next = ptr->next;
|
||||
pp->ValueOfVE.ints = NULL;
|
||||
pp->ArrayEArity = 0;
|
||||
if (close(ptr->fd) < 0) {
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (close: %s)", strerror(errno));
|
||||
return(FALSE);
|
||||
}
|
||||
Yap_FreeAtomSpace((char *)ptr);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
ResizeMmappedArray(StaticArrayEntry *pp, Int dim, void *area)
|
||||
{
|
||||
mmap_array_block *ptr = mmap_arrays;
|
||||
size_t total_size;
|
||||
while (ptr != NULL && ptr->start != area) {
|
||||
ptr = ptr->next;
|
||||
}
|
||||
if (ptr == NULL)
|
||||
return;
|
||||
/* This is a very stupid algorithm to change size for an array.
|
||||
|
||||
First, we unmap it, then we actually change the size for the file,
|
||||
and last we initialise again
|
||||
*/
|
||||
if (munmap(ptr->start, ptr->size) == -1) {
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (munmap: %s)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
total_size = (ptr->size / ptr->items)*dim;
|
||||
if (ftruncate(ptr->fd, total_size) < 0) {
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (ftruncate: %s)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
if (lseek(ptr->fd, total_size-1, SEEK_SET) < 0) {
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (lseek: %s)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
if (write(ptr->fd, "", 1) < 0) {
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (write: %s)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
if ((ptr->start = (void *)mmap(0, (size_t) total_size, PROT_READ | PROT_WRITE, MAP_SHARED, ptr->fd, 0)) == (void *) - 1) {
|
||||
Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (mmap: %s)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
ptr->size = total_size;
|
||||
ptr->items = dim;
|
||||
pp->ValueOfVE.chars = ptr->start;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* create an array (+Name, + Size, +Props) */
|
||||
static Int
|
||||
p_create_mmapped_array(void)
|
||||
p_create_mmapped_array( USES_REGS1 )
|
||||
{
|
||||
#ifdef HAVE_MMAP
|
||||
Term ti = Deref(ARG2);
|
||||
@ -1382,7 +1370,7 @@ p_create_mmapped_array(void)
|
||||
} else {
|
||||
WRITE_LOCK(pp->ArRWLock);
|
||||
}
|
||||
CreateStaticArray(ae, size, props, array_addr, pp);
|
||||
CreateStaticArray(ae, size, props, array_addr, pp PASS_REGS);
|
||||
ptr = (mmap_array_block *)Yap_AllocAtomSpace(sizeof(mmap_array_block));
|
||||
ptr->name = AbsAtom(ae);
|
||||
ptr->size = total_size;
|
||||
@ -1414,7 +1402,7 @@ static void
|
||||
replace_array_references_complex(register CELL *pt0,
|
||||
register CELL *pt0_end,
|
||||
register CELL *ptn,
|
||||
Term Var)
|
||||
Term Var USES_REGS)
|
||||
{
|
||||
|
||||
register CELL **to_visit = (CELL **) Yap_PreAllocCodeSpace();
|
||||
@ -1524,7 +1512,7 @@ loop:
|
||||
* variables.
|
||||
*/
|
||||
static Term
|
||||
replace_array_references(Term t0)
|
||||
replace_array_references(Term t0 USES_REGS)
|
||||
{
|
||||
Term t;
|
||||
|
||||
@ -1540,8 +1528,8 @@ replace_array_references(Term t0)
|
||||
|
||||
H += 2;
|
||||
replace_array_references_complex(RepPair(t) - 1, RepPair(t) + 1, h0,
|
||||
VList);
|
||||
return (MkPairTerm(AbsPair(h0), VList));
|
||||
VList PASS_REGS);
|
||||
return MkPairTerm(AbsPair(h0), VList);
|
||||
} else {
|
||||
Term VList = MkVarTerm();
|
||||
CELL *h0 = H;
|
||||
@ -1551,15 +1539,15 @@ replace_array_references(Term t0)
|
||||
H += ArityOfFunctor(f);
|
||||
replace_array_references_complex(RepAppl(t),
|
||||
RepAppl(t) + ArityOfFunctor(FunctorOfTerm(t)), h0 + 1,
|
||||
VList);
|
||||
VList PASS_REGS);
|
||||
return (MkPairTerm(AbsAppl(h0), VList));
|
||||
}
|
||||
}
|
||||
|
||||
static Int
|
||||
p_array_references(void)
|
||||
p_array_references( USES_REGS1 )
|
||||
{
|
||||
Term t = replace_array_references(ARG1);
|
||||
Term t = replace_array_references(ARG1 PASS_REGS);
|
||||
Term t1 = HeadOfTerm(t);
|
||||
Term t2 = TailOfTerm(t);
|
||||
|
||||
@ -1567,7 +1555,7 @@ p_array_references(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_assign_static(void)
|
||||
p_assign_static( USES_REGS1 )
|
||||
{
|
||||
Term t1, t2, t3;
|
||||
StaticArrayEntry *ptr;
|
||||
@ -1899,7 +1887,7 @@ p_assign_static(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_assign_dynamic(void)
|
||||
p_assign_dynamic( USES_REGS1 )
|
||||
{
|
||||
Term t1, t2, t3;
|
||||
StaticArrayEntry *ptr;
|
||||
@ -2039,7 +2027,7 @@ p_assign_dynamic(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_add_to_array_element(void)
|
||||
p_add_to_array_element( USES_REGS1 )
|
||||
{
|
||||
Term t1, t2, t3;
|
||||
StaticArrayEntry *ptr;
|
||||
@ -2234,20 +2222,20 @@ p_add_to_array_element(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_compile_array_refs(void)
|
||||
p_compile_array_refs( USES_REGS1 )
|
||||
{
|
||||
compile_arrays = TRUE;
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_array_refs_compiled(void)
|
||||
p_array_refs_compiled( USES_REGS1 )
|
||||
{
|
||||
return compile_arrays;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_sync_mmapped_arrays(void)
|
||||
p_sync_mmapped_arrays( USES_REGS1 )
|
||||
{
|
||||
#ifdef HAVE_MMAP
|
||||
mmap_array_block *ptr = mmap_arrays;
|
||||
@ -2260,7 +2248,7 @@ p_sync_mmapped_arrays(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_static_array_to_term(void)
|
||||
p_static_array_to_term( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
|
||||
@ -2378,7 +2366,7 @@ p_static_array_to_term(void)
|
||||
/* The object is now in use */
|
||||
DBTerm *ref = pp->ValueOfVE.terms[indx];
|
||||
|
||||
Term TRef = GetTermFromArray(ref);
|
||||
Term TRef = GetTermFromArray(ref PASS_REGS);
|
||||
|
||||
if (P == FAILCODE) {
|
||||
return FALSE;
|
||||
@ -2394,7 +2382,7 @@ p_static_array_to_term(void)
|
||||
H += dim;
|
||||
for (indx=0; indx < dim; indx++) {
|
||||
/* The object is now in use */
|
||||
Term To = GetNBTerm(pp->ValueOfVE.lterms, indx);
|
||||
Term To = GetNBTerm(pp->ValueOfVE.lterms, indx PASS_REGS);
|
||||
|
||||
if (P == FAILCODE) {
|
||||
return FALSE;
|
||||
@ -2423,7 +2411,7 @@ p_static_array_to_term(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_static_array_location(void)
|
||||
p_static_array_location( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
Int *ptr;
|
||||
@ -2452,7 +2440,7 @@ p_static_array_location(void)
|
||||
}
|
||||
|
||||
void
|
||||
Yap_InitArrayPreds(void)
|
||||
Yap_InitArrayPreds( void )
|
||||
{
|
||||
Yap_InitCPred("$create_array", 2, p_create_array, SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$array_references", 3, p_array_references, SafePredFlag|HiddenPredFlag);
|
||||
|
130
C/attvar.c
130
C/attvar.c
@ -33,7 +33,7 @@ static char SccsId[]="%W% %G%";
|
||||
#define TermVoidAtt TermFoundVar
|
||||
|
||||
static CELL *
|
||||
AddToQueue(attvar_record *attv)
|
||||
AddToQueue(attvar_record *attv USES_REGS)
|
||||
{
|
||||
Term t[2];
|
||||
Term WGs, ng;
|
||||
@ -53,14 +53,14 @@ AddToQueue(attvar_record *attv)
|
||||
}
|
||||
|
||||
static void
|
||||
AddFailToQueue(void)
|
||||
AddFailToQueue( USES_REGS1 )
|
||||
{
|
||||
Term WGs;
|
||||
|
||||
/* follow the chain */
|
||||
WGs = Yap_ReadTimedVar(WokenGoals);
|
||||
|
||||
Yap_UpdateTimedVar(WokenGoals, MkPairTerm(MkAtomTerm(AtomFail),WGs));
|
||||
Yap_UpdateTimedVar(WokenGoals, MkPairTerm(MkAtomTerm(AtomFail), WGs));
|
||||
if ((Term)WGs == TermNil) {
|
||||
/* from now on, we have to start waking up goals */
|
||||
Yap_signal(YAP_WAKEUP_SIGNAL);
|
||||
@ -68,7 +68,7 @@ AddFailToQueue(void)
|
||||
}
|
||||
|
||||
static attvar_record *
|
||||
BuildNewAttVar(void)
|
||||
BuildNewAttVar( USES_REGS1 )
|
||||
{
|
||||
attvar_record *newv;
|
||||
|
||||
@ -83,14 +83,14 @@ BuildNewAttVar(void)
|
||||
}
|
||||
|
||||
static int
|
||||
CopyAttVar(CELL *orig, struct cp_frame **to_visit_ptr, CELL *res)
|
||||
CopyAttVar(CELL *orig, struct cp_frame **to_visit_ptr, CELL *res USES_REGS)
|
||||
{
|
||||
register attvar_record *attv = RepAttVar(orig);
|
||||
register attvar_record *newv;
|
||||
struct cp_frame *to_visit = *to_visit_ptr;
|
||||
CELL *vt;
|
||||
|
||||
if (!(newv = BuildNewAttVar()))
|
||||
if (!(newv = BuildNewAttVar( PASS_REGS1 )))
|
||||
return FALSE;
|
||||
vt = &(attv->Atts);
|
||||
to_visit->start_cp = vt-1;
|
||||
@ -118,9 +118,9 @@ AttVarToTerm(CELL *orig)
|
||||
}
|
||||
|
||||
static int
|
||||
TermToAttVar(Term attvar, Term to)
|
||||
TermToAttVar(Term attvar, Term to USES_REGS)
|
||||
{
|
||||
attvar_record *attv = BuildNewAttVar();
|
||||
attvar_record *attv = BuildNewAttVar( PASS_REGS1 );
|
||||
if (!attv)
|
||||
return FALSE;
|
||||
Bind(&attv->Atts, attvar);
|
||||
@ -129,7 +129,7 @@ TermToAttVar(Term attvar, Term to)
|
||||
}
|
||||
|
||||
static void
|
||||
WakeAttVar(CELL* pt1, CELL reg2)
|
||||
WakeAttVar(CELL* pt1, CELL reg2 USES_REGS)
|
||||
{
|
||||
|
||||
/* if bound to someone else, follow until we find the last one */
|
||||
@ -152,11 +152,11 @@ WakeAttVar(CELL* pt1, CELL reg2)
|
||||
if (!IsVarTerm(susp2->Value) || !IsUnboundVar(&susp2->Value)) {
|
||||
/* oops, our goal is on the queue to be woken */
|
||||
if (!Yap_unify(susp2->Value, (CELL)pt1)) {
|
||||
AddFailToQueue();
|
||||
AddFailToQueue( PASS_REGS1 );
|
||||
}
|
||||
}
|
||||
Bind_Global(&(susp2->Value), (CELL)pt1);
|
||||
AddToQueue(susp2);
|
||||
AddToQueue(susp2 PASS_REGS);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -167,11 +167,11 @@ WakeAttVar(CELL* pt1, CELL reg2)
|
||||
if (!IsVarTerm(attv->Value) || !IsUnboundVar(&attv->Value)) {
|
||||
/* oops, our goal is on the queue to be woken */
|
||||
if (!Yap_unify(attv->Value, reg2)) {
|
||||
AddFailToQueue();
|
||||
AddFailToQueue( PASS_REGS1 );
|
||||
}
|
||||
return;
|
||||
}
|
||||
bind_ptr = AddToQueue(attv);
|
||||
bind_ptr = AddToQueue(attv PASS_REGS);
|
||||
if (IsNonVarTerm(reg2)) {
|
||||
if (IsPairTerm(reg2) && RepPair(reg2) == myH)
|
||||
reg2 = AbsPair(H);
|
||||
@ -184,10 +184,11 @@ WakeAttVar(CELL* pt1, CELL reg2)
|
||||
|
||||
void
|
||||
Yap_WakeUp(CELL *pt0) {
|
||||
CACHE_REGS
|
||||
CELL d0 = *pt0;
|
||||
RESET_VARIABLE(pt0);
|
||||
TR--;
|
||||
WakeAttVar(pt0, d0);
|
||||
WakeAttVar(pt0, d0 PASS_REGS);
|
||||
}
|
||||
|
||||
|
||||
@ -198,7 +199,7 @@ mark_attvar(CELL *orig)
|
||||
}
|
||||
|
||||
static Term
|
||||
BuildAttTerm(Functor mfun, UInt ar)
|
||||
BuildAttTerm(Functor mfun, UInt ar USES_REGS)
|
||||
{
|
||||
CELL *h0 = H;
|
||||
UInt i;
|
||||
@ -240,7 +241,7 @@ SearchAttsForModuleName(Term start, Atom mname)
|
||||
}
|
||||
|
||||
static void
|
||||
AddNewModule(attvar_record *attv, Term t, int new, int do_it)
|
||||
AddNewModule(attvar_record *attv, Term t, int new, int do_it USES_REGS)
|
||||
{
|
||||
CELL *newp = RepAppl(t)+2;
|
||||
UInt i, ar = ArityOfFunctor((Functor)newp[-2]);
|
||||
@ -274,7 +275,7 @@ AddNewModule(attvar_record *attv, Term t, int new, int do_it)
|
||||
}
|
||||
|
||||
static void
|
||||
ReplaceAtts(attvar_record *attv, Term oatt, Term att)
|
||||
ReplaceAtts(attvar_record *attv, Term oatt, Term att USES_REGS)
|
||||
{
|
||||
UInt ar = ArityOfFunctor(FunctorOfTerm(oatt)), i;
|
||||
CELL *oldp = RepAppl(oatt)+1;
|
||||
@ -326,18 +327,18 @@ ReplaceAtts(attvar_record *attv, Term oatt, Term att)
|
||||
}
|
||||
|
||||
static void
|
||||
DelAllAtts(attvar_record *attv)
|
||||
DelAllAtts(attvar_record *attv USES_REGS)
|
||||
{
|
||||
MaBind(&(attv->Done), attv->Value);
|
||||
}
|
||||
|
||||
static void
|
||||
DelAtts(attvar_record *attv, Term oatt)
|
||||
DelAtts(attvar_record *attv, Term oatt USES_REGS)
|
||||
{
|
||||
Term t = ArgOfTerm(1,oatt);
|
||||
if (attv->Atts == oatt) {
|
||||
if (IsVarTerm(t)) {
|
||||
DelAllAtts(attv);
|
||||
DelAllAtts(attv PASS_REGS);
|
||||
return;
|
||||
}
|
||||
if (RepAppl(attv->Atts) >= HB)
|
||||
@ -359,7 +360,7 @@ DelAtts(attvar_record *attv, Term oatt)
|
||||
}
|
||||
|
||||
static void
|
||||
PutAtt(Int pos, Term atts, Term att)
|
||||
PutAtt(Int pos, Term atts, Term att USES_REGS)
|
||||
{
|
||||
if (IsVarTerm(att) && (CELL *)att > H && (CELL *)att < LCL0) {
|
||||
/* globalise locals */
|
||||
@ -371,7 +372,7 @@ PutAtt(Int pos, Term atts, Term att)
|
||||
}
|
||||
|
||||
static Int
|
||||
BindAttVar(attvar_record *attv) {
|
||||
BindAttVar(attvar_record *attv USES_REGS) {
|
||||
if (IsVarTerm(attv->Done) && IsUnboundVar(&attv->Done)) {
|
||||
/* make sure we are not trying to bind a variable against itself */
|
||||
if (!IsVarTerm(attv->Value)) {
|
||||
@ -414,7 +415,7 @@ GetAllAtts(attvar_record *attv) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_put_att(void) {
|
||||
p_put_att( USES_REGS1 ) {
|
||||
/* receive a variable in ARG1 */
|
||||
Term inp = Deref(ARG1);
|
||||
/* if this is unbound, ok */
|
||||
@ -429,7 +430,7 @@ p_put_att(void) {
|
||||
if (IsAttachedTerm(inp)) {
|
||||
attv = RepAttVar(VarOfTerm(inp));
|
||||
} else {
|
||||
while (!(attv = BuildNewAttVar())) {
|
||||
while (!(attv = BuildNewAttVar( PASS_REGS1 ))) {
|
||||
Yap_Error_Size = sizeof(attvar_record);
|
||||
if (!Yap_gcl(Yap_Error_Size, 5, ENV, gc_P(P,CP))) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
@ -441,16 +442,16 @@ p_put_att(void) {
|
||||
}
|
||||
mfun= Yap_MkFunctor(modname,ar);
|
||||
if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts,mfun))) {
|
||||
while (!(tatts = BuildAttTerm(mfun,ar))) {
|
||||
while (!(tatts = BuildAttTerm(mfun,ar PASS_REGS))) {
|
||||
if (!Yap_gcl(Yap_Error_Size, 5, ENV, gc_P(P,CP))) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
Yap_unify(ARG1, AbsAttVar(attv));
|
||||
AddNewModule(attv,tatts,new,TRUE);
|
||||
AddNewModule(attv, tatts, new, TRUE PASS_REGS);
|
||||
}
|
||||
PutAtt(IntegerOfTerm(Deref(ARG4)), tatts, Deref(ARG5));
|
||||
PutAtt(IntegerOfTerm(Deref(ARG4)), tatts, Deref(ARG5) PASS_REGS);
|
||||
return TRUE;
|
||||
} else {
|
||||
Yap_Error(REPRESENTATION_ERROR_VARIABLE,inp,"first argument of put_attributes/2");
|
||||
@ -459,7 +460,7 @@ p_put_att(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_put_att_term(void) {
|
||||
p_put_att_term( USES_REGS1 ) {
|
||||
/* receive a variable in ARG1 */
|
||||
Term inp = Deref(ARG1);
|
||||
/* if this is unbound, ok */
|
||||
@ -470,7 +471,7 @@ p_put_att_term(void) {
|
||||
if (IsAttachedTerm(inp)) {
|
||||
attv = RepAttVar(VarOfTerm(inp));
|
||||
} else {
|
||||
while (!(attv = BuildNewAttVar())) {
|
||||
while (!(attv = BuildNewAttVar( PASS_REGS1 ))) {
|
||||
Yap_Error_Size = sizeof(attvar_record);
|
||||
if (!Yap_gcl(Yap_Error_Size, 5, ENV, gc_P(P,CP))) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
@ -494,7 +495,7 @@ p_put_att_term(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_rm_att(void) {
|
||||
p_rm_att( USES_REGS1 ) {
|
||||
/* receive a variable in ARG1 */
|
||||
Term inp = Deref(ARG1);
|
||||
/* if this is unbound, ok */
|
||||
@ -509,7 +510,7 @@ p_rm_att(void) {
|
||||
if (IsAttachedTerm(inp)) {
|
||||
attv = RepAttVar(VarOfTerm(inp));
|
||||
} else {
|
||||
while (!(attv = BuildNewAttVar())) {
|
||||
while (!(attv = BuildNewAttVar( PASS_REGS1 ))) {
|
||||
Yap_Error_Size = sizeof(attvar_record);
|
||||
if (!Yap_gcl(Yap_Error_Size, 5, ENV, gc_P(P,CP))) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
@ -522,15 +523,15 @@ p_rm_att(void) {
|
||||
}
|
||||
mfun= Yap_MkFunctor(modname,ar);
|
||||
if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts,mfun))) {
|
||||
while (!(tatts = BuildAttTerm(mfun,ar))) {
|
||||
while (!(tatts = BuildAttTerm(mfun, ar PASS_REGS))) {
|
||||
if (!Yap_gcl(Yap_Error_Size, 4, ENV, gc_P(P,CP))) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
AddNewModule(attv,tatts,new, FALSE);
|
||||
AddNewModule(attv,tatts,new, FALSE PASS_REGS);
|
||||
} else {
|
||||
PutAtt(IntegerOfTerm(Deref(ARG4)), tatts, TermVoidAtt);
|
||||
PutAtt(IntegerOfTerm(Deref(ARG4)), tatts, TermVoidAtt PASS_REGS);
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
@ -540,7 +541,7 @@ p_rm_att(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_put_atts(void) {
|
||||
p_put_atts( USES_REGS1 ) {
|
||||
/* receive a variable in ARG1 */
|
||||
Term inp = Deref(ARG1);
|
||||
|
||||
@ -556,7 +557,7 @@ p_put_atts(void) {
|
||||
if (IsAttachedTerm(inp)) {
|
||||
attv = RepAttVar(VarOfTerm(inp));
|
||||
} else {
|
||||
while (!(attv = BuildNewAttVar())) {
|
||||
while (!(attv = BuildNewAttVar( PASS_REGS1 ))) {
|
||||
Yap_Error_Size = sizeof(attvar_record);
|
||||
if (!Yap_gcl(Yap_Error_Size, 2, ENV, gc_P(P,CP))) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
@ -577,9 +578,9 @@ p_put_atts(void) {
|
||||
return FALSE;
|
||||
}
|
||||
if (IsVarTerm(otatts = SearchAttsForModule(attv->Atts,mfun))) {
|
||||
AddNewModule(attv,tatts,new,FALSE);
|
||||
AddNewModule(attv, tatts, new, FALSE PASS_REGS);
|
||||
} else {
|
||||
ReplaceAtts(attv, otatts, tatts);
|
||||
ReplaceAtts(attv, otatts, tatts PASS_REGS);
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
@ -589,7 +590,7 @@ p_put_atts(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_del_atts(void) {
|
||||
p_del_atts( USES_REGS1 ) {
|
||||
/* receive a variable in ARG1 */
|
||||
Term inp = Deref(ARG1);
|
||||
Term otatts;
|
||||
@ -608,7 +609,7 @@ p_del_atts(void) {
|
||||
if (IsVarTerm(otatts = SearchAttsForModule(attv->Atts,mfun))) {
|
||||
return TRUE;
|
||||
} else {
|
||||
DelAtts(attv, otatts);
|
||||
DelAtts(attv, otatts PASS_REGS);
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
@ -617,7 +618,7 @@ p_del_atts(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_del_all_atts(void) {
|
||||
p_del_all_atts( USES_REGS1 ) {
|
||||
/* receive a variable in ARG1 */
|
||||
Term inp = Deref(ARG1);
|
||||
|
||||
@ -626,13 +627,13 @@ p_del_all_atts(void) {
|
||||
attvar_record *attv;
|
||||
|
||||
attv = RepAttVar(VarOfTerm(inp));
|
||||
DelAllAtts(attv);
|
||||
DelAllAtts(attv PASS_REGS);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_get_att(void) {
|
||||
p_get_att( USES_REGS1 ) {
|
||||
/* receive a variable in ARG1 */
|
||||
Term inp = Deref(ARG1);
|
||||
/* if this is unbound, ok */
|
||||
@ -660,7 +661,7 @@ p_get_att(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_free_att(void) {
|
||||
p_free_att( USES_REGS1 ) {
|
||||
/* receive a variable in ARG1 */
|
||||
Term inp = Deref(ARG1);
|
||||
/* if this is unbound, ok */
|
||||
@ -687,7 +688,7 @@ p_free_att(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_get_atts(void) {
|
||||
p_get_atts( USES_REGS1 ) {
|
||||
/* receive a variable in ARG1 */
|
||||
Term inp = Deref(ARG1);
|
||||
/* if this is unbound, ok */
|
||||
@ -727,7 +728,7 @@ p_get_atts(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_has_atts(void) {
|
||||
p_has_atts( USES_REGS1 ) {
|
||||
/* receive a variable in ARG1 */
|
||||
Term inp = Deref(ARG1);
|
||||
/* if this is unbound, ok */
|
||||
@ -751,14 +752,14 @@ p_has_atts(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_bind_attvar(void) {
|
||||
p_bind_attvar( USES_REGS1 ) {
|
||||
/* receive a variable in ARG1 */
|
||||
Term inp = Deref(ARG1);
|
||||
/* if this is unbound, ok */
|
||||
if (IsVarTerm(inp)) {
|
||||
if (IsAttachedTerm(inp)) {
|
||||
attvar_record *attv = RepAttVar(VarOfTerm(inp));
|
||||
return(BindAttVar(attv));
|
||||
return(BindAttVar(attv PASS_REGS));
|
||||
}
|
||||
return(TRUE);
|
||||
} else {
|
||||
@ -768,7 +769,7 @@ p_bind_attvar(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_unbind_attvar(void) {
|
||||
p_unbind_attvar( USES_REGS1 ) {
|
||||
/* receive a variable in ARG1 */
|
||||
Term inp = Deref(ARG1);
|
||||
/* if this is unbound, ok */
|
||||
@ -785,7 +786,7 @@ p_unbind_attvar(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_get_all_atts(void) {
|
||||
p_get_all_atts( USES_REGS1 ) {
|
||||
/* receive a variable in ARG1 */
|
||||
Term inp = Deref(ARG1);
|
||||
/* if this is unbound, ok */
|
||||
@ -815,7 +816,7 @@ ActiveAtt(Term tatt, UInt ar)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_modules_with_atts(void) {
|
||||
p_modules_with_atts( USES_REGS1 ) {
|
||||
/* receive a variable in ARG1 */
|
||||
Term inp = Deref(ARG1);
|
||||
/* if this is unbound, ok */
|
||||
@ -850,7 +851,7 @@ p_modules_with_atts(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_swi_all_atts(void) {
|
||||
p_swi_all_atts( USES_REGS1 ) {
|
||||
/* receive a variable in ARG1 */
|
||||
Term inp = Deref(ARG1);
|
||||
Functor attf = FunctorAtt1;
|
||||
@ -895,7 +896,7 @@ p_swi_all_atts(void) {
|
||||
|
||||
|
||||
static Term
|
||||
AllAttVars(void) {
|
||||
AllAttVars( USES_REGS1 ) {
|
||||
CELL *pt = H0;
|
||||
CELL *myH = H;
|
||||
|
||||
@ -948,12 +949,12 @@ AllAttVars(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_all_attvars(void)
|
||||
p_all_attvars( USES_REGS1 )
|
||||
{
|
||||
do {
|
||||
Term out;
|
||||
|
||||
if (!(out = AllAttVars())) {
|
||||
if (!(out = AllAttVars( PASS_REGS1 ))) {
|
||||
if (!Yap_gcl(Yap_Error_Size, 1, ENV, gc_P(P,CP))) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
@ -965,7 +966,7 @@ p_all_attvars(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_is_attvar(void)
|
||||
p_is_attvar( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
return(IsVarTerm(t) &&
|
||||
@ -974,7 +975,7 @@ p_is_attvar(void)
|
||||
|
||||
/* check if we are not redoing effort */
|
||||
static Int
|
||||
p_attvar_bound(void)
|
||||
p_attvar_bound( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
return
|
||||
@ -984,19 +985,19 @@ p_attvar_bound(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_void_term(void)
|
||||
p_void_term( USES_REGS1 )
|
||||
{
|
||||
return Yap_unify(ARG1,TermVoidAtt);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_free_term(void)
|
||||
p_free_term( USES_REGS1 )
|
||||
{
|
||||
return Yap_unify(ARG1,TermFreeTerm);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_fast_unify(void)
|
||||
p_fast_unify( USES_REGS1 )
|
||||
{
|
||||
/*
|
||||
Case we want to unify two variables, but we do not
|
||||
@ -1021,27 +1022,28 @@ p_fast_unify(void)
|
||||
#else
|
||||
|
||||
static Int
|
||||
p_all_attvars(void)
|
||||
p_all_attvars( USES_REGS1 )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_is_attvar(void)
|
||||
p_is_attvar( USES_REGS1 )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_attvar_bound(void)
|
||||
p_attvar_bound( USES_REGS1 )
|
||||
{
|
||||
b return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif /* COROUTINING */
|
||||
|
||||
void Yap_InitAttVarPreds(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term OldCurrentModule = CurrentModule;
|
||||
CurrentModule = ATTRIBUTES_MODULE;
|
||||
#ifdef COROUTINING
|
||||
|
31
C/bb.c
31
C/bb.c
@ -25,7 +25,7 @@ static char SccsId[] = "%W% %G%";
|
||||
#endif
|
||||
|
||||
static BBProp
|
||||
PutBBProp(AtomEntry *ae, Term mod) /* get BBentry for at; */
|
||||
PutBBProp(AtomEntry *ae, Term mod USES_REGS) /* get BBentry for at; */
|
||||
{
|
||||
Prop p0;
|
||||
BBProp p;
|
||||
@ -56,7 +56,7 @@ PutBBProp(AtomEntry *ae, Term mod) /* get BBentry for at; */
|
||||
}
|
||||
|
||||
static BBProp
|
||||
PutIntBBProp(Int key, Term mod) /* get BBentry for at; */
|
||||
PutIntBBProp(Int key, Term mod USES_REGS) /* get BBentry for at; */
|
||||
{
|
||||
Prop p0;
|
||||
BBProp p;
|
||||
@ -147,6 +147,7 @@ GetIntBBProp(Int key, Term mod) /* get BBentry for at; */
|
||||
|
||||
static int
|
||||
resize_bb_int_keys(UInt new_size) {
|
||||
CACHE_REGS
|
||||
Prop *new;
|
||||
UInt i;
|
||||
|
||||
@ -186,7 +187,7 @@ resize_bb_int_keys(UInt new_size) {
|
||||
}
|
||||
|
||||
static BBProp
|
||||
AddBBProp(Term t1, char *msg, Term mod)
|
||||
AddBBProp(Term t1, char *msg, Term mod USES_REGS)
|
||||
{
|
||||
BBProp p;
|
||||
|
||||
@ -195,9 +196,9 @@ AddBBProp(Term t1, char *msg, Term mod)
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, msg);
|
||||
return(NULL);
|
||||
} if (IsAtomTerm(t1)) {
|
||||
p = PutBBProp(RepAtom(AtomOfTerm(t1)), mod);
|
||||
p = PutBBProp(RepAtom(AtomOfTerm(t1)), mod PASS_REGS);
|
||||
} else if (IsIntegerTerm(t1)) {
|
||||
p = PutIntBBProp(IntegerOfTerm(t1), mod);
|
||||
p = PutIntBBProp(IntegerOfTerm(t1), mod PASS_REGS);
|
||||
} else if (IsApplTerm(t1) && FunctorOfTerm(t1) == FunctorModule) {
|
||||
Term tmod = ArgOfTerm(1, t1);
|
||||
if (!IsVarTerm(tmod) ) {
|
||||
@ -264,10 +265,10 @@ BBPut(Term t0, Term t2)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_bb_put(void)
|
||||
p_bb_put( USES_REGS1 )
|
||||
{
|
||||
Term t1 = Deref(ARG1);
|
||||
BBProp p = AddBBProp(t1, "bb_put/2", CurrentModule);
|
||||
BBProp p = AddBBProp(t1, "bb_put/2", CurrentModule PASS_REGS);
|
||||
|
||||
if (p == NULL) {
|
||||
return(FALSE);
|
||||
@ -283,7 +284,7 @@ p_bb_put(void)
|
||||
}
|
||||
|
||||
static Term
|
||||
BBGet(Term t, UInt arity)
|
||||
BBGet(Term t, UInt arity USES_REGS)
|
||||
{
|
||||
if (IsVarTerm(t)) {
|
||||
return MkVarTerm();
|
||||
@ -295,7 +296,7 @@ BBGet(Term t, UInt arity)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_bb_get(void)
|
||||
p_bb_get( USES_REGS1 )
|
||||
{
|
||||
Term t1 = Deref(ARG1);
|
||||
BBProp p = FetchBBProp(t1, "bb_get/2", CurrentModule);
|
||||
@ -309,12 +310,12 @@ p_bb_get(void)
|
||||
*/
|
||||
t0 = p->Element;
|
||||
READ_UNLOCK(p->BBRWLock);
|
||||
out = BBGet(t0, 2);
|
||||
out = BBGet(t0, 2 PASS_REGS);
|
||||
return Yap_unify(ARG2,out);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_bb_delete(void)
|
||||
p_bb_delete( USES_REGS1 )
|
||||
{
|
||||
Term t1 = Deref(ARG1);
|
||||
BBProp p;
|
||||
@ -324,7 +325,7 @@ p_bb_delete(void)
|
||||
if (p == NULL || p->Element == 0L)
|
||||
return(FALSE);
|
||||
WRITE_LOCK(p->BBRWLock);
|
||||
out = BBGet(p->Element,2);
|
||||
out = BBGet(p->Element, 2 PASS_REGS);
|
||||
if (!IsVarTerm(p->Element) && IsApplTerm(p->Element)) {
|
||||
Yap_ErLogUpdCl((LogUpdClause *)DBRefOfTerm(p->Element));
|
||||
}
|
||||
@ -334,7 +335,7 @@ p_bb_delete(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_bb_update(void)
|
||||
p_bb_update( USES_REGS1 )
|
||||
{
|
||||
Term t1 = Deref(ARG1);
|
||||
BBProp p;
|
||||
@ -344,7 +345,7 @@ p_bb_update(void)
|
||||
if (p == NULL || p->Element == 0L)
|
||||
return FALSE;
|
||||
WRITE_LOCK(p->BBRWLock);
|
||||
out = BBGet(p->Element, 3);
|
||||
out = BBGet(p->Element, 3 PASS_REGS);
|
||||
if (!Yap_unify(out,ARG2)) {
|
||||
WRITE_UNLOCK(p->BBRWLock);
|
||||
return FALSE;
|
||||
@ -355,7 +356,7 @@ p_bb_update(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_resize_bb_int_keys(void)
|
||||
p_resize_bb_int_keys( USES_REGS1 )
|
||||
{
|
||||
Term t1 = Deref(ARG1);
|
||||
if (IsVarTerm(t1)) {
|
||||
|
12
C/bignum.c
12
C/bignum.c
@ -34,6 +34,7 @@ static char SccsId[] = "%W% %G%";
|
||||
Term
|
||||
Yap_MkBigIntTerm(MP_INT *big)
|
||||
{
|
||||
CACHE_REGS
|
||||
Int nlimbs;
|
||||
MP_INT *dst = (MP_INT *)(H+2);
|
||||
CELL *ret = H;
|
||||
@ -70,6 +71,7 @@ Yap_BigIntOfTerm(Term t)
|
||||
Term
|
||||
Yap_MkBigRatTerm(MP_RAT *big)
|
||||
{
|
||||
CACHE_REGS
|
||||
Int nlimbs;
|
||||
MP_INT *dst = (MP_INT *)(H+2);
|
||||
MP_INT *num = mpq_numref(big);
|
||||
@ -157,7 +159,7 @@ Yap_MkULLIntTerm(YAP_ULONG_LONG n)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_is_bignum(void)
|
||||
p_is_bignum( USES_REGS1 )
|
||||
{
|
||||
#ifdef USE_GMP
|
||||
Term t = Deref(ARG1);
|
||||
@ -173,7 +175,7 @@ p_is_bignum(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_has_bignums(void)
|
||||
p_has_bignums( USES_REGS1 )
|
||||
{
|
||||
#ifdef USE_GMP
|
||||
return TRUE;
|
||||
@ -183,7 +185,7 @@ p_has_bignums(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_is_rational(void)
|
||||
p_is_rational( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
if (IsVarTerm(t))
|
||||
@ -205,7 +207,7 @@ p_is_rational(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_rational(void)
|
||||
p_rational( USES_REGS1 )
|
||||
{
|
||||
#ifdef USE_GMP
|
||||
Term t = Deref(ARG1);
|
||||
@ -246,6 +248,7 @@ p_rational(void)
|
||||
Term
|
||||
Yap_MkBlobStringTerm(const char *s, size_t len)
|
||||
{
|
||||
CACHE_REGS
|
||||
CELL *ret = H;
|
||||
size_t sz;
|
||||
MP_INT *dst = (MP_INT *)(H+2);
|
||||
@ -275,6 +278,7 @@ Yap_MkBlobStringTerm(const char *s, size_t len)
|
||||
Term
|
||||
Yap_MkBlobWideStringTerm(const wchar_t *s, size_t len)
|
||||
{
|
||||
CACHE_REGS
|
||||
CELL *ret = H;
|
||||
size_t sz;
|
||||
MP_INT *dst = (MP_INT *)(H+2);
|
||||
|
348
C/c_interface.c
348
C/c_interface.c
@ -545,6 +545,7 @@ static int do_yap_putc(int streamno,wchar_t ch) {
|
||||
static int
|
||||
dogc(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
UInt arity;
|
||||
|
||||
if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) {
|
||||
@ -561,6 +562,7 @@ dogc(void)
|
||||
static int
|
||||
doexpand(UInt sz)
|
||||
{
|
||||
CACHE_REGS
|
||||
UInt arity;
|
||||
|
||||
if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) {
|
||||
@ -577,6 +579,7 @@ doexpand(UInt sz)
|
||||
X_API Term
|
||||
YAP_A(int i)
|
||||
{
|
||||
CACHE_REGS
|
||||
return(Deref(XREGS[i]));
|
||||
}
|
||||
|
||||
@ -751,6 +754,7 @@ YAP_RationalOfTerm(Term t, void *b)
|
||||
X_API Term
|
||||
YAP_MkBlobTerm(unsigned int sz)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term I;
|
||||
MP_INT *dst;
|
||||
BACKUP_H();
|
||||
@ -846,6 +850,7 @@ YAP_WideAtomName(Atom a)
|
||||
X_API Atom
|
||||
YAP_LookupAtom(char *c)
|
||||
{
|
||||
CACHE_REGS
|
||||
Atom a;
|
||||
|
||||
while (TRUE) {
|
||||
@ -863,6 +868,7 @@ YAP_LookupAtom(char *c)
|
||||
X_API Atom
|
||||
YAP_LookupWideAtom(wchar_t *c)
|
||||
{
|
||||
CACHE_REGS
|
||||
Atom a;
|
||||
|
||||
while (TRUE) {
|
||||
@ -880,6 +886,7 @@ YAP_LookupWideAtom(wchar_t *c)
|
||||
X_API Atom
|
||||
YAP_FullLookupAtom(char *c)
|
||||
{
|
||||
CACHE_REGS
|
||||
Atom at;
|
||||
|
||||
while (TRUE) {
|
||||
@ -914,6 +921,7 @@ YAP_AtomNameLength(Atom at)
|
||||
X_API Term
|
||||
YAP_MkVarTerm(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
CELL t;
|
||||
BACKUP_H();
|
||||
|
||||
@ -926,19 +934,20 @@ YAP_MkVarTerm(void)
|
||||
X_API Term
|
||||
YAP_MkPairTerm(Term t1, Term t2)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t;
|
||||
BACKUP_H();
|
||||
|
||||
if (H > ASP-1024) {
|
||||
Int sl1 = Yap_InitSlot(t1);
|
||||
Int sl2 = Yap_InitSlot(t2);
|
||||
Int sl1 = Yap_InitSlot(t1 PASS_REGS);
|
||||
Int sl2 = Yap_InitSlot(t2 PASS_REGS);
|
||||
if (!dogc()) {
|
||||
RECOVER_H();
|
||||
return TermNil;
|
||||
}
|
||||
t1 = Yap_GetFromSlot(sl1);
|
||||
t2 = Yap_GetFromSlot(sl2);
|
||||
Yap_RecoverSlots(2);
|
||||
t1 = Yap_GetFromSlot(sl1 PASS_REGS);
|
||||
t2 = Yap_GetFromSlot(sl2 PASS_REGS);
|
||||
Yap_RecoverSlots(2 PASS_REGS);
|
||||
}
|
||||
t = MkPairTerm(t1, t2);
|
||||
RECOVER_H();
|
||||
@ -948,6 +957,7 @@ YAP_MkPairTerm(Term t1, Term t2)
|
||||
X_API Term
|
||||
YAP_MkNewPairTerm()
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t;
|
||||
BACKUP_H();
|
||||
|
||||
@ -1003,6 +1013,7 @@ YAP_SkipList(Term *l, Term **tailp)
|
||||
X_API Term
|
||||
YAP_MkApplTerm(Functor f,UInt arity, Term args[])
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t;
|
||||
BACKUP_H();
|
||||
|
||||
@ -1018,6 +1029,7 @@ YAP_MkApplTerm(Functor f,UInt arity, Term args[])
|
||||
X_API Term
|
||||
YAP_MkNewApplTerm(Functor f,UInt arity)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t;
|
||||
BACKUP_H();
|
||||
|
||||
@ -1075,6 +1087,7 @@ YAP_ArityOfFunctor(Functor f)
|
||||
X_API void *
|
||||
YAP_ExtraSpaceCut(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
void *ptr;
|
||||
BACKUP_B();
|
||||
|
||||
@ -1088,6 +1101,7 @@ YAP_ExtraSpaceCut(void)
|
||||
X_API void *
|
||||
YAP_ExtraSpace(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
void *ptr;
|
||||
BACKUP_B();
|
||||
BACKUP_H();
|
||||
@ -1104,6 +1118,7 @@ YAP_ExtraSpace(void)
|
||||
X_API void
|
||||
YAP_cut_up(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
BACKUP_B();
|
||||
#ifdef CUT_C
|
||||
{
|
||||
@ -1189,43 +1204,50 @@ YAP_TermHash(Term t, Int sz, Int depth, int variant)
|
||||
X_API Int
|
||||
YAP_CurrentSlot(void)
|
||||
{
|
||||
return Yap_CurrentSlot();
|
||||
CACHE_REGS
|
||||
return Yap_CurrentSlot( PASS_REGS1 );
|
||||
}
|
||||
|
||||
X_API Int
|
||||
YAP_NewSlots(int n)
|
||||
{
|
||||
return Yap_NewSlots(n);
|
||||
CACHE_REGS
|
||||
return Yap_NewSlots(n PASS_REGS);
|
||||
}
|
||||
|
||||
X_API Int
|
||||
YAP_InitSlot(Term t)
|
||||
{
|
||||
return Yap_InitSlot(t);
|
||||
CACHE_REGS
|
||||
return Yap_InitSlot(t PASS_REGS);
|
||||
}
|
||||
|
||||
X_API int
|
||||
YAP_RecoverSlots(int n)
|
||||
{
|
||||
return Yap_RecoverSlots(n);
|
||||
CACHE_REGS
|
||||
return Yap_RecoverSlots(n PASS_REGS);
|
||||
}
|
||||
|
||||
X_API Term
|
||||
YAP_GetFromSlot(Int slot)
|
||||
{
|
||||
return Yap_GetFromSlot(slot);
|
||||
CACHE_REGS
|
||||
return Yap_GetFromSlot(slot PASS_REGS);
|
||||
}
|
||||
|
||||
X_API Term *
|
||||
YAP_AddressFromSlot(Int slot)
|
||||
{
|
||||
return Yap_AddressFromSlot(slot);
|
||||
CACHE_REGS
|
||||
return Yap_AddressFromSlot(slot PASS_REGS);
|
||||
}
|
||||
|
||||
X_API Term *
|
||||
YAP_AddressOfTermInSlot(Int slot)
|
||||
{
|
||||
Term *b = Yap_AddressFromSlot(slot);
|
||||
CACHE_REGS
|
||||
Term *b = Yap_AddressFromSlot(slot PASS_REGS);
|
||||
Term a = *b;
|
||||
restart:
|
||||
if (!IsVarTerm(a)) {
|
||||
@ -1242,7 +1264,8 @@ YAP_AddressOfTermInSlot(Int slot)
|
||||
X_API void
|
||||
YAP_PutInSlot(Int slot, Term t)
|
||||
{
|
||||
Yap_PutInSlot(slot, t);
|
||||
CACHE_REGS
|
||||
Yap_PutInSlot(slot, t PASS_REGS);
|
||||
}
|
||||
|
||||
|
||||
@ -1258,6 +1281,7 @@ typedef struct foreign_context
|
||||
struct PL_local_data *engine; /* invoking engine */
|
||||
} scontext ;
|
||||
|
||||
typedef Int (*CPredicate0)(void);
|
||||
typedef Int (*CPredicate1)(Int);
|
||||
typedef Int (*CPredicate2)(Int,Int);
|
||||
typedef Int (*CPredicate3)(Int,Int,Int);
|
||||
@ -1271,108 +1295,108 @@ typedef Int (*CPredicate10)(Int,Int,Int,Int,Int,Int,Int,Int,Int,Int);
|
||||
typedef Int (*CPredicateV)(Int,Int,struct foreign_context *);
|
||||
|
||||
static Int
|
||||
execute_cargs(PredEntry *pe, CPredicate exec_code)
|
||||
execute_cargs(PredEntry *pe, CPredicate exec_code USES_REGS)
|
||||
{
|
||||
switch (pe->ArityOfPE) {
|
||||
case 0:
|
||||
{
|
||||
CPredicate code0 = exec_code;
|
||||
CPredicate0 code0 = (CPredicate0)exec_code;
|
||||
return ((code0)());
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
CPredicate1 code1 = (CPredicate1)exec_code;
|
||||
return ((code1)(Yap_InitSlot(Deref(ARG1))));
|
||||
return ((code1)(Yap_InitSlot(Deref(ARG1) PASS_REGS)));
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
CPredicate2 code2 = (CPredicate2)exec_code;
|
||||
return ((code2)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2))));
|
||||
return ((code2)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS)));
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
CPredicate3 code3 = (CPredicate3)exec_code;
|
||||
return ((code3)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
Yap_InitSlot(Deref(ARG3))));
|
||||
return ((code3)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG3) PASS_REGS)));
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
CPredicate4 code4 = (CPredicate4)exec_code;
|
||||
return ((code4)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
Yap_InitSlot(Deref(ARG3)),
|
||||
Yap_InitSlot(Deref(ARG4))));
|
||||
return ((code4)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG4) PASS_REGS)));
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
CPredicate5 code5 = (CPredicate5)exec_code;
|
||||
return ((code5)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
Yap_InitSlot(Deref(ARG3)),
|
||||
Yap_InitSlot(Deref(ARG4)),
|
||||
Yap_InitSlot(Deref(ARG5))));
|
||||
return ((code5)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG5) PASS_REGS)));
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
CPredicate6 code6 = (CPredicate6)exec_code;
|
||||
return ((code6)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
Yap_InitSlot(Deref(ARG3)),
|
||||
Yap_InitSlot(Deref(ARG4)),
|
||||
Yap_InitSlot(Deref(ARG5)),
|
||||
Yap_InitSlot(Deref(ARG6))));
|
||||
return ((code6)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG6) PASS_REGS)));
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
CPredicate7 code7 = (CPredicate7)exec_code;
|
||||
return ((code7)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
Yap_InitSlot(Deref(ARG3)),
|
||||
Yap_InitSlot(Deref(ARG4)),
|
||||
Yap_InitSlot(Deref(ARG5)),
|
||||
Yap_InitSlot(Deref(ARG6)),
|
||||
Yap_InitSlot(Deref(ARG7))));
|
||||
return ((code7)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG7) PASS_REGS)));
|
||||
}
|
||||
case 8:
|
||||
{
|
||||
CPredicate8 code8 = (CPredicate8)exec_code;
|
||||
return ((code8)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
Yap_InitSlot(Deref(ARG3)),
|
||||
Yap_InitSlot(Deref(ARG4)),
|
||||
Yap_InitSlot(Deref(ARG5)),
|
||||
Yap_InitSlot(Deref(ARG6)),
|
||||
Yap_InitSlot(Deref(ARG7)),
|
||||
Yap_InitSlot(Deref(ARG8))));
|
||||
return ((code8)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG7) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG8) PASS_REGS)));
|
||||
}
|
||||
case 9:
|
||||
{
|
||||
CPredicate9 code9 = (CPredicate9)exec_code;
|
||||
return ((code9)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
Yap_InitSlot(Deref(ARG3)),
|
||||
Yap_InitSlot(Deref(ARG4)),
|
||||
Yap_InitSlot(Deref(ARG5)),
|
||||
Yap_InitSlot(Deref(ARG6)),
|
||||
Yap_InitSlot(Deref(ARG7)),
|
||||
Yap_InitSlot(Deref(ARG8)),
|
||||
Yap_InitSlot(Deref(ARG9))));
|
||||
return ((code9)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG7) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG8) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG9) PASS_REGS)));
|
||||
}
|
||||
case 10:
|
||||
{
|
||||
CPredicate10 code10 = (CPredicate10)exec_code;
|
||||
return ((code10)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
Yap_InitSlot(Deref(ARG3)),
|
||||
Yap_InitSlot(Deref(ARG4)),
|
||||
Yap_InitSlot(Deref(ARG5)),
|
||||
Yap_InitSlot(Deref(ARG6)),
|
||||
Yap_InitSlot(Deref(ARG7)),
|
||||
Yap_InitSlot(Deref(ARG8)),
|
||||
Yap_InitSlot(Deref(ARG9)),
|
||||
Yap_InitSlot(Deref(ARG10))));
|
||||
return ((code10)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG7) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG8) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG9) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG10) PASS_REGS)));
|
||||
}
|
||||
default:
|
||||
return(FALSE);
|
||||
@ -1392,7 +1416,7 @@ typedef Int (*CBPredicate9)(Int,Int,Int,Int,Int,Int,Int,Int,Int,struct foreign_c
|
||||
typedef Int (*CBPredicate10)(Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,struct foreign_context *);
|
||||
|
||||
static Int
|
||||
execute_cargs_back(PredEntry *pe, CPredicate exec_code, struct foreign_context *ctx)
|
||||
execute_cargs_back(PredEntry *pe, CPredicate exec_code, struct foreign_context *ctx USES_REGS)
|
||||
{
|
||||
switch (pe->ArityOfPE) {
|
||||
case 0:
|
||||
@ -1403,105 +1427,105 @@ execute_cargs_back(PredEntry *pe, CPredicate exec_code, struct foreign_context *
|
||||
case 1:
|
||||
{
|
||||
CBPredicate1 code1 = (CBPredicate1)exec_code;
|
||||
return ((code1)(Yap_InitSlot(Deref(ARG1)),
|
||||
return ((code1)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
ctx));
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
CBPredicate2 code2 = (CBPredicate2)exec_code;
|
||||
return ((code2)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
return ((code2)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
ctx));
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
CBPredicate3 code3 = (CBPredicate3)exec_code;
|
||||
return ((code3)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
Yap_InitSlot(Deref(ARG3)),
|
||||
return ((code3)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||
ctx));
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
CBPredicate4 code4 = (CBPredicate4)exec_code;
|
||||
return ((code4)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
Yap_InitSlot(Deref(ARG3)),
|
||||
Yap_InitSlot(Deref(ARG4)),
|
||||
return ((code4)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||
ctx));
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
CBPredicate5 code5 = (CBPredicate5)exec_code;
|
||||
return ((code5)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
Yap_InitSlot(Deref(ARG3)),
|
||||
Yap_InitSlot(Deref(ARG4)),
|
||||
Yap_InitSlot(Deref(ARG5)), ctx));
|
||||
return ((code5)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG5) PASS_REGS), ctx));
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
CBPredicate6 code6 = (CBPredicate6)exec_code;
|
||||
return ((code6)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
Yap_InitSlot(Deref(ARG3)),
|
||||
Yap_InitSlot(Deref(ARG4)),
|
||||
Yap_InitSlot(Deref(ARG5)),
|
||||
Yap_InitSlot(Deref(ARG6)),
|
||||
return ((code6)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||
ctx));
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
CBPredicate7 code7 = (CBPredicate7)exec_code;
|
||||
return ((code7)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
Yap_InitSlot(Deref(ARG3)),
|
||||
Yap_InitSlot(Deref(ARG4)),
|
||||
Yap_InitSlot(Deref(ARG5)),
|
||||
Yap_InitSlot(Deref(ARG6)),
|
||||
Yap_InitSlot(Deref(ARG7)),
|
||||
return ((code7)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG7) PASS_REGS),
|
||||
ctx));
|
||||
}
|
||||
case 8:
|
||||
{
|
||||
CBPredicate8 code8 = (CBPredicate8)exec_code;
|
||||
return ((code8)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
Yap_InitSlot(Deref(ARG3)),
|
||||
Yap_InitSlot(Deref(ARG4)),
|
||||
Yap_InitSlot(Deref(ARG5)),
|
||||
Yap_InitSlot(Deref(ARG6)),
|
||||
Yap_InitSlot(Deref(ARG7)),
|
||||
Yap_InitSlot(Deref(ARG8)),
|
||||
return ((code8)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG7) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG8) PASS_REGS),
|
||||
ctx));
|
||||
}
|
||||
case 9:
|
||||
{
|
||||
CBPredicate9 code9 = (CBPredicate9)exec_code;
|
||||
return ((code9)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
Yap_InitSlot(Deref(ARG3)),
|
||||
Yap_InitSlot(Deref(ARG4)),
|
||||
Yap_InitSlot(Deref(ARG5)),
|
||||
Yap_InitSlot(Deref(ARG6)),
|
||||
Yap_InitSlot(Deref(ARG7)),
|
||||
Yap_InitSlot(Deref(ARG8)),
|
||||
Yap_InitSlot(Deref(ARG9)),
|
||||
return ((code9)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG7) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG8) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG9) PASS_REGS),
|
||||
ctx));
|
||||
}
|
||||
case 10:
|
||||
{
|
||||
CBPredicate10 code10 = (CBPredicate10)exec_code;
|
||||
return ((code10)(Yap_InitSlot(Deref(ARG1)),
|
||||
Yap_InitSlot(Deref(ARG2)),
|
||||
Yap_InitSlot(Deref(ARG3)),
|
||||
Yap_InitSlot(Deref(ARG4)),
|
||||
Yap_InitSlot(Deref(ARG5)),
|
||||
Yap_InitSlot(Deref(ARG6)),
|
||||
Yap_InitSlot(Deref(ARG7)),
|
||||
Yap_InitSlot(Deref(ARG8)),
|
||||
Yap_InitSlot(Deref(ARG9)),
|
||||
Yap_InitSlot(Deref(ARG10)),
|
||||
return ((code10)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG7) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG8) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG9) PASS_REGS),
|
||||
Yap_InitSlot(Deref(ARG10) PASS_REGS),
|
||||
ctx));
|
||||
}
|
||||
default:
|
||||
@ -1513,6 +1537,7 @@ execute_cargs_back(PredEntry *pe, CPredicate exec_code, struct foreign_context *
|
||||
Int
|
||||
YAP_Execute(PredEntry *pe, CPredicate exec_code)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (pe->PredFlags & SWIEnvPredFlag) {
|
||||
CPredicateV codev = (CPredicateV)exec_code;
|
||||
struct foreign_context ctx;
|
||||
@ -1522,7 +1547,7 @@ YAP_Execute(PredEntry *pe, CPredicate exec_code)
|
||||
|
||||
ctx.engine = NULL;
|
||||
for (i=pe->ArityOfPE; i > 0; i--) {
|
||||
sl = Yap_InitSlot(XREGS[i]);
|
||||
sl = Yap_InitSlot(XREGS[i] PASS_REGS);
|
||||
}
|
||||
PP = pe;
|
||||
ret = ((codev)(sl,0,&ctx));
|
||||
@ -1541,7 +1566,7 @@ YAP_Execute(PredEntry *pe, CPredicate exec_code)
|
||||
}
|
||||
if (pe->PredFlags & CArgsPredFlag) {
|
||||
PP = pe;
|
||||
Int out = execute_cargs(pe, exec_code);
|
||||
Int out = execute_cargs(pe, exec_code PASS_REGS);
|
||||
PP = NULL;
|
||||
if (!out) {
|
||||
Term t;
|
||||
@ -1555,7 +1580,7 @@ YAP_Execute(PredEntry *pe, CPredicate exec_code)
|
||||
}
|
||||
return out;
|
||||
} else {
|
||||
Int ret = (exec_code)();
|
||||
Int ret = (exec_code)( PASS_REGS1 );
|
||||
if (!ret) {
|
||||
Term t;
|
||||
|
||||
@ -1578,6 +1603,7 @@ YAP_Execute(PredEntry *pe, CPredicate exec_code)
|
||||
Int
|
||||
YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (pe->PredFlags & (SWIEnvPredFlag|CArgsPredFlag)) {
|
||||
Int val;
|
||||
CPredicateV codev = (CPredicateV)exec_code;
|
||||
@ -1590,7 +1616,7 @@ YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code)
|
||||
ctx->engine = NULL; //(PL_local_data *)Yap_regp;
|
||||
ctx->context = NULL;
|
||||
if (pe->PredFlags & CArgsPredFlag) {
|
||||
val = execute_cargs_back(pe, exec_code, ctx);
|
||||
val = execute_cargs_back(pe, exec_code, ctx PASS_REGS);
|
||||
} else {
|
||||
val = ((codev)((&ARG1)-LCL0,0,ctx));
|
||||
}
|
||||
@ -1620,7 +1646,7 @@ YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code)
|
||||
return TRUE;
|
||||
}
|
||||
} else {
|
||||
Int ret = (exec_code)();
|
||||
Int ret = (exec_code)( PASS_REGS1 );
|
||||
if (!ret) {
|
||||
Term t;
|
||||
|
||||
@ -1638,6 +1664,7 @@ YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code)
|
||||
Int
|
||||
YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (pe->PredFlags & (SWIEnvPredFlag|CArgsPredFlag)) {
|
||||
Int val;
|
||||
CPredicateV codev = (CPredicateV)exec_code;
|
||||
@ -1650,7 +1677,7 @@ YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code)
|
||||
ctx->engine = NULL; //(PL_local_data *)Yap_regp;
|
||||
ctx->context = NULL;
|
||||
if (pe->PredFlags & CArgsPredFlag) {
|
||||
val = execute_cargs_back(pe, exec_code, ctx);
|
||||
val = execute_cargs_back(pe, exec_code, ctx PASS_REGS);
|
||||
} else {
|
||||
val = ((codev)((&ARG1)-LCL0,0,ctx));
|
||||
}
|
||||
@ -1674,7 +1701,7 @@ YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code)
|
||||
return TRUE;
|
||||
}
|
||||
} else {
|
||||
Int ret = (exec_code)();
|
||||
Int ret = (exec_code)( PASS_REGS1 );
|
||||
if (!ret) {
|
||||
Term t;
|
||||
|
||||
@ -1693,6 +1720,7 @@ YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code)
|
||||
Int
|
||||
YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (pe->PredFlags & (SWIEnvPredFlag|CArgsPredFlag)) {
|
||||
Int val;
|
||||
CPredicateV codev = (CPredicateV)exec_code;
|
||||
@ -1703,7 +1731,7 @@ YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code)
|
||||
PP = pe;
|
||||
ctx->control = FRG_REDO;
|
||||
if (pe->PredFlags & CArgsPredFlag) {
|
||||
val = execute_cargs_back(pe, exec_code, ctx);
|
||||
val = execute_cargs_back(pe, exec_code, ctx PASS_REGS);
|
||||
} else {
|
||||
val = ((codev)((&ARG1)-LCL0,0,ctx));
|
||||
}
|
||||
@ -1736,7 +1764,7 @@ YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code)
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
Int ret = (exec_code)();
|
||||
Int ret = (exec_code)( PASS_REGS1 );
|
||||
if (!ret) {
|
||||
Term t;
|
||||
|
||||
@ -1754,6 +1782,7 @@ YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code)
|
||||
X_API Int
|
||||
YAP_CallProlog(Term t)
|
||||
{
|
||||
CACHE_REGS
|
||||
Int out;
|
||||
Term mod = CurrentModule;
|
||||
BACKUP_MACHINE_REGS();
|
||||
@ -1774,6 +1803,7 @@ YAP_CallProlog(Term t)
|
||||
|
||||
X_API void *
|
||||
YAP_ReallocSpaceFromYap(void *ptr,unsigned int size) {
|
||||
CACHE_REGS
|
||||
void *new_ptr;
|
||||
BACKUP_MACHINE_REGS();
|
||||
while ((new_ptr = Yap_ReallocCodeSpace(ptr,size)) == NULL) {
|
||||
@ -1788,7 +1818,8 @@ YAP_ReallocSpaceFromYap(void *ptr,unsigned int size) {
|
||||
X_API void *
|
||||
YAP_AllocSpaceFromYap(unsigned int size)
|
||||
{
|
||||
void *ptr;
|
||||
CACHE_REGS
|
||||
void *ptr;
|
||||
BACKUP_MACHINE_REGS();
|
||||
|
||||
while ((ptr = Yap_AllocCodeSpace(size)) == NULL) {
|
||||
@ -1905,6 +1936,7 @@ YAP_NWideBufferToString(wchar_t *s, size_t len)
|
||||
X_API Term
|
||||
YAP_ReadBuffer(char *s, Term *tp)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t;
|
||||
BACKUP_H();
|
||||
|
||||
@ -2016,10 +2048,11 @@ YAP_NWideBufferToAtomDiffList(wchar_t *s, Term t0, size_t len)
|
||||
X_API Term
|
||||
YAP_BufferToDiffList(char *s, Term t0)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t;
|
||||
BACKUP_H();
|
||||
|
||||
t = Yap_StringToDiffList(s, t0);
|
||||
t = Yap_StringToDiffList(s, t0 PASS_REGS);
|
||||
|
||||
RECOVER_H();
|
||||
return t;
|
||||
@ -2099,12 +2132,14 @@ static int myputc (wchar_t ch)
|
||||
X_API PredEntry *
|
||||
YAP_FunctorToPred(Functor func)
|
||||
{
|
||||
CACHE_REGS
|
||||
return RepPredProp(PredPropByFunc(func, CurrentModule));
|
||||
}
|
||||
|
||||
X_API PredEntry *
|
||||
YAP_AtomToPred(Atom at)
|
||||
{
|
||||
CACHE_REGS
|
||||
return RepPredProp(PredPropByAtom(at, CurrentModule));
|
||||
}
|
||||
|
||||
@ -2112,6 +2147,7 @@ YAP_AtomToPred(Atom at)
|
||||
static int
|
||||
run_emulator(YAP_dogoalinfo *dgi)
|
||||
{
|
||||
CACHE_REGS
|
||||
choiceptr myB;
|
||||
int out;
|
||||
BACKUP_MACHINE_REGS();
|
||||
@ -2134,7 +2170,7 @@ run_emulator(YAP_dogoalinfo *dgi)
|
||||
B = B->cp_b;
|
||||
HB = B->cp_h;
|
||||
} else {
|
||||
Yap_StartSlots();
|
||||
Yap_StartSlots( PASS_REGS1 );
|
||||
}
|
||||
P = dgi->p;
|
||||
RECOVER_MACHINE_REGS();
|
||||
@ -2144,6 +2180,7 @@ run_emulator(YAP_dogoalinfo *dgi)
|
||||
X_API int
|
||||
YAP_EnterGoal(PredEntry *pe, Term *ptr, YAP_dogoalinfo *dgi)
|
||||
{
|
||||
CACHE_REGS
|
||||
UInt i;
|
||||
choiceptr myB;
|
||||
int out;
|
||||
@ -2186,6 +2223,7 @@ YAP_EnterGoal(PredEntry *pe, Term *ptr, YAP_dogoalinfo *dgi)
|
||||
X_API int
|
||||
YAP_RetryGoal(YAP_dogoalinfo *dgi)
|
||||
{
|
||||
CACHE_REGS
|
||||
choiceptr myB;
|
||||
int out;
|
||||
|
||||
@ -2205,6 +2243,7 @@ YAP_RetryGoal(YAP_dogoalinfo *dgi)
|
||||
X_API int
|
||||
YAP_LeaveGoal(int backtrack, YAP_dogoalinfo *dgi)
|
||||
{
|
||||
CACHE_REGS
|
||||
choiceptr myB;
|
||||
|
||||
BACKUP_MACHINE_REGS();
|
||||
@ -2246,6 +2285,7 @@ YAP_LeaveGoal(int backtrack, YAP_dogoalinfo *dgi)
|
||||
X_API Term
|
||||
YAP_RunGoal(Term t)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term out;
|
||||
yamop *old_CP = CP;
|
||||
BACKUP_MACHINE_REGS();
|
||||
@ -2272,6 +2312,7 @@ YAP_RunGoal(Term t)
|
||||
X_API Term
|
||||
YAP_RunGoalOnce(Term t)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term out;
|
||||
yamop *old_CP = CP;
|
||||
BACKUP_MACHINE_REGS();
|
||||
@ -2308,6 +2349,7 @@ YAP_RunGoalOnce(Term t)
|
||||
X_API int
|
||||
YAP_RestartGoal(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
int out;
|
||||
BACKUP_MACHINE_REGS();
|
||||
if (Yap_AllowRestart) {
|
||||
@ -2318,7 +2360,7 @@ YAP_RestartGoal(void)
|
||||
Yap_PrologMode = UserCCallMode;
|
||||
if (out == FALSE) {
|
||||
/* cleanup */
|
||||
Yap_CloseSlots();
|
||||
Yap_CloseSlots( PASS_REGS1 );
|
||||
Yap_trust_last();
|
||||
Yap_AllowRestart = FALSE;
|
||||
}
|
||||
@ -2332,6 +2374,7 @@ YAP_RestartGoal(void)
|
||||
X_API int
|
||||
YAP_ShutdownGoal(int backtrack)
|
||||
{
|
||||
CACHE_REGS
|
||||
BACKUP_MACHINE_REGS();
|
||||
|
||||
if (Yap_AllowRestart) {
|
||||
@ -2384,7 +2427,8 @@ YAP_ContinueGoal(void)
|
||||
X_API void
|
||||
YAP_PruneGoal(void)
|
||||
{
|
||||
BACKUP_B();
|
||||
CACHE_REGS
|
||||
BACKUP_B();
|
||||
|
||||
while (B->cp_ap != NOCODE) {
|
||||
B = B->cp_b;
|
||||
@ -2400,6 +2444,7 @@ YAP_PruneGoal(void)
|
||||
X_API int
|
||||
YAP_GoalHasException(Term *t)
|
||||
{
|
||||
CACHE_REGS
|
||||
int out = FALSE;
|
||||
BACKUP_MACHINE_REGS();
|
||||
if (EX) {
|
||||
@ -2434,6 +2479,7 @@ YAP_GoalHasException(Term *t)
|
||||
X_API void
|
||||
YAP_ClearExceptions(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
Yap_ResetExceptionTerm();
|
||||
if (EX) {
|
||||
BallTerm = EX;
|
||||
@ -2472,6 +2518,7 @@ YAP_EndConsult(IOSTREAM *s)
|
||||
X_API Term
|
||||
YAP_Read(IOSTREAM *inp)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t, tpos = TermNil;
|
||||
TokEntry *tokstart;
|
||||
|
||||
@ -2534,6 +2581,7 @@ YAP_WriteBuffer(Term t, char *buf, unsigned int sze, int flags)
|
||||
X_API char *
|
||||
YAP_CompileClause(Term t)
|
||||
{
|
||||
CACHE_REGS
|
||||
yamop *codeaddr;
|
||||
int mod = CurrentModule;
|
||||
Term tn = TermNil;
|
||||
@ -2671,6 +2719,7 @@ construct_init_file(char *boot_file, char *BootFile)
|
||||
X_API Int
|
||||
YAP_Init(YAP_init_args *yap_init)
|
||||
{
|
||||
CACHE_REGS
|
||||
int restore_result;
|
||||
int do_bootstrap = (yap_init->YapPrologBootFile != NULL);
|
||||
CELL Trail = 0, Stack = 0, Heap = 0, Atts = 0;
|
||||
@ -2729,6 +2778,10 @@ YAP_Init(YAP_init_args *yap_init)
|
||||
yap_init->SchedulerLoop,
|
||||
yap_init->DelayedReleaseLoad
|
||||
);
|
||||
#if THREADS
|
||||
/* make sure we use the correct value of regcache */
|
||||
regcache = ((REGSTORE *)pthread_getspecific(Yap_yaamregs_key));
|
||||
#endif
|
||||
#if USE_SYSTEM_MALLOC
|
||||
if (Trail < MinTrailSpace)
|
||||
Trail = MinTrailSpace;
|
||||
@ -2987,6 +3040,7 @@ YAP_CompareTerms(Term t1, Term t2)
|
||||
X_API int
|
||||
YAP_Reset(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
BACKUP_MACHINE_REGS();
|
||||
|
||||
/* first, backtrack to the root */
|
||||
@ -3077,6 +3131,7 @@ YAP_Halt(int i)
|
||||
X_API CELL *
|
||||
YAP_TopOfLocalStack(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
return(ASP);
|
||||
}
|
||||
|
||||
@ -3139,6 +3194,7 @@ YAP_UserBackCutCPredicate(char *name, CPredicate init, CPredicate cont, CPredica
|
||||
X_API void
|
||||
YAP_UserCPredicateWithArgs(char *a, CPredicate f, UInt arity, Term mod)
|
||||
{
|
||||
CACHE_REGS
|
||||
PredEntry *pe;
|
||||
Term cm = CurrentModule;
|
||||
CurrentModule = mod;
|
||||
@ -3156,12 +3212,14 @@ YAP_UserCPredicateWithArgs(char *a, CPredicate f, UInt arity, Term mod)
|
||||
X_API Term
|
||||
YAP_CurrentModule(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
return(CurrentModule);
|
||||
}
|
||||
|
||||
X_API Term
|
||||
YAP_SetCurrentModule(Term new)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term omod = CurrentModule;
|
||||
CurrentModule = new;
|
||||
return omod;
|
||||
@ -3270,6 +3328,7 @@ YAP_HaltRegisterHook(HaltHookFunc hook, void * closure)
|
||||
X_API char *
|
||||
YAP_cwd(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
char *buf;
|
||||
int len;
|
||||
if (!Yap_getcwd(Yap_FileNameBuf, YAP_FILENAME_MAX))
|
||||
@ -3285,6 +3344,7 @@ YAP_cwd(void)
|
||||
X_API Term
|
||||
YAP_OpenList(int n)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t;
|
||||
BACKUP_H();
|
||||
|
||||
@ -3403,6 +3463,7 @@ YAP_Record(Term t)
|
||||
X_API Term
|
||||
YAP_Recorded(void *handle)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t;
|
||||
DBTerm *dbterm = ((DBRecordList *)handle)->dbrecord;
|
||||
|
||||
@ -3452,7 +3513,8 @@ YAP_Erase(void *handle)
|
||||
X_API Int
|
||||
YAP_ArgsToSlots(int n)
|
||||
{
|
||||
Int slot = Yap_NewSlots(n);
|
||||
CACHE_REGS
|
||||
Int slot = Yap_NewSlots(n PASS_REGS);
|
||||
CELL *ptr0 = LCL0+slot, *ptr1=&ARG1;
|
||||
while (n--) {
|
||||
*ptr0++ = *ptr1++;
|
||||
@ -3463,6 +3525,7 @@ YAP_ArgsToSlots(int n)
|
||||
X_API void
|
||||
YAP_SlotsToArgs(int n, Int slot)
|
||||
{
|
||||
CACHE_REGS
|
||||
CELL *ptr0 = LCL0+slot, *ptr1=&ARG1;
|
||||
while (n--) {
|
||||
*ptr1++ = *ptr0++;
|
||||
@ -3501,7 +3564,8 @@ YAP_SetYAPFlag(yap_flag_t flag, int val)
|
||||
|
||||
/* Int YAP_VarSlotToNumber(Int) */
|
||||
Int YAP_VarSlotToNumber(Int s) {
|
||||
Term *t = (CELL *)Deref(Yap_GetFromSlot(s));
|
||||
CACHE_REGS
|
||||
Term *t = (CELL *)Deref(Yap_GetFromSlot(s PASS_REGS));
|
||||
if (t < H)
|
||||
return t-H0;
|
||||
return t-LCL0;
|
||||
|
260
C/cdmgr.c
260
C/cdmgr.c
@ -480,7 +480,7 @@ STATIC_PROTO(void asserta_stat_clause, (PredEntry *, yamop *, int));
|
||||
STATIC_PROTO(void asserta_dynam_clause, (PredEntry *, yamop *));
|
||||
STATIC_PROTO(void assertz_stat_clause, (PredEntry *, yamop *, int));
|
||||
STATIC_PROTO(void assertz_dynam_clause, (PredEntry *, yamop *));
|
||||
STATIC_PROTO(void expand_consult, (void));
|
||||
STATIC_PROTO(void expand_consult, ( void ));
|
||||
STATIC_PROTO(int not_was_reconsulted, (PredEntry *, Term, int));
|
||||
STATIC_PROTO(int RemoveIndexation, (PredEntry *));
|
||||
#if EMACS
|
||||
@ -492,33 +492,33 @@ STATIC_PROTO(Int search_for_static_predicate_in_use, (PredEntry *, int));
|
||||
STATIC_PROTO(void mark_pred, (int, PredEntry *));
|
||||
STATIC_PROTO(void do_toggle_static_predicates_in_use, (int));
|
||||
#endif
|
||||
STATIC_PROTO(Int p_number_of_clauses, (void));
|
||||
STATIC_PROTO(Int p_compile, (void));
|
||||
STATIC_PROTO(Int p_compile_dynamic, (void));
|
||||
STATIC_PROTO(Int p_purge_clauses, (void));
|
||||
STATIC_PROTO(Int p_setspy, (void));
|
||||
STATIC_PROTO(Int p_rmspy, (void));
|
||||
STATIC_PROTO(Int p_startconsult, (void));
|
||||
STATIC_PROTO(Int p_showconslultlev, (void));
|
||||
STATIC_PROTO(Int p_endconsult, (void));
|
||||
STATIC_PROTO(Int p_undefined, (void));
|
||||
STATIC_PROTO(Int p_in_use, (void));
|
||||
STATIC_PROTO(Int p_new_multifile, (void));
|
||||
STATIC_PROTO(Int p_is_multifile, (void));
|
||||
STATIC_PROTO(Int p_optimizer_on, (void));
|
||||
STATIC_PROTO(Int p_optimizer_off, (void));
|
||||
STATIC_PROTO(Int p_is_dynamic, (void));
|
||||
STATIC_PROTO(Int p_kill_dynamic, (void));
|
||||
STATIC_PROTO(Int p_compile_mode, (void));
|
||||
STATIC_PROTO(Int p_is_profiled, (void));
|
||||
STATIC_PROTO(Int p_profile_info, (void));
|
||||
STATIC_PROTO(Int p_profile_reset, (void));
|
||||
STATIC_PROTO(Int p_is_call_counted, (void));
|
||||
STATIC_PROTO(Int p_call_count_info, (void));
|
||||
STATIC_PROTO(Int p_call_count_set, (void));
|
||||
STATIC_PROTO(Int p_call_count_reset, (void));
|
||||
STATIC_PROTO(Int p_toggle_static_predicates_in_use, (void));
|
||||
STATIC_PROTO(Atom YapConsultingFile, (void));
|
||||
STATIC_PROTO(Int p_number_of_clauses, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_compile, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_compile_dynamic, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_purge_clauses, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_setspy, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_rmspy, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_startconsult, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_showconslultlev, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_endconsult, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_undefined, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_in_use, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_new_multifile, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_is_multifile, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_optimizer_on, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_optimizer_off, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_is_dynamic, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_kill_dynamic, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_compile_mode, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_is_profiled, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_profile_info, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_profile_reset, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_is_call_counted, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_call_count_info, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_call_count_set, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_call_count_reset, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_toggle_static_predicates_in_use, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Atom YapConsultingFile, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int PredForCode,(yamop *, Atom *, UInt *, Term *));
|
||||
STATIC_PROTO(void kill_first_log_iblock,(LogUpdIndex *, LogUpdIndex *, PredEntry *));
|
||||
STATIC_PROTO(LogUpdIndex *find_owner_log_index,(LogUpdIndex *, yamop *));
|
||||
@ -632,8 +632,9 @@ Yap_PredForChoicePt(choiceptr cp) {
|
||||
}
|
||||
|
||||
static void
|
||||
InitConsultStack(void)
|
||||
InitConsultStack( void )
|
||||
{
|
||||
CACHE_REGS
|
||||
ConsultLow = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj)*InitialConsultCapacity);
|
||||
if (ConsultLow == NULL) {
|
||||
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"No Heap Space in InitCodes");
|
||||
@ -645,8 +646,9 @@ InitConsultStack(void)
|
||||
}
|
||||
|
||||
void
|
||||
Yap_ResetConsultStack(void)
|
||||
Yap_ResetConsultStack( void )
|
||||
{
|
||||
CACHE_REGS
|
||||
Yap_FreeCodeSpace((char *)ConsultLow);
|
||||
ConsultBase =
|
||||
ConsultSp =
|
||||
@ -776,6 +778,7 @@ get_pred(Term t, Term tmod, char *pname)
|
||||
|
||||
static Term BlobTermInCodeAdjust(Term t)
|
||||
{
|
||||
CACHE_REGS
|
||||
#if TAGS_FAST_OPS
|
||||
return t-ClDiff;
|
||||
#else
|
||||
@ -801,6 +804,7 @@ static UInt total_megaclause, total_released, nof_megaclauses;
|
||||
void
|
||||
Yap_BuildMegaClause(PredEntry *ap)
|
||||
{
|
||||
CACHE_REGS
|
||||
StaticClause *cl;
|
||||
UInt sz;
|
||||
MegaClause *mcl;
|
||||
@ -860,7 +864,7 @@ Yap_BuildMegaClause(PredEntry *ap)
|
||||
memcpy((void *)ptr, (void *)cl->ClCode, sz);
|
||||
if (has_blobs) {
|
||||
ClDiff = (char *)(ptr)-(char *)cl->ClCode;
|
||||
restore_opcodes(ptr, NULL);
|
||||
restore_opcodes(ptr, NULL PASS_REGS);
|
||||
}
|
||||
ptr = (yamop *)((char *)ptr + sz);
|
||||
if (cl->ClCode == ap->cs.p_code.LastClause)
|
||||
@ -953,6 +957,7 @@ split_megaclause(PredEntry *ap)
|
||||
static void
|
||||
IPred(PredEntry *ap, UInt NSlots, yamop *next_pc)
|
||||
{
|
||||
CACHE_REGS
|
||||
yamop *BaseAddr;
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -1938,8 +1943,9 @@ assertz_dynam_clause(PredEntry *p, yamop *cp)
|
||||
p->cs.p_code.NOfClauses++;
|
||||
}
|
||||
|
||||
static void expand_consult(void)
|
||||
static void expand_consult( void )
|
||||
{
|
||||
CACHE_REGS
|
||||
consult_obj *new_cl, *new_cs;
|
||||
UInt OldConsultCapacity = ConsultCapacity;
|
||||
|
||||
@ -1971,6 +1977,7 @@ static void expand_consult(void)
|
||||
static int
|
||||
not_was_reconsulted(PredEntry *p, Term t, int mode)
|
||||
{
|
||||
CACHE_REGS
|
||||
register consult_obj *fp;
|
||||
Prop p0 = AbsProp((PropEntry *)p);
|
||||
|
||||
@ -1999,7 +2006,7 @@ not_was_reconsulted(PredEntry *p, Term t, int mode)
|
||||
!(p->PredFlags & MultiFileFlag)) /* we are in reconsult mode */ {
|
||||
retract_all(p, static_in_use(p,TRUE));
|
||||
}
|
||||
p->src.OwnerFile = YapConsultingFile();
|
||||
p->src.OwnerFile = YapConsultingFile( PASS_REGS1 );
|
||||
}
|
||||
return TRUE; /* careful */
|
||||
}
|
||||
@ -2007,6 +2014,7 @@ not_was_reconsulted(PredEntry *p, Term t, int mode)
|
||||
static void
|
||||
addcl_permission_error(AtomEntry *ap, Int Arity, int in_use)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t, ti[2];
|
||||
|
||||
ti[0] = MkAtomTerm(AbsAtom(ap));
|
||||
@ -2078,6 +2086,7 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
|
||||
2 asserta
|
||||
*/
|
||||
{
|
||||
CACHE_REGS
|
||||
PredEntry *p;
|
||||
int spy_flag = FALSE;
|
||||
Atom at;
|
||||
@ -2276,7 +2285,7 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
|
||||
if (pflags & MultiFileFlag) {
|
||||
/* add Info on new clause for multifile predicates to the DB */
|
||||
Term t[5], tn;
|
||||
t[0] = MkAtomTerm(YapConsultingFile());
|
||||
t[0] = MkAtomTerm(YapConsultingFile( PASS_REGS1 ));
|
||||
t[1] = MkAtomTerm(at);
|
||||
t[2] = MkIntegerTerm(Arity);
|
||||
t[3] = mod;
|
||||
@ -2438,7 +2447,7 @@ where_new_clause(pred_prop, mode)
|
||||
#endif
|
||||
|
||||
static Int
|
||||
p_compile(void)
|
||||
p_compile( USES_REGS1 )
|
||||
{ /* '$compile'(+C,+Flags, Mod) */
|
||||
Term t = Deref(ARG1);
|
||||
Term t1 = Deref(ARG2);
|
||||
@ -2471,7 +2480,7 @@ p_compile(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_compile_dynamic(void)
|
||||
p_compile_dynamic( USES_REGS1 )
|
||||
{ /* '$compile_dynamic'(+C,+Flags,Mod,-Ref) */
|
||||
Term t = Deref(ARG1);
|
||||
Term t1 = Deref(ARG2);
|
||||
@ -2513,7 +2522,7 @@ p_compile_dynamic(void)
|
||||
static int consult_level = 0;
|
||||
|
||||
static Atom
|
||||
YapConsultingFile (void)
|
||||
YapConsultingFile ( USES_REGS1 )
|
||||
{
|
||||
if (consult_level == 0) {
|
||||
return(AtomUser);
|
||||
@ -2523,15 +2532,17 @@ YapConsultingFile (void)
|
||||
}
|
||||
|
||||
Atom
|
||||
Yap_ConsultingFile (void)
|
||||
Yap_ConsultingFile ( void )
|
||||
{
|
||||
return YapConsultingFile();
|
||||
CACHE_REGS
|
||||
return YapConsultingFile( PASS_REGS1 );
|
||||
}
|
||||
|
||||
/* consult file *file*, *mode* may be one of either consult or reconsult */
|
||||
static void
|
||||
init_consult(int mode, char *file)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (!ConsultSp) {
|
||||
InitConsultStack();
|
||||
}
|
||||
@ -2557,7 +2568,7 @@ Yap_init_consult(int mode, char *file)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_startconsult(void)
|
||||
p_startconsult( USES_REGS1 )
|
||||
{ /* '$start_consult'(+Mode) */
|
||||
Term t;
|
||||
char *smode = RepAtom(AtomOfTerm(Deref(ARG1)))->StrOfAE;
|
||||
@ -2570,7 +2581,7 @@ p_startconsult(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_showconslultlev(void)
|
||||
p_showconslultlev( USES_REGS1 )
|
||||
{
|
||||
Term t;
|
||||
|
||||
@ -2579,7 +2590,7 @@ p_showconslultlev(void)
|
||||
}
|
||||
|
||||
static void
|
||||
end_consult(void)
|
||||
end_consult( USES_REGS1 )
|
||||
{
|
||||
ConsultSp = ConsultBase;
|
||||
ConsultBase = ConsultSp+ConsultSp->c;
|
||||
@ -2593,15 +2604,16 @@ end_consult(void)
|
||||
}
|
||||
|
||||
void
|
||||
Yap_end_consult(void) {
|
||||
end_consult();
|
||||
Yap_end_consult( void ) {
|
||||
CACHE_REGS
|
||||
end_consult( PASS_REGS1 );
|
||||
}
|
||||
|
||||
|
||||
static Int
|
||||
p_endconsult(void)
|
||||
p_endconsult( USES_REGS1 )
|
||||
{ /* '$end_consult' */
|
||||
end_consult();
|
||||
end_consult( PASS_REGS1 );
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -2626,7 +2638,7 @@ Yap_Abolish(PredEntry *pred)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_purge_clauses(void)
|
||||
p_purge_clauses( USES_REGS1 )
|
||||
{ /* '$purge_clauses'(+Func) */
|
||||
PredEntry *pred;
|
||||
Term t = Deref(ARG1);
|
||||
@ -2664,7 +2676,7 @@ p_purge_clauses(void)
|
||||
******************************************************************/
|
||||
|
||||
static Int
|
||||
p_setspy(void)
|
||||
p_setspy( USES_REGS1 )
|
||||
{ /* '$set_spy'(+Fun,+M) */
|
||||
Atom at;
|
||||
PredEntry *pred;
|
||||
@ -2723,7 +2735,7 @@ p_setspy(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_rmspy(void)
|
||||
p_rmspy( USES_REGS1 )
|
||||
{ /* '$rm_spy'(+T,+Mod) */
|
||||
Atom at;
|
||||
PredEntry *pred;
|
||||
@ -2791,7 +2803,7 @@ p_rmspy(void)
|
||||
******************************************************************/
|
||||
|
||||
static Int
|
||||
p_number_of_clauses(void)
|
||||
p_number_of_clauses( USES_REGS1 )
|
||||
{ /* '$number_of_clauses'(Predicate,M,N) */
|
||||
Term t = Deref(ARG1);
|
||||
Term mod = Deref(ARG2);
|
||||
@ -2819,7 +2831,7 @@ p_number_of_clauses(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_in_use(void)
|
||||
p_in_use( USES_REGS1 )
|
||||
{ /* '$in_use'(+P,+Mod) */
|
||||
PredEntry *pe;
|
||||
Int out;
|
||||
@ -2834,7 +2846,7 @@ p_in_use(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_new_multifile(void)
|
||||
p_new_multifile( USES_REGS1 )
|
||||
{ /* '$new_multifile'(+N,+Ar,+Mod) */
|
||||
Atom at;
|
||||
int arity;
|
||||
@ -2873,7 +2885,7 @@ p_new_multifile(void)
|
||||
|
||||
|
||||
static Int
|
||||
p_is_multifile(void)
|
||||
p_is_multifile( USES_REGS1 )
|
||||
{ /* '$is_multifile'(+S,+Mod) */
|
||||
PredEntry *pe;
|
||||
Int out;
|
||||
@ -2888,7 +2900,7 @@ p_is_multifile(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_is_log_updatable(void)
|
||||
p_is_log_updatable( USES_REGS1 )
|
||||
{ /* '$is_dynamic'(+P) */
|
||||
PredEntry *pe;
|
||||
Int out;
|
||||
@ -2903,7 +2915,7 @@ p_is_log_updatable(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_is_source(void)
|
||||
p_is_source( USES_REGS1 )
|
||||
{ /* '$is_dynamic'(+P) */
|
||||
PredEntry *pe;
|
||||
Int out;
|
||||
@ -2918,7 +2930,7 @@ p_is_source(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_owner_file(void)
|
||||
p_owner_file( USES_REGS1 )
|
||||
{ /* '$owner_file'(+P,M,F) */
|
||||
PredEntry *pe;
|
||||
Atom owner;
|
||||
@ -2941,7 +2953,7 @@ p_owner_file(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_mk_d(void)
|
||||
p_mk_d( USES_REGS1 )
|
||||
{ /* '$is_dynamic'(+P) */
|
||||
PredEntry *pe;
|
||||
|
||||
@ -2957,7 +2969,7 @@ p_mk_d(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_is_dynamic(void)
|
||||
p_is_dynamic( USES_REGS1 )
|
||||
{ /* '$is_dynamic'(+P) */
|
||||
PredEntry *pe;
|
||||
Int out;
|
||||
@ -2972,7 +2984,7 @@ p_is_dynamic(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_is_metapredicate(void)
|
||||
p_is_metapredicate( USES_REGS1 )
|
||||
{ /* '$is_metapredicate'(+P) */
|
||||
PredEntry *pe;
|
||||
Int out;
|
||||
@ -2987,7 +2999,7 @@ p_is_metapredicate(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_is_expandgoalormetapredicate(void)
|
||||
p_is_expandgoalormetapredicate( USES_REGS1 )
|
||||
{ /* '$is_expand_goal_predicate'(+P) */
|
||||
PredEntry *pe;
|
||||
Term t = Deref(ARG1);
|
||||
@ -3050,7 +3062,7 @@ p_is_expandgoalormetapredicate(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_pred_exists(void)
|
||||
p_pred_exists( USES_REGS1 )
|
||||
{ /* '$pred_exists'(+P,+M) */
|
||||
PredEntry *pe;
|
||||
Int out;
|
||||
@ -3069,7 +3081,7 @@ p_pred_exists(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_set_pred_module(void)
|
||||
p_set_pred_module( USES_REGS1 )
|
||||
{ /* '$set_pred_module'(+P,+Mod) */
|
||||
PredEntry *pe;
|
||||
|
||||
@ -3083,7 +3095,7 @@ p_set_pred_module(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_undefined(void)
|
||||
p_undefined( USES_REGS1 )
|
||||
{ /* '$undefined'(P,Mod) */
|
||||
PredEntry *pe;
|
||||
|
||||
@ -3109,7 +3121,7 @@ p_undefined(void)
|
||||
*/
|
||||
|
||||
static Int
|
||||
p_kill_dynamic(void)
|
||||
p_kill_dynamic( USES_REGS1 )
|
||||
{ /* '$kill_dynamic'(P,M) */
|
||||
PredEntry *pe;
|
||||
|
||||
@ -3134,21 +3146,21 @@ p_kill_dynamic(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_optimizer_on(void)
|
||||
p_optimizer_on( USES_REGS1 )
|
||||
{ /* '$optimizer_on' */
|
||||
optimizer_on = TRUE;
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_optimizer_off(void)
|
||||
p_optimizer_off( USES_REGS1 )
|
||||
{ /* '$optimizer_off' */
|
||||
optimizer_on = FALSE;
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_compile_mode(void)
|
||||
p_compile_mode( USES_REGS1 )
|
||||
{ /* $compile_mode(Old,New) */
|
||||
Term t2, t3 = MkIntTerm(compile_mode);
|
||||
if (!Yap_unify_constant(ARG1, t3))
|
||||
@ -3368,7 +3380,7 @@ Yap_find_owner_index(yamop *ipc, PredEntry *ap)
|
||||
}
|
||||
|
||||
static Term
|
||||
all_envs(CELL *env_ptr)
|
||||
all_envs(CELL *env_ptr USES_REGS)
|
||||
{
|
||||
Term tf = AbsPair(H);
|
||||
CELL *start = H;
|
||||
@ -3398,7 +3410,7 @@ all_envs(CELL *env_ptr)
|
||||
}
|
||||
|
||||
static Term
|
||||
all_cps(choiceptr b_ptr)
|
||||
all_cps(choiceptr b_ptr USES_REGS)
|
||||
{
|
||||
CELL *bp = NULL;
|
||||
CELL *start = H;
|
||||
@ -3428,7 +3440,7 @@ all_cps(choiceptr b_ptr)
|
||||
|
||||
|
||||
static Term
|
||||
all_calls(void)
|
||||
all_calls( USES_REGS1 )
|
||||
{
|
||||
Term ts[4];
|
||||
Functor f = Yap_MkFunctor(AtomLocalSp,4);
|
||||
@ -3436,8 +3448,8 @@ all_calls(void)
|
||||
ts[0] = MkIntegerTerm((Int)P);
|
||||
ts[1] = MkIntegerTerm((Int)CP);
|
||||
if (yap_flags[STACK_DUMP_ON_ERROR_FLAG]) {
|
||||
ts[2] = all_envs(ENV);
|
||||
ts[3] = all_cps(B);
|
||||
ts[2] = all_envs(ENV PASS_REGS);
|
||||
ts[3] = all_cps(B PASS_REGS);
|
||||
if (ts[2] == 0L ||
|
||||
ts[3] == 0L)
|
||||
return 0L;
|
||||
@ -3448,16 +3460,17 @@ all_calls(void)
|
||||
}
|
||||
|
||||
Term
|
||||
Yap_all_calls(void)
|
||||
Yap_all_calls( void )
|
||||
{
|
||||
return all_calls();
|
||||
CACHE_REGS
|
||||
return all_calls( PASS_REGS1 );
|
||||
}
|
||||
|
||||
static Int
|
||||
p_all_choicepoints(void)
|
||||
p_all_choicepoints( USES_REGS1 )
|
||||
{
|
||||
Term t;
|
||||
while ((t = all_cps(B)) == 0L) {
|
||||
while ((t = all_cps(B PASS_REGS)) == 0L) {
|
||||
if (!Yap_gcl(Yap_Error_Size, 1, ENV, gc_P(P,CP))) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while dumping choicepoints");
|
||||
return FALSE;
|
||||
@ -3467,10 +3480,10 @@ p_all_choicepoints(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_all_envs(void)
|
||||
p_all_envs( USES_REGS1 )
|
||||
{
|
||||
Term t;
|
||||
while ((t = all_envs(ENV)) == 0L) {
|
||||
while ((t = all_envs(ENV PASS_REGS)) == 0L) {
|
||||
if (!Yap_gcl(Yap_Error_Size, 1, ENV, gc_P(P,CP))) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while dumping environments");
|
||||
return FALSE;
|
||||
@ -3480,10 +3493,10 @@ p_all_envs(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_current_stack(void)
|
||||
p_current_stack( USES_REGS1 )
|
||||
{
|
||||
Term t;
|
||||
while ((t = all_calls()) == 0L) {
|
||||
while ((t = all_calls( PASS_REGS1 )) == 0L) {
|
||||
if (!Yap_gcl(Yap_Error_Size, 1, ENV, gc_P(P,CP))) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while dumping stack");
|
||||
return FALSE;
|
||||
@ -3499,7 +3512,7 @@ p_current_stack(void)
|
||||
|
||||
*/
|
||||
static Int
|
||||
p_toggle_static_predicates_in_use(void)
|
||||
p_toggle_static_predicates_in_use( USES_REGS1 )
|
||||
{
|
||||
#if !defined(YAPOR) && !defined(THREADS)
|
||||
Term t = Deref(ARG1);
|
||||
@ -3837,7 +3850,7 @@ found_idb_clause(yamop *pc, CODEADDR *startp, CODEADDR *endp)
|
||||
|
||||
/* we hit a expand_index, no point in going on */
|
||||
static PredEntry *
|
||||
found_expand_index(yamop *pc, CODEADDR *startp, CODEADDR *endp, yamop *codeptr)
|
||||
found_expand_index(yamop *pc, CODEADDR *startp, CODEADDR *endp, yamop *codeptr USES_REGS)
|
||||
{
|
||||
PredEntry *pp = codeptr->u.sssllp.p;
|
||||
if (pc == codeptr) {
|
||||
@ -3849,7 +3862,7 @@ found_expand_index(yamop *pc, CODEADDR *startp, CODEADDR *endp, yamop *codeptr)
|
||||
|
||||
/* we hit a expand_index, no point in going on */
|
||||
static PredEntry *
|
||||
found_fail(yamop *pc, CODEADDR *startp, CODEADDR *endp)
|
||||
found_fail(yamop *pc, CODEADDR *startp, CODEADDR *endp USES_REGS)
|
||||
{
|
||||
PredEntry *pp = RepPredProp(Yap_GetPredPropByAtom(AtomFail,CurrentModule));
|
||||
*startp = *endp = (CODEADDR)FAILCODE;
|
||||
@ -3858,7 +3871,7 @@ found_fail(yamop *pc, CODEADDR *startp, CODEADDR *endp)
|
||||
|
||||
/* we hit a expand_index, no point in going on */
|
||||
static PredEntry *
|
||||
found_owner_op(yamop *pc, CODEADDR *startp, CODEADDR *endp)
|
||||
found_owner_op(yamop *pc, CODEADDR *startp, CODEADDR *endp USES_REGS)
|
||||
{
|
||||
PredEntry *pp = ((PredEntry *)(Unsigned(pc)-(CELL)(&(((PredEntry *)NULL)->OpcodeOfPred))));
|
||||
*startp = (CODEADDR)&(pp->OpcodeOfPred);
|
||||
@ -3868,7 +3881,7 @@ found_owner_op(yamop *pc, CODEADDR *startp, CODEADDR *endp)
|
||||
|
||||
/* we hit a expand_index, no point in going on */
|
||||
static PredEntry *
|
||||
found_expand(yamop *pc, CODEADDR *startp, CODEADDR *endp)
|
||||
found_expand(yamop *pc, CODEADDR *startp, CODEADDR *endp USES_REGS)
|
||||
{
|
||||
PredEntry *pp = ((PredEntry *)(Unsigned(pc)-(CELL)(&(((PredEntry *)NULL)->cs.p_code.ExpandCode))));
|
||||
*startp = (CODEADDR)&(pp->cs.p_code.ExpandCode);
|
||||
@ -3877,7 +3890,7 @@ found_expand(yamop *pc, CODEADDR *startp, CODEADDR *endp)
|
||||
}
|
||||
|
||||
static PredEntry *
|
||||
found_ystop(yamop *pc, int clause_code, CODEADDR *startp, CODEADDR *endp, PredEntry *pp)
|
||||
found_ystop(yamop *pc, int clause_code, CODEADDR *startp, CODEADDR *endp, PredEntry *pp USES_REGS)
|
||||
{
|
||||
if (pc == YESCODE) {
|
||||
pp = RepPredProp(Yap_GetPredPropByAtom(AtomTrue,CurrentModule));
|
||||
@ -3919,7 +3932,7 @@ found_ystop(yamop *pc, int clause_code, CODEADDR *startp, CODEADDR *endp, PredEn
|
||||
}
|
||||
|
||||
static PredEntry *
|
||||
ClauseInfoForCode(yamop *codeptr, CODEADDR *startp, CODEADDR *endp) {
|
||||
ClauseInfoForCode(yamop *codeptr, CODEADDR *startp, CODEADDR *endp USES_REGS) {
|
||||
yamop *pc;
|
||||
PredEntry *pp = NULL;
|
||||
int clause_code = FALSE;
|
||||
@ -3938,7 +3951,7 @@ ClauseInfoForCode(yamop *codeptr, CODEADDR *startp, CODEADDR *endp) {
|
||||
|
||||
PredEntry *
|
||||
Yap_PredEntryForCode(yamop *codeptr, find_pred_type where_from, CODEADDR *startp, CODEADDR *endp) {
|
||||
|
||||
CACHE_REGS
|
||||
if (where_from == FIND_PRED_FROM_CP) {
|
||||
PredEntry *pp = PredForChoicePt(codeptr);
|
||||
if (cl_code_in_pred(pp, codeptr, startp, endp)) {
|
||||
@ -3950,14 +3963,14 @@ Yap_PredEntryForCode(yamop *codeptr, find_pred_type where_from, CODEADDR *startp
|
||||
return pp;
|
||||
}
|
||||
} else {
|
||||
return ClauseInfoForCode(codeptr, startp, endp);
|
||||
return ClauseInfoForCode(codeptr, startp, endp PASS_REGS);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static Int
|
||||
p_pred_for_code(void) {
|
||||
p_pred_for_code( USES_REGS1 ) {
|
||||
yamop *codeptr;
|
||||
Atom at;
|
||||
UInt arity;
|
||||
@ -3989,7 +4002,7 @@ p_pred_for_code(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_is_profiled(void)
|
||||
p_is_profiled( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
char *s;
|
||||
@ -4021,7 +4034,7 @@ p_is_profiled(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_profile_info(void)
|
||||
p_profile_info( USES_REGS1 )
|
||||
{
|
||||
Term mod = Deref(ARG1);
|
||||
Term tfun = Deref(ARG2);
|
||||
@ -4060,7 +4073,7 @@ p_profile_info(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_profile_reset(void)
|
||||
p_profile_reset( USES_REGS1 )
|
||||
{
|
||||
Term mod = Deref(ARG1);
|
||||
Term tfun = Deref(ARG2);
|
||||
@ -4092,7 +4105,7 @@ p_profile_reset(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_is_call_counted(void)
|
||||
p_is_call_counted( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
char *s;
|
||||
@ -4124,7 +4137,7 @@ p_is_call_counted(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_call_count_info(void)
|
||||
p_call_count_info( USES_REGS1 )
|
||||
{
|
||||
return(Yap_unify(MkIntegerTerm(ReductionsCounter),ARG1) &&
|
||||
Yap_unify(MkIntegerTerm(PredEntriesCounter),ARG2) &&
|
||||
@ -4132,7 +4145,7 @@ p_call_count_info(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_call_count_reset(void)
|
||||
p_call_count_reset( USES_REGS1 )
|
||||
{
|
||||
ReductionsCounter = 0;
|
||||
ReductionsCounterOn = FALSE;
|
||||
@ -4144,7 +4157,7 @@ p_call_count_reset(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_call_count_set(void)
|
||||
p_call_count_set( USES_REGS1 )
|
||||
{
|
||||
int do_calls = IntOfTerm(ARG2);
|
||||
int do_retries = IntOfTerm(ARG4);
|
||||
@ -4163,7 +4176,7 @@ p_call_count_set(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_clean_up_dead_clauses(void)
|
||||
p_clean_up_dead_clauses( USES_REGS1 )
|
||||
{
|
||||
while (DeadStaticClauses != NULL) {
|
||||
char *pt = (char *)DeadStaticClauses;
|
||||
@ -4193,7 +4206,7 @@ p_clean_up_dead_clauses(void)
|
||||
}
|
||||
|
||||
static Int /* $parent_pred(Module, Name, Arity) */
|
||||
p_parent_pred(void)
|
||||
p_parent_pred( USES_REGS1 )
|
||||
{
|
||||
/* This predicate is called from the debugger.
|
||||
We assume a sequence of the form a -> b */
|
||||
@ -4211,7 +4224,7 @@ p_parent_pred(void)
|
||||
}
|
||||
|
||||
static Int /* $system_predicate(P) */
|
||||
p_system_pred(void)
|
||||
p_system_pred( USES_REGS1 )
|
||||
{
|
||||
PredEntry *pe;
|
||||
|
||||
@ -4256,7 +4269,7 @@ p_system_pred(void)
|
||||
}
|
||||
|
||||
static Int /* $system_predicate(P) */
|
||||
p_all_system_pred(void)
|
||||
p_all_system_pred( USES_REGS1 )
|
||||
{
|
||||
PredEntry *pe;
|
||||
|
||||
@ -4308,7 +4321,7 @@ p_all_system_pred(void)
|
||||
}
|
||||
|
||||
static Int /* $system_predicate(P) */
|
||||
p_hide_predicate(void)
|
||||
p_hide_predicate( USES_REGS1 )
|
||||
{
|
||||
PredEntry *pe;
|
||||
|
||||
@ -4350,7 +4363,7 @@ p_hide_predicate(void)
|
||||
}
|
||||
|
||||
static Int /* $hidden_predicate(P) */
|
||||
p_hidden_predicate(void)
|
||||
p_hidden_predicate( USES_REGS1 )
|
||||
{
|
||||
PredEntry *pe;
|
||||
|
||||
@ -4393,6 +4406,7 @@ p_hidden_predicate(void)
|
||||
static Int
|
||||
fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, yamop *cp_ptr, int first_time)
|
||||
{
|
||||
CACHE_REGS
|
||||
LogUpdClause *cl;
|
||||
Term rtn;
|
||||
Term Terms[3];
|
||||
@ -4506,7 +4520,7 @@ fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, ya
|
||||
}
|
||||
|
||||
static Int /* $hidden_predicate(P) */
|
||||
p_log_update_clause(void)
|
||||
p_log_update_clause( USES_REGS1 )
|
||||
{
|
||||
PredEntry *pe;
|
||||
Term t1 = Deref(ARG1);
|
||||
@ -4527,7 +4541,7 @@ p_log_update_clause(void)
|
||||
}
|
||||
|
||||
static Int /* $hidden_predicate(P) */
|
||||
p_continue_log_update_clause(void)
|
||||
p_continue_log_update_clause( USES_REGS1 )
|
||||
{
|
||||
PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
||||
yamop *ipc = (yamop *)IntegerOfTerm(ARG2);
|
||||
@ -4539,6 +4553,7 @@ p_continue_log_update_clause(void)
|
||||
static Int
|
||||
fetch_next_lu_clause_erase(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, yamop *cp_ptr, int first_time)
|
||||
{
|
||||
CACHE_REGS
|
||||
LogUpdClause *cl;
|
||||
Term rtn;
|
||||
Term Terms[3];
|
||||
@ -4656,7 +4671,7 @@ fetch_next_lu_clause_erase(PredEntry *pe, yamop *i_code, Term th, Term tb, Term
|
||||
}
|
||||
|
||||
static Int /* $hidden_predicate(P) */
|
||||
p_log_update_clause_erase(void)
|
||||
p_log_update_clause_erase( USES_REGS1 )
|
||||
{
|
||||
PredEntry *pe;
|
||||
Term t1 = Deref(ARG1);
|
||||
@ -4677,7 +4692,7 @@ p_log_update_clause_erase(void)
|
||||
}
|
||||
|
||||
static Int /* $hidden_predicate(P) */
|
||||
p_continue_log_update_clause_erase(void)
|
||||
p_continue_log_update_clause_erase( USES_REGS1 )
|
||||
{
|
||||
PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
||||
yamop *ipc = (yamop *)IntegerOfTerm(ARG2);
|
||||
@ -4733,6 +4748,7 @@ replace_integer(Term orig, UInt new)
|
||||
void /* $hidden_predicate(P) */
|
||||
Yap_UpdateTimestamps(PredEntry *ap)
|
||||
{
|
||||
CACHE_REGS
|
||||
choiceptr bptr = B;
|
||||
yamop *cl0 = NEXTOP(PredLogUpdClause0->CodeOfPred,Otapl);
|
||||
yamop *cl = NEXTOP(PredLogUpdClause->CodeOfPred,Otapl);
|
||||
@ -4859,6 +4875,7 @@ Yap_UpdateTimestamps(PredEntry *ap)
|
||||
static Int
|
||||
fetch_next_static_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, yamop *cp_ptr, int first_time)
|
||||
{
|
||||
CACHE_REGS
|
||||
StaticClause *cl;
|
||||
Term rtn;
|
||||
Term Terms[3];
|
||||
@ -4996,7 +5013,7 @@ fetch_next_static_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr
|
||||
}
|
||||
|
||||
static Int /* $hidden_predicate(P) */
|
||||
p_static_clause(void)
|
||||
p_static_clause( USES_REGS1 )
|
||||
{
|
||||
PredEntry *pe;
|
||||
Term t1 = Deref(ARG1);
|
||||
@ -5015,7 +5032,7 @@ p_static_clause(void)
|
||||
}
|
||||
|
||||
static Int /* $hidden_predicate(P) */
|
||||
p_nth_clause(void)
|
||||
p_nth_clause( USES_REGS1 )
|
||||
{
|
||||
PredEntry *pe;
|
||||
Term t1 = Deref(ARG1);
|
||||
@ -5073,7 +5090,7 @@ p_nth_clause(void)
|
||||
}
|
||||
|
||||
static Int /* $hidden_predicate(P) */
|
||||
p_continue_static_clause(void)
|
||||
p_continue_static_clause( USES_REGS1 )
|
||||
{
|
||||
PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
||||
yamop *ipc = (yamop *)IntegerOfTerm(ARG2);
|
||||
@ -5224,6 +5241,7 @@ index_ssz(StaticIndex *x)
|
||||
static Int
|
||||
static_statistics(PredEntry *pe)
|
||||
{
|
||||
CACHE_REGS
|
||||
UInt sz = 0, cls = 0, isz = 0;
|
||||
StaticClause *cl = ClauseCodeToStaticClause(pe->cs.p_code.FirstClause);
|
||||
|
||||
@ -5252,7 +5270,7 @@ static_statistics(PredEntry *pe)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_static_pred_statistics(void)
|
||||
p_static_pred_statistics( USES_REGS1 )
|
||||
{
|
||||
Int out;
|
||||
PredEntry *pe;
|
||||
@ -5272,7 +5290,7 @@ p_static_pred_statistics(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_predicate_erased_statistics(void)
|
||||
p_predicate_erased_statistics( USES_REGS1 )
|
||||
{
|
||||
UInt sz = 0, cls = 0;
|
||||
UInt isz = 0, icls = 0;
|
||||
@ -5307,7 +5325,7 @@ p_predicate_erased_statistics(void)
|
||||
|
||||
#ifdef DEBUG
|
||||
static Int
|
||||
p_predicate_lu_cps(void)
|
||||
p_predicate_lu_cps( USES_REGS1 )
|
||||
{
|
||||
return Yap_unify(ARG1, MkIntegerTerm(Yap_LiveCps)) &&
|
||||
Yap_unify(ARG2, MkIntegerTerm(Yap_FreedCps)) &&
|
||||
@ -5317,7 +5335,7 @@ p_predicate_lu_cps(void)
|
||||
#endif
|
||||
|
||||
static Int
|
||||
p_program_continuation(void)
|
||||
p_program_continuation( USES_REGS1 )
|
||||
{
|
||||
PredEntry *pe = EnvPreg((yamop *)((ENV_Parent(ENV))[E_CP]));
|
||||
if (pe->ModuleOfPred) {
|
||||
@ -5344,6 +5362,7 @@ p_program_continuation(void)
|
||||
static Term
|
||||
BuildActivePred(PredEntry *ap, CELL *vect)
|
||||
{
|
||||
CACHE_REGS
|
||||
UInt i;
|
||||
|
||||
if (!ap->ArityOfPE) {
|
||||
@ -5364,7 +5383,7 @@ BuildActivePred(PredEntry *ap, CELL *vect)
|
||||
}
|
||||
|
||||
static int
|
||||
UnifyPredInfo(PredEntry *pe, int start_arg) {
|
||||
UnifyPredInfo(PredEntry *pe, int start_arg USES_REGS) {
|
||||
UInt arity = pe->ArityOfPE;
|
||||
Term tmod, tname;
|
||||
|
||||
@ -5407,7 +5426,7 @@ ClauseId(yamop *ipc, PredEntry *pe)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_env_info(void)
|
||||
p_env_info( USES_REGS1 )
|
||||
{
|
||||
PredEntry *pe;
|
||||
CELL *env = LCL0-IntegerOfTerm(Deref(ARG1));
|
||||
@ -5427,18 +5446,18 @@ p_env_info(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_cpc_info(void)
|
||||
p_cpc_info( USES_REGS1 )
|
||||
{
|
||||
PredEntry *pe;
|
||||
yamop *ipc = (yamop *)IntegerOfTerm(Deref(ARG1));
|
||||
|
||||
pe = PREVOP(ipc,Osbpp)->u.Osbpp.p0;
|
||||
return UnifyPredInfo(pe, 2) &&
|
||||
return UnifyPredInfo(pe, 2 PASS_REGS) &&
|
||||
Yap_unify(ARG5,MkIntegerTerm(ClauseId(ipc,pe)));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_choicepoint_info(void)
|
||||
p_choicepoint_info( USES_REGS1 )
|
||||
{
|
||||
choiceptr cptr = (choiceptr)(LCL0-IntegerOfTerm(Deref(ARG1)));
|
||||
PredEntry *pe = NULL;
|
||||
@ -5608,7 +5627,7 @@ p_choicepoint_info(void)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return UnifyPredInfo(pe, 3) &&
|
||||
return UnifyPredInfo(pe, 3 PASS_REGS) &&
|
||||
Yap_unify(ARG2, taddr) &&
|
||||
Yap_unify(ARG6,t) &&
|
||||
Yap_unify(ARG7,MkIntegerTerm(ClauseId(ncl,pe)));
|
||||
@ -5617,6 +5636,7 @@ p_choicepoint_info(void)
|
||||
void
|
||||
Yap_InitCdMgr(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term cm = CurrentModule;
|
||||
|
||||
Yap_InitCPred("$compile_mode", 2, p_compile_mode, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
|
@ -9,7 +9,7 @@
|
||||
/* need to fix overflow handling */
|
||||
|
||||
static void
|
||||
mk_blob(int sz)
|
||||
mk_blob(int sz USES_REGS)
|
||||
{
|
||||
MP_INT *dst;
|
||||
|
||||
@ -24,7 +24,7 @@ mk_blob(int sz)
|
||||
}
|
||||
|
||||
static CELL *
|
||||
extend_blob(CELL *start, int sz)
|
||||
extend_blob(CELL *start, int sz USES_REGS)
|
||||
{
|
||||
UInt osize;
|
||||
MP_INT *dst;
|
||||
@ -44,9 +44,10 @@ extend_blob(CELL *start, int sz)
|
||||
X_API clause_list_t
|
||||
Yap_ClauseListInit(clause_list_t in)
|
||||
{
|
||||
CACHE_REGS
|
||||
in->n = 0;
|
||||
in->start = H;
|
||||
mk_blob(0);
|
||||
mk_blob(0 PASS_REGS);
|
||||
in->end = H;
|
||||
return in;
|
||||
}
|
||||
@ -56,6 +57,7 @@ Yap_ClauseListInit(clause_list_t in)
|
||||
X_API int
|
||||
Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
||||
{
|
||||
CACHE_REGS
|
||||
PredEntry *ap = (PredEntry *)pred;
|
||||
|
||||
/* fprintf(stderr,"cl=%p\n",clause); */
|
||||
@ -63,13 +65,13 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
||||
return FALSE;
|
||||
if (cl->n == 0) {
|
||||
void **ptr;
|
||||
if (!(ptr = (void **)extend_blob(cl->start,1))) return FALSE;
|
||||
if (!(ptr = (void **)extend_blob(cl->start,1 PASS_REGS))) return FALSE;
|
||||
ptr[0] = clause;
|
||||
} else if (cl->n == 1) {
|
||||
yamop **ptr;
|
||||
yamop *code_p, *fclause;
|
||||
|
||||
if (!(ptr = (yamop **)extend_blob(cl->start,2*(CELL)NEXTOP((yamop *)NULL,Otapl)/sizeof(CELL)-1))) return FALSE;
|
||||
if (!(ptr = (yamop **)extend_blob(cl->start,2*(CELL)NEXTOP((yamop *)NULL,Otapl)/sizeof(CELL)-1 PASS_REGS))) return FALSE;
|
||||
fclause = ptr[-1];
|
||||
code_p = (yamop *)(ptr-1);
|
||||
code_p->opc = Yap_opcode(_try_clause);
|
||||
@ -96,7 +98,7 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
||||
} else {
|
||||
yamop *code_p;
|
||||
|
||||
if (!(code_p = (yamop *)extend_blob(cl->start,((CELL)NEXTOP((yamop *)NULL,Otapl))/sizeof(CELL)))) return FALSE;
|
||||
if (!(code_p = (yamop *)extend_blob(cl->start,((CELL)NEXTOP((yamop *)NULL,Otapl))/sizeof(CELL) PASS_REGS))) return FALSE;
|
||||
code_p->opc = Yap_opcode(_trust);
|
||||
code_p->u.Otapl.d = clause;
|
||||
code_p->u.Otapl.s = ap->ArityOfPE;
|
||||
@ -126,6 +128,7 @@ Yap_ClauseListClose(clause_list_t cl)
|
||||
X_API int
|
||||
Yap_ClauseListDestroy(clause_list_t cl)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (cl->end != H)
|
||||
return FALSE;
|
||||
H = cl->start;
|
||||
@ -136,12 +139,13 @@ Yap_ClauseListDestroy(clause_list_t cl)
|
||||
X_API void *
|
||||
Yap_ClauseListToClause(clause_list_t cl)
|
||||
{
|
||||
CACHE_REGS
|
||||
void **ptr;
|
||||
if (cl->end != H)
|
||||
return NULL;
|
||||
if (cl->n != 1)
|
||||
return NULL;
|
||||
if (!(ptr = (void **)extend_blob(cl->start,0))) return NULL;
|
||||
if (!(ptr = (void **)extend_blob(cl->start,0 PASS_REGS))) return NULL;
|
||||
return ptr[-1];
|
||||
}
|
||||
|
||||
|
39
C/cmppreds.c
39
C/cmppreds.c
@ -28,8 +28,8 @@ static char SccsId[] = "%W% %G%";
|
||||
#include <wchar.h>
|
||||
|
||||
STATIC_PROTO(Int compare, (Term, Term));
|
||||
STATIC_PROTO(Int p_compare, (void));
|
||||
STATIC_PROTO(Int p_acomp, (void));
|
||||
STATIC_PROTO(Int p_compare, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_acomp, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int a_eq, (Term,Term));
|
||||
STATIC_PROTO(Int a_dif, (Term,Term));
|
||||
STATIC_PROTO(Int a_gt, (Term, Term));
|
||||
@ -77,7 +77,7 @@ cmp_atoms(Atom a1, Atom a2)
|
||||
static int compare_complex(register CELL *pt0, register CELL *pt0_end, register
|
||||
CELL *pt1)
|
||||
{
|
||||
|
||||
CACHE_REGS
|
||||
register CELL **to_visit = (CELL **)H;
|
||||
register int out = 0;
|
||||
|
||||
@ -447,7 +447,7 @@ int Yap_compare_terms(CELL d0, CELL d1)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_compare(void)
|
||||
p_compare( USES_REGS1 )
|
||||
{ /* compare(?Op,?T1,?T2) */
|
||||
Int r = compare(Deref(ARG2), Deref(ARG3));
|
||||
Atom p;
|
||||
@ -479,7 +479,7 @@ flt_cmp(Float dif)
|
||||
|
||||
|
||||
static inline Int
|
||||
a_cmp(Term t1, Term t2)
|
||||
a_cmp(Term t1, Term t2 USES_REGS)
|
||||
{
|
||||
ArithError = FALSE;
|
||||
if (IsVarTerm(t1)) {
|
||||
@ -596,20 +596,22 @@ a_cmp(Term t1, Term t2)
|
||||
|
||||
|
||||
static Int
|
||||
p_acomp(void)
|
||||
p_acomp( USES_REGS1 )
|
||||
{ /* $a_compare(?R,+X,+Y) */
|
||||
Term t1 = Deref(ARG1);
|
||||
Term t2 = Deref(ARG2);
|
||||
Int out;
|
||||
|
||||
out = a_cmp(t1, t2);
|
||||
out = a_cmp(t1, t2 PASS_REGS);
|
||||
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||
return out;
|
||||
}
|
||||
|
||||
static Int
|
||||
a_eq(Term t1, Term t2)
|
||||
{ /* A =:= B */
|
||||
{
|
||||
CACHE_REGS
|
||||
/* A =:= B */
|
||||
int out;
|
||||
|
||||
if (IsVarTerm(t1)) {
|
||||
@ -634,7 +636,7 @@ a_eq(Term t1, Term t2)
|
||||
return (FloatOfTerm(t2) == IntegerOfTerm(t1));
|
||||
}
|
||||
}
|
||||
out = a_cmp(t1,t2);
|
||||
out = a_cmp(t1,t2 PASS_REGS);
|
||||
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||
return out == 0;
|
||||
}
|
||||
@ -642,7 +644,8 @@ a_eq(Term t1, Term t2)
|
||||
static Int
|
||||
a_dif(Term t1, Term t2)
|
||||
{
|
||||
Int out = a_cmp(Deref(t1),Deref(t2));
|
||||
CACHE_REGS
|
||||
Int out = a_cmp(Deref(t1),Deref(t2) PASS_REGS);
|
||||
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||
return out != 0;
|
||||
}
|
||||
@ -650,7 +653,8 @@ a_dif(Term t1, Term t2)
|
||||
static Int
|
||||
a_gt(Term t1, Term t2)
|
||||
{ /* A > B */
|
||||
Int out = a_cmp(Deref(t1),Deref(t2));
|
||||
CACHE_REGS
|
||||
Int out = a_cmp(Deref(t1),Deref(t2) PASS_REGS);
|
||||
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||
return out > 0;
|
||||
}
|
||||
@ -658,7 +662,8 @@ a_gt(Term t1, Term t2)
|
||||
static Int
|
||||
a_ge(Term t1, Term t2)
|
||||
{ /* A >= B */
|
||||
Int out = a_cmp(Deref(t1),Deref(t2));
|
||||
CACHE_REGS
|
||||
Int out = a_cmp(Deref(t1),Deref(t2) PASS_REGS);
|
||||
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||
return out >= 0;
|
||||
}
|
||||
@ -666,7 +671,8 @@ a_ge(Term t1, Term t2)
|
||||
static Int
|
||||
a_lt(Term t1, Term t2)
|
||||
{ /* A < B */
|
||||
Int out = a_cmp(Deref(t1),Deref(t2));
|
||||
CACHE_REGS
|
||||
Int out = a_cmp(Deref(t1),Deref(t2) PASS_REGS);
|
||||
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||
return out < 0;
|
||||
}
|
||||
@ -674,7 +680,8 @@ a_lt(Term t1, Term t2)
|
||||
static Int
|
||||
a_le(Term t1, Term t2)
|
||||
{ /* A <= B */
|
||||
Int out = a_cmp(Deref(t1),Deref(t2));
|
||||
CACHE_REGS
|
||||
Int out = a_cmp(Deref(t1),Deref(t2) PASS_REGS);
|
||||
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||
return out <= 0;
|
||||
}
|
||||
@ -701,13 +708,13 @@ a_gen_le(Term t1, Term t2)
|
||||
static Int
|
||||
a_gen_gt(Term t1, Term t2)
|
||||
{
|
||||
return (compare(t1, t2) > 0);
|
||||
return compare(t1, t2) > 0;
|
||||
}
|
||||
|
||||
static Int
|
||||
a_gen_ge(Term t1, Term t2)
|
||||
{
|
||||
return (compare(t1, t2) >= 0);
|
||||
return compare(t1, t2) >= 0;
|
||||
}
|
||||
|
||||
|
||||
|
25
C/compiler.c
25
C/compiler.c
@ -322,6 +322,7 @@ adjust_current_commits(compiler_struct *cglobs) {
|
||||
|
||||
static int
|
||||
check_var(Term t, unsigned int level, Int argno, compiler_struct *cglobs) {
|
||||
CACHE_REGS
|
||||
int flags, new = FALSE;
|
||||
Ventry *v = (Ventry *)t;
|
||||
|
||||
@ -498,6 +499,7 @@ reset_vars(Ventry *vtable)
|
||||
static Term
|
||||
optimize_ce(Term t, unsigned int arity, unsigned int level, compiler_struct *cglobs)
|
||||
{
|
||||
CACHE_REGS
|
||||
CExpEntry *p = cglobs->common_exps;
|
||||
int cmp = 0;
|
||||
|
||||
@ -586,6 +588,7 @@ compile_sf_term(Term t, int argno, int level)
|
||||
inline static void
|
||||
c_args(Term app, unsigned int level, compiler_struct *cglobs)
|
||||
{
|
||||
CACHE_REGS
|
||||
Functor f = FunctorOfTerm(app);
|
||||
unsigned int Arity = ArityOfFunctor(f);
|
||||
unsigned int i;
|
||||
@ -608,6 +611,7 @@ c_args(Term app, unsigned int level, compiler_struct *cglobs)
|
||||
static int
|
||||
try_store_as_dbterm(Term t, Int argno, unsigned int arity, int level, compiler_struct *cglobs)
|
||||
{
|
||||
CACHE_REGS
|
||||
DBTerm *dbt;
|
||||
int g;
|
||||
CELL *h0 = H;
|
||||
@ -765,6 +769,7 @@ c_arg(Int argno, Term t, unsigned int arity, unsigned int level, compiler_struct
|
||||
} else if (IsRefTerm(t)) {
|
||||
PELOCK(40,cglobs->cint.CurrentPred);
|
||||
if (!(cglobs->cint.CurrentPred->PredFlags & (DynamicPredFlag|LogUpdatePredFlag))) {
|
||||
CACHE_REGS
|
||||
UNLOCK(cglobs->cint.CurrentPred->PELock);
|
||||
FAIL("can not compile data base reference",TYPE_ERROR_CALLABLE,t);
|
||||
} else {
|
||||
@ -819,6 +824,7 @@ c_arg(Int argno, Term t, unsigned int arity, unsigned int level, compiler_struct
|
||||
static void
|
||||
c_eq(Term t1, Term t2, compiler_struct *cglobs)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (t1 == t2) {
|
||||
Yap_emit(nop_op, Zero, Zero, &cglobs->cint);
|
||||
return;
|
||||
@ -914,6 +920,7 @@ c_eq(Term t1, Term t2, compiler_struct *cglobs)
|
||||
|
||||
static void
|
||||
c_test(Int Op, Term t1, compiler_struct *cglobs) {
|
||||
CACHE_REGS
|
||||
Term t = Deref(t1);
|
||||
|
||||
if (!IsVarTerm(t) || IsNewVar(t)) {
|
||||
@ -958,7 +965,8 @@ bip_cons Op,Xk,Ri,C
|
||||
static void
|
||||
c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler_struct *cglobs)
|
||||
{
|
||||
/* compile Z = X Op Y arithmetic function */
|
||||
CACHE_REGS
|
||||
/* compile Z = X Op Y arithmetic function */
|
||||
/* first we fetch the arguments */
|
||||
|
||||
if (IsVarTerm(t1)) {
|
||||
@ -1314,6 +1322,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
static void
|
||||
c_functor(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t1 = ArgOfTerm(1, Goal);
|
||||
Term t2 = ArgOfTerm(2, Goal);
|
||||
Term t3 = ArgOfTerm(3, Goal);
|
||||
@ -1439,6 +1448,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
Term M = ArgOfTerm(1, Goal);
|
||||
|
||||
if (IsVarTerm(M) || !IsAtomTerm(M)) {
|
||||
CACHE_REGS
|
||||
if (IsVarTerm(M)) {
|
||||
Yap_Error_TYPE = INSTANTIATION_ERROR;
|
||||
} else {
|
||||
@ -1455,8 +1465,10 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
if (IsVarTerm(Goal)) {
|
||||
Goal = Yap_MkApplTerm(FunctorCall, 1, &Goal);
|
||||
} else if (IsNumTerm(Goal)) {
|
||||
CACHE_REGS
|
||||
FAIL("goal can not be a number", TYPE_ERROR_CALLABLE, Goal);
|
||||
} else if (IsRefTerm(Goal)) {
|
||||
CACHE_REGS
|
||||
Yap_Error_TYPE = TYPE_ERROR_DBREF;
|
||||
Yap_Error_Term = Goal;
|
||||
FAIL("goal argument in static procedure can not be a data base reference", TYPE_ERROR_CALLABLE, Goal);
|
||||
@ -1647,6 +1659,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
*/
|
||||
if (looking_at_commit) {
|
||||
if (!optimizing_commit && !commitflag) {
|
||||
CACHE_REGS
|
||||
/* This instruction is placed before
|
||||
* the disjunction. This means that
|
||||
* the program counter must point
|
||||
@ -1734,6 +1747,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
return;
|
||||
}
|
||||
else if (f == FunctorNot || f == FunctorAltNot) {
|
||||
CACHE_REGS
|
||||
CELL label = (cglobs->labelno += 2);
|
||||
CELL end_label = (cglobs->labelno += 2);
|
||||
int save = cglobs->onlast;
|
||||
@ -1773,6 +1787,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
return;
|
||||
}
|
||||
else if (f == FunctorArrow) {
|
||||
CACHE_REGS
|
||||
Term commitvar;
|
||||
int save = cglobs->onlast;
|
||||
|
||||
@ -1884,6 +1899,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
#else
|
||||
else if (p->PredFlags & BinaryPredFlag) {
|
||||
#endif
|
||||
CACHE_REGS
|
||||
Term a1 = ArgOfTerm(1,Goal);
|
||||
|
||||
if (IsVarTerm(a1) && !IsNewVar(a1)) {
|
||||
@ -2296,6 +2312,7 @@ clear_bvarray(int var, CELL *bvarray
|
||||
nbit = ((CELL)1 << var);
|
||||
#ifdef DEBUG
|
||||
if (*bvarray & nbit) {
|
||||
CACHE_REGS
|
||||
/* someone had already marked this variable: complain */
|
||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||
Yap_Error_Term = TermNil;
|
||||
@ -2339,6 +2356,7 @@ static void
|
||||
push_bvmap(int label, PInstr *pcpc, compiler_struct *cglobs)
|
||||
{
|
||||
if (bvindex == MAX_DISJUNCTIONS) {
|
||||
CACHE_REGS
|
||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "Too many embedded disjunctions";
|
||||
@ -2362,6 +2380,7 @@ reset_bvmap(CELL *bvarray, int nperm, compiler_struct *cglobs)
|
||||
if (bvarray == NULL)
|
||||
|
||||
if (bvindex == 0) {
|
||||
CACHE_REGS
|
||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "No embedding in disjunctions";
|
||||
@ -2382,6 +2401,7 @@ static void
|
||||
pop_bvmap(CELL *bvarray, int nperm, compiler_struct *cglobs)
|
||||
{
|
||||
if (bvindex == 0) {
|
||||
CACHE_REGS
|
||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "Too few embedded disjunctions";
|
||||
@ -2652,6 +2672,7 @@ checktemp(Int arg, Int rn, compiler_vm_op ic, compiler_struct *cglobs)
|
||||
++target1;
|
||||
}
|
||||
if (target1 == cglobs->MaxCTemps) {
|
||||
CACHE_REGS
|
||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "too many temporaries";
|
||||
@ -2785,6 +2806,7 @@ c_layout(compiler_struct *cglobs)
|
||||
CheckUnsafe(cglobs->cint.CodeStart, cglobs);
|
||||
#ifdef DEBUG
|
||||
if (cglobs->pbvars != nperm) {
|
||||
CACHE_REGS
|
||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "wrong number of variables found in bitmap";
|
||||
@ -3321,6 +3343,7 @@ c_optimize(PInstr *pc)
|
||||
yamop *
|
||||
Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
|
||||
{ /* compile a prolog clause, copy of clause myst be in ARG1 */
|
||||
CACHE_REGS
|
||||
/* returns address of code for clause */
|
||||
Term head, body;
|
||||
yamop *acode;
|
||||
|
@ -111,6 +111,7 @@ AllocCMem (UInt size, struct intermediates *cip)
|
||||
else
|
||||
blksz = CMEM_BLK_SIZE;
|
||||
if (!cip->blks) {
|
||||
CACHE_REGS
|
||||
if (Yap_CMemFirstBlock) {
|
||||
p = Yap_CMemFirstBlock;
|
||||
blksz = Yap_CMemFirstBlockSz;
|
||||
@ -130,6 +131,7 @@ AllocCMem (UInt size, struct intermediates *cip)
|
||||
} else {
|
||||
p = (struct mem_blk *)Yap_AllocCodeSpace(blksz);
|
||||
if (!p) {
|
||||
CACHE_REGS
|
||||
Yap_Error_Size = size;
|
||||
save_machine_regs();
|
||||
siglongjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
@ -150,6 +152,7 @@ AllocCMem (UInt size, struct intermediates *cip)
|
||||
p = cip->freep;
|
||||
cip->freep += size;
|
||||
if (ASP <= CellPtr (cip->freep) + 256) {
|
||||
CACHE_REGS
|
||||
Yap_Error_Size = 256+((char *)cip->freep - (char *)H);
|
||||
save_machine_regs();
|
||||
siglongjmp(cip->CompilerBotch, OUT_OF_STACK_BOTCH);
|
||||
@ -162,6 +165,7 @@ void
|
||||
Yap_ReleaseCMem (struct intermediates *cip)
|
||||
{
|
||||
#if USE_SYSTEM_MALLOC
|
||||
CACHE_REGS
|
||||
struct mem_blk *p = cip->blks;
|
||||
while (p) {
|
||||
struct mem_blk *nextp = p->u.next;
|
||||
@ -843,6 +847,7 @@ static char *opformat[] =
|
||||
void
|
||||
Yap_ShowCode (struct intermediates *cint)
|
||||
{
|
||||
CACHE_REGS
|
||||
CELL *oldH = H;
|
||||
struct PSEUDO *cpc;
|
||||
|
||||
|
49
C/corout.c
49
C/corout.c
@ -30,7 +30,7 @@ static char SccsId[]="%W% %G%";
|
||||
#ifdef COROUTINING
|
||||
|
||||
/* check if variable was there */
|
||||
static Term AddVarIfNotThere(Term var , Term dest)
|
||||
static Term AddVarIfNotThere(Term var , Term dest USES_REGS)
|
||||
{
|
||||
Term test = dest;
|
||||
while (test != TermNil) {
|
||||
@ -45,7 +45,7 @@ static Term AddVarIfNotThere(Term var , Term dest)
|
||||
static int can_unify_complex(register CELL *pt0,
|
||||
register CELL *pt0_end,
|
||||
register CELL *pt1,
|
||||
Term *Vars)
|
||||
Term *Vars USES_REGS)
|
||||
{
|
||||
|
||||
/* This is really just unification, folks */
|
||||
@ -73,7 +73,7 @@ static int can_unify_complex(register CELL *pt0,
|
||||
if (IsVarTerm(d1)) {
|
||||
if (d0 != d1) {
|
||||
/* we need to suspend on both variables ! */
|
||||
*Vars = AddVarIfNotThere(d0, AddVarIfNotThere(d1,*Vars));
|
||||
*Vars = AddVarIfNotThere(d0, AddVarIfNotThere(d1,*Vars PASS_REGS) PASS_REGS);
|
||||
/* bind the two variables, we would have to do that to unify
|
||||
them */
|
||||
if (d1 > d0) { /* youngest */
|
||||
@ -88,13 +88,13 @@ static int can_unify_complex(register CELL *pt0,
|
||||
}
|
||||
else {
|
||||
/* oh no, some more variables! */
|
||||
*Vars = AddVarIfNotThere(d0, *Vars);
|
||||
*Vars = AddVarIfNotThere(d0, *Vars PASS_REGS);
|
||||
}
|
||||
/* now bind it */
|
||||
Bind_Global((CELL *)d0, d1);
|
||||
/* continue the loop */
|
||||
} else if (IsVarTerm(d1)) {
|
||||
*Vars = AddVarIfNotThere(d1, *Vars);
|
||||
*Vars = AddVarIfNotThere(d1, *Vars PASS_REGS);
|
||||
/* and bind it */
|
||||
Bind_Global((CELL *)d1, d0);
|
||||
/* continue the loop */
|
||||
@ -236,7 +236,7 @@ static int can_unify_complex(register CELL *pt0,
|
||||
}
|
||||
|
||||
static int
|
||||
can_unify(Term t1, Term t2, Term *Vars)
|
||||
can_unify(Term t1, Term t2, Term *Vars USES_REGS)
|
||||
{
|
||||
t1 = Deref(t1);
|
||||
t2 = Deref(t2);
|
||||
@ -274,7 +274,7 @@ can_unify(Term t1, Term t2, Term *Vars)
|
||||
} else if (IsPairTerm(t1)) {
|
||||
if (IsPairTerm(t2)) {
|
||||
return(can_unify_complex(RepPair(t1)-1, RepPair(t1)+1,
|
||||
RepPair(t2)-1, Vars));
|
||||
RepPair(t2)-1, Vars PASS_REGS));
|
||||
} else return FALSE;
|
||||
} else {
|
||||
Functor f = FunctorOfTerm(t1);
|
||||
@ -303,14 +303,14 @@ can_unify(Term t1, Term t2, Term *Vars)
|
||||
/* Two complex terms with the same functor */
|
||||
return can_unify_complex(RepAppl(t1),
|
||||
RepAppl(t1)+ArityOfFunctor(f),
|
||||
RepAppl(t2), Vars);
|
||||
RepAppl(t2), Vars PASS_REGS);
|
||||
}
|
||||
}
|
||||
|
||||
/* This routine verifies whether a complex has variables. */
|
||||
static int non_ground_complex(register CELL *pt0,
|
||||
register CELL *pt0_end,
|
||||
Term *Var)
|
||||
Term *Var USES_REGS)
|
||||
{
|
||||
|
||||
register CELL **to_visit = (CELL **)Yap_PreAllocCodeSpace();
|
||||
@ -428,7 +428,7 @@ static int non_ground_complex(register CELL *pt0,
|
||||
}
|
||||
|
||||
static int
|
||||
non_ground(Term t, Term *Var)
|
||||
non_ground(Term t, Term *Var USES_REGS)
|
||||
{
|
||||
int out = -1;
|
||||
while (out < 0) {
|
||||
@ -441,7 +441,7 @@ non_ground(Term t, Term *Var)
|
||||
if (IsPrimitiveTerm(t)) {
|
||||
return FALSE;
|
||||
} else if (IsPairTerm(t)) {
|
||||
out = non_ground_complex(RepPair(t)-1, RepPair(t)+1, Var);
|
||||
out = non_ground_complex(RepPair(t)-1, RepPair(t)+1, Var PASS_REGS);
|
||||
if (out >= 0)
|
||||
return out;
|
||||
} else {
|
||||
@ -451,7 +451,7 @@ non_ground(Term t, Term *Var)
|
||||
}
|
||||
out = non_ground_complex(RepAppl(t),
|
||||
RepAppl(t)+ArityOfFunctor(FunctorOfTerm(t)),
|
||||
Var);
|
||||
Var PASS_REGS);
|
||||
if (out >= 0)
|
||||
return out;
|
||||
}
|
||||
@ -467,11 +467,11 @@ non_ground(Term t, Term *Var)
|
||||
|
||||
/* check whether the two terms unify and return what variables should
|
||||
be bound before the terms are exactly equal */
|
||||
static Int p_can_unify(void)
|
||||
static Int p_can_unify( USES_REGS1 )
|
||||
{
|
||||
#ifdef COROUTINING
|
||||
Term r = TermNil;
|
||||
if (!can_unify(ARG1, ARG2, &r))
|
||||
if (!can_unify(ARG1, ARG2, &r PASS_REGS))
|
||||
return FALSE;
|
||||
return Yap_unify(ARG3, r);
|
||||
#else
|
||||
@ -480,11 +480,11 @@ static Int p_can_unify(void)
|
||||
}
|
||||
|
||||
/* if the term is not ground return a variable in the term */
|
||||
static Int p_non_ground(void)
|
||||
static Int p_non_ground( USES_REGS1 )
|
||||
{
|
||||
#ifdef COROUTINING
|
||||
Term r = TermNil;
|
||||
if (!non_ground(ARG1, &r))
|
||||
if (!non_ground(ARG1, &r PASS_REGS))
|
||||
return(FALSE);
|
||||
return (Yap_unify(ARG2, r));
|
||||
#else
|
||||
@ -493,7 +493,7 @@ static Int p_non_ground(void)
|
||||
}
|
||||
|
||||
/* if the term is not ground return a variable in the term */
|
||||
static Int p_coroutining(void)
|
||||
static Int p_coroutining( USES_REGS1 )
|
||||
{
|
||||
#ifdef COROUTINING
|
||||
return(TRUE);
|
||||
@ -504,25 +504,26 @@ static Int p_coroutining(void)
|
||||
|
||||
#if COROUTINING
|
||||
static Term
|
||||
ListOfWokenGoals(void) {
|
||||
ListOfWokenGoals( USES_REGS1 ) {
|
||||
return Yap_ReadTimedVar(WokenGoals);
|
||||
}
|
||||
|
||||
Term
|
||||
Yap_ListOfWokenGoals(void) {
|
||||
return ListOfWokenGoals();
|
||||
CACHE_REGS
|
||||
return ListOfWokenGoals( PASS_REGS1 );
|
||||
}
|
||||
#endif
|
||||
|
||||
/* return a list of awoken goals */
|
||||
static Int p_awoken_goals(void)
|
||||
static Int p_awoken_goals( USES_REGS1 )
|
||||
{
|
||||
#ifdef COROUTINING
|
||||
Term WGs = Yap_ReadTimedVar(WokenGoals);
|
||||
if (WGs == TermNil) {
|
||||
return(FALSE);
|
||||
}
|
||||
WGs = ListOfWokenGoals();
|
||||
WGs = ListOfWokenGoals( PASS_REGS1 );
|
||||
Yap_UpdateTimedVar(WokenGoals, TermNil);
|
||||
return(Yap_unify(ARG1,WGs));
|
||||
#else
|
||||
@ -531,7 +532,7 @@ static Int p_awoken_goals(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_yap_has_rational_trees(void)
|
||||
p_yap_has_rational_trees( USES_REGS1 )
|
||||
{
|
||||
#if RATIONAL_TREES
|
||||
return TRUE;
|
||||
@ -541,7 +542,7 @@ p_yap_has_rational_trees(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_yap_has_coroutining(void)
|
||||
p_yap_has_coroutining( USES_REGS1 )
|
||||
{
|
||||
#if COROUTINING
|
||||
return TRUE;
|
||||
@ -551,7 +552,7 @@ p_yap_has_coroutining(void)
|
||||
}
|
||||
|
||||
void
|
||||
Yap_InitCoroutPreds(void)
|
||||
Yap_InitCoroutPreds( void )
|
||||
{
|
||||
#ifdef COROUTINING
|
||||
Atom at;
|
||||
|
@ -5,11 +5,13 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void cut_c_initialize(void){
|
||||
CACHE_REGS
|
||||
Yap_REGS.CUT_C_TOP=(cut_c_str_ptr)Yap_LocalBase;
|
||||
}
|
||||
|
||||
/*Removes a choice_point from the stack*/
|
||||
void cut_c_pop(void){
|
||||
CACHE_REGS
|
||||
cut_c_str_ptr to_delete = NULL;
|
||||
if (((CELL *)Yap_REGS.CUT_C_TOP) == ((CELL *)Yap_LocalBase))
|
||||
{
|
||||
@ -26,6 +28,7 @@ void cut_c_pop(void){
|
||||
|
||||
/*Insert a choice_point in the stack*/
|
||||
void cut_c_push(cut_c_str_ptr new_top){
|
||||
CACHE_REGS
|
||||
new_top->before = Yap_REGS.CUT_C_TOP;
|
||||
Yap_REGS.CUT_C_TOP=new_top;
|
||||
return;
|
||||
|
@ -24,15 +24,15 @@ static char SccsId[] = "%W% %G%";
|
||||
|
||||
#include "Yatom.h"
|
||||
|
||||
STD_PROTO(static Int p_get_depth_limit, (void));
|
||||
STD_PROTO(static Int p_set_depth_limit, (void));
|
||||
STD_PROTO(static Int p_get_depth_limit, ( USES_REGS1 ));
|
||||
STD_PROTO(static Int p_set_depth_limit, ( USES_REGS1 ));
|
||||
|
||||
static Int p_get_depth_limit(void)
|
||||
static Int p_get_depth_limit( USES_REGS1 )
|
||||
{
|
||||
return(Yap_unify_constant(ARG1, MkIntTerm(IntOfTerm(DEPTH/2))));
|
||||
}
|
||||
|
||||
static Int p_set_depth_limit(void)
|
||||
static Int p_set_depth_limit( USES_REGS1 )
|
||||
{
|
||||
Term d = Deref(ARG1);
|
||||
|
||||
@ -51,7 +51,7 @@ static Int p_set_depth_limit(void)
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static Int p_set_depth_limit_for_next_call(void)
|
||||
static Int p_set_depth_limit_for_next_call( USES_REGS1 )
|
||||
{
|
||||
Term d = Deref(ARG1);
|
||||
|
||||
|
35
C/errors.c
35
C/errors.c
@ -32,8 +32,8 @@
|
||||
|
||||
#ifdef DEBUG
|
||||
STATIC_PROTO (int hidden, (Atom));
|
||||
STATIC_PROTO (int legal_env, (CELL *));
|
||||
void STD_PROTO (DumpActiveGoals, (void));
|
||||
STATIC_PROTO (int legal_env, (CELL * CACHE_TYPE));
|
||||
void STD_PROTO (DumpActiveGoals, ( CACHE_TYPE1 ));
|
||||
STATIC_PROTO (void detect_bug_location, (yamop *,find_pred_type,char *, int));
|
||||
|
||||
#define ONHEAP(ptr) (CellPtr(ptr) >= CellPtr(Yap_HeapBase) && CellPtr(ptr) < CellPtr(HeapTop))
|
||||
@ -56,7 +56,7 @@ hidden (Atom at)
|
||||
}
|
||||
|
||||
static int
|
||||
legal_env (CELL *ep)
|
||||
legal_env (CELL *ep USES_REGS)
|
||||
{
|
||||
CELL cp, ps;
|
||||
PredEntry *pe;
|
||||
@ -77,7 +77,7 @@ legal_env (CELL *ep)
|
||||
}
|
||||
|
||||
void
|
||||
DumpActiveGoals (void)
|
||||
DumpActiveGoals ( USES_REGS1 )
|
||||
{
|
||||
/* try to dump active goals */
|
||||
CELL *ep = YENV; /* and current environment */
|
||||
@ -86,9 +86,9 @@ DumpActiveGoals (void)
|
||||
PredEntry *pe;
|
||||
int first = 1;
|
||||
|
||||
if (legal_env (YENV) && YENV < ENV)
|
||||
if (legal_env (YENV PASS_REGS) && YENV < ENV)
|
||||
ep = YENV;
|
||||
else if (legal_env (ENV))
|
||||
else if (legal_env (ENV PASS_REGS))
|
||||
ep = ENV;
|
||||
while (TRUE)
|
||||
{
|
||||
@ -226,7 +226,7 @@ detect_bug_location(yamop *yap_pc, find_pred_type where_from, char *tp, int psiz
|
||||
}
|
||||
|
||||
static int
|
||||
handled_exception(void)
|
||||
handled_exception( USES_REGS1 )
|
||||
{
|
||||
yamop *pos = NEXTOP(PredDollarCatch->cs.p_code.TrueCodeOfPred,l);
|
||||
int found_handler = FALSE;
|
||||
@ -251,7 +251,7 @@ handled_exception(void)
|
||||
|
||||
|
||||
static void
|
||||
dump_stack(void)
|
||||
dump_stack( USES_REGS1 )
|
||||
{
|
||||
choiceptr b_ptr = B;
|
||||
CELL *env_ptr = ENV;
|
||||
@ -260,7 +260,7 @@ dump_stack(void)
|
||||
int max_count = 200;
|
||||
|
||||
/* check if handled */
|
||||
if (handled_exception())
|
||||
if (handled_exception( PASS_REGS1 ))
|
||||
return;
|
||||
#if DEBUG
|
||||
fprintf(stderr,"%% YAP regs: P=%p, CP=%p, ASP=%p, H=%p, TR=%p, HeapTop=%p\n",P,CP,ASP,H,TR,HeapTop);
|
||||
@ -347,8 +347,9 @@ dump_stack(void)
|
||||
static void
|
||||
error_exit_yap (int value)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (!(Yap_PrologMode & BootMode)) {
|
||||
dump_stack();
|
||||
dump_stack( PASS_REGS1 );
|
||||
#if DEBUG
|
||||
#endif
|
||||
}
|
||||
@ -362,6 +363,7 @@ error_exit_yap (int value)
|
||||
void
|
||||
Yap_bug_location(yamop *pc)
|
||||
{
|
||||
CACHE_REGS
|
||||
detect_bug_location(pc, FIND_PRED_FROM_ANYWHERE, (char *)H, 256);
|
||||
fprintf(stderr,"%s\n",(char *)H);
|
||||
}
|
||||
@ -377,6 +379,7 @@ static char tmpbuf[YAP_BUF_SIZE];
|
||||
yamop *
|
||||
Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
{
|
||||
CACHE_REGS
|
||||
va_list ap;
|
||||
CELL nt[3];
|
||||
Functor fun;
|
||||
@ -492,7 +495,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
error_exit_yap (1);
|
||||
}
|
||||
#ifdef DEBUGX
|
||||
DumpActiveGoals();
|
||||
DumpActiveGoals( USES_REGS1 );
|
||||
#endif /* DEBUG */
|
||||
switch (type) {
|
||||
case INTERNAL_ERROR:
|
||||
@ -1050,7 +1053,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
int i;
|
||||
Term ti[1];
|
||||
|
||||
dump_stack();
|
||||
dump_stack( PASS_REGS1 );
|
||||
ti[0] = MkAtomTerm(AtomCodeSpace);
|
||||
i = strlen(tmpbuf);
|
||||
nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti);
|
||||
@ -1065,7 +1068,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
int i;
|
||||
Term ti[1];
|
||||
|
||||
dump_stack();
|
||||
dump_stack( PASS_REGS1 );
|
||||
i = strlen(tmpbuf);
|
||||
ti[0] = MkAtomTerm(AtomStack);
|
||||
nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti);
|
||||
@ -1080,7 +1083,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
int i;
|
||||
Term ti[1];
|
||||
|
||||
dump_stack();
|
||||
dump_stack( PASS_REGS1 );
|
||||
i = strlen(tmpbuf);
|
||||
ti[0] = MkAtomTerm(AtomAttributes);
|
||||
nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti);
|
||||
@ -1095,7 +1098,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
int i;
|
||||
Term ti[1];
|
||||
|
||||
dump_stack();
|
||||
dump_stack( PASS_REGS1 );
|
||||
i = strlen(tmpbuf);
|
||||
tp = tmpbuf+i;
|
||||
ti[0] = MkAtomTerm(AtomUnificationStack);
|
||||
@ -1110,7 +1113,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
int i;
|
||||
Term ti[1];
|
||||
|
||||
dump_stack();
|
||||
dump_stack( PASS_REGS1 );
|
||||
i = strlen(tmpbuf);
|
||||
ti[0] = MkAtomTerm(AtomTrail);
|
||||
nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti);
|
||||
|
16
C/eval.c
16
C/eval.c
@ -37,7 +37,7 @@ static char SccsId[] = "%W% %G%";
|
||||
yap_error_number Yap_matherror = YAP_NO_ERROR;
|
||||
|
||||
static Term
|
||||
Eval(Term t)
|
||||
Eval(Term t USES_REGS)
|
||||
{
|
||||
if (IsVarTerm(t)) {
|
||||
ArithError = TRUE;
|
||||
@ -78,7 +78,7 @@ Eval(Term t)
|
||||
RepAtom(name)->StrOfAE,n);
|
||||
}
|
||||
*RepAppl(t) = (CELL)AtomFoundVar;
|
||||
t1 = Eval(ArgOfTerm(1,t));
|
||||
t1 = Eval(ArgOfTerm(1,t) PASS_REGS);
|
||||
if (t1 == 0L) {
|
||||
*RepAppl(t) = (CELL)fun;
|
||||
return FALSE;
|
||||
@ -87,7 +87,7 @@ Eval(Term t)
|
||||
*RepAppl(t) = (CELL)fun;
|
||||
return Yap_eval_unary(p->FOfEE, t1);
|
||||
}
|
||||
t2 = Eval(ArgOfTerm(2,t));
|
||||
t2 = Eval(ArgOfTerm(2,t) PASS_REGS);
|
||||
*RepAppl(t) = (CELL)fun;
|
||||
if (t2 == 0L)
|
||||
return FALSE;
|
||||
@ -98,14 +98,15 @@ Eval(Term t)
|
||||
return Yap_ArithError(TYPE_ERROR_EVALUABLE, t,
|
||||
"string must contain a single character to be evaluated as an arithmetic expression");
|
||||
}
|
||||
return Eval(HeadOfTerm(t));
|
||||
return Eval(HeadOfTerm(t) PASS_REGS);
|
||||
}
|
||||
}
|
||||
|
||||
Term
|
||||
Yap_InnerEval(Term t)
|
||||
{
|
||||
return Eval(t);
|
||||
CACHE_REGS
|
||||
return Eval(t PASS_REGS);
|
||||
}
|
||||
|
||||
#ifdef BEAM
|
||||
@ -125,11 +126,11 @@ BEAM_is(void)
|
||||
#endif
|
||||
|
||||
static Int
|
||||
p_is(void)
|
||||
p_is( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
Term out = 0L;
|
||||
|
||||
while (!(out = Eval(Deref(ARG2)))) {
|
||||
while (!(out = Eval(Deref(ARG2) PASS_REGS))) {
|
||||
if (Yap_Error_TYPE == RESOURCE_ERROR_STACK) {
|
||||
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||
if (!Yap_gcl(Yap_Error_Size, 2, ENV, CP)) {
|
||||
@ -147,6 +148,7 @@ p_is(void)
|
||||
Int
|
||||
Yap_ArithError(yap_error_number type, Term where, char *format,...)
|
||||
{
|
||||
CACHE_REGS
|
||||
va_list ap;
|
||||
|
||||
ArithError = TRUE;
|
||||
|
248
C/globals.c
248
C/globals.c
@ -102,7 +102,7 @@ CreateNewArena(CELL *ptr, UInt size)
|
||||
}
|
||||
|
||||
static Term
|
||||
NewArena(UInt size, UInt arity, CELL *where)
|
||||
NewArena(UInt size, UInt arity, CELL *where USES_REGS)
|
||||
{
|
||||
Term t;
|
||||
UInt new_size;
|
||||
@ -128,7 +128,7 @@ NewArena(UInt size, UInt arity, CELL *where)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_allocate_arena(void)
|
||||
p_allocate_arena( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
if (IsVarTerm(t)) {
|
||||
@ -138,12 +138,12 @@ p_allocate_arena(void)
|
||||
Yap_Error(TYPE_ERROR_INTEGER,t,"allocate_arena");
|
||||
return FALSE;
|
||||
}
|
||||
return Yap_unify(ARG2,NewArena(IntegerOfTerm(t), 1, NULL));
|
||||
return Yap_unify(ARG2,NewArena(IntegerOfTerm(t), 1, NULL PASS_REGS));
|
||||
}
|
||||
|
||||
|
||||
static Int
|
||||
p_default_arena_size(void)
|
||||
p_default_arena_size( USES_REGS1 )
|
||||
{
|
||||
return Yap_unify(ARG1,MkIntegerTerm(ArenaSz(GlobalArena)));
|
||||
}
|
||||
@ -152,11 +152,12 @@ p_default_arena_size(void)
|
||||
void
|
||||
Yap_AllocateDefaultArena(Int gsize, Int attsize)
|
||||
{
|
||||
GlobalArena = NewArena(gsize, 2, NULL);
|
||||
CACHE_REGS
|
||||
GlobalArena = NewArena(gsize, 2, NULL PASS_REGS);
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_cps(UInt size)
|
||||
adjust_cps(UInt size USES_REGS)
|
||||
{
|
||||
/* adjust possible back pointers in choice-point stack */
|
||||
choiceptr b_ptr = B;
|
||||
@ -168,7 +169,7 @@ adjust_cps(UInt size)
|
||||
|
||||
|
||||
static int
|
||||
GrowArena(Term arena, CELL *pt, UInt old_size, UInt size, UInt arity)
|
||||
GrowArena(Term arena, CELL *pt, UInt old_size, UInt size, UInt arity USES_REGS)
|
||||
{
|
||||
ArenaOverflows++;
|
||||
if (size == 0) {
|
||||
@ -192,9 +193,9 @@ GrowArena(Term arena, CELL *pt, UInt old_size, UInt size, UInt arity)
|
||||
arena = XREGS[arity+1];
|
||||
/* we don't know if the GC added junk on top of the global */
|
||||
pt = ArenaLimit(arena);
|
||||
return GrowArena(arena, pt, old_size, size, arity);
|
||||
return GrowArena(arena, pt, old_size, size, arity PASS_REGS);
|
||||
}
|
||||
adjust_cps(size);
|
||||
adjust_cps(size PASS_REGS);
|
||||
H += size;
|
||||
} else {
|
||||
XREGS[arity+1] = arena;
|
||||
@ -220,6 +221,7 @@ GrowArena(Term arena, CELL *pt, UInt old_size, UInt size, UInt arity)
|
||||
CELL *
|
||||
Yap_GetFromArena(Term *arenap, UInt cells, UInt arity)
|
||||
{
|
||||
CACHE_REGS
|
||||
restart:
|
||||
{
|
||||
Term arena = *arenap;
|
||||
@ -234,7 +236,7 @@ Yap_GetFromArena(Term *arenap, UInt cells, UInt arity)
|
||||
return base;
|
||||
}
|
||||
if (base+cells > max-1024) {
|
||||
if (!GrowArena(arena, max, old_sz, old_sz+sizeof(CELL)*1024, arity))
|
||||
if (!GrowArena(arena, max, old_sz, old_sz+sizeof(CELL)*1024, arity PASS_REGS))
|
||||
return NULL;
|
||||
goto restart;
|
||||
}
|
||||
@ -247,7 +249,7 @@ Yap_GetFromArena(Term *arenap, UInt cells, UInt arity)
|
||||
}
|
||||
|
||||
static void
|
||||
CloseArena(CELL *oldH, CELL *oldHB, CELL *oldASP, Term *oldArenaP, UInt old_size)
|
||||
CloseArena(CELL *oldH, CELL *oldHB, CELL *oldASP, Term *oldArenaP, UInt old_size USES_REGS)
|
||||
{
|
||||
UInt new_size;
|
||||
|
||||
@ -261,7 +263,7 @@ CloseArena(CELL *oldH, CELL *oldHB, CELL *oldASP, Term *oldArenaP, UInt old_size
|
||||
}
|
||||
|
||||
static inline void
|
||||
clean_dirty_tr(tr_fr_ptr TR0) {
|
||||
clean_dirty_tr(tr_fr_ptr TR0 USES_REGS) {
|
||||
if (TR != TR0) {
|
||||
tr_fr_ptr pt = TR0;
|
||||
|
||||
@ -282,7 +284,7 @@ clean_dirty_tr(tr_fr_ptr TR0) {
|
||||
}
|
||||
|
||||
static int
|
||||
copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int copy_att_vars, CELL *ptf, CELL *HLow)
|
||||
copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int copy_att_vars, CELL *ptf, CELL *HLow USES_REGS)
|
||||
{
|
||||
|
||||
struct cp_frame *to_visit0, *to_visit = (struct cp_frame *)Yap_PreAllocCodeSpace();
|
||||
@ -478,7 +480,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
|
||||
CELL new;
|
||||
|
||||
bp = to_visit;
|
||||
if (!attas[ExtFromCell(ptd0)].copy_term_op(ptd0, &bp, ptf)) {
|
||||
if (!attas[ExtFromCell(ptd0)].copy_term_op(ptd0, &bp, ptf PASS_REGS)) {
|
||||
goto overflow;
|
||||
}
|
||||
to_visit = bp;
|
||||
@ -527,7 +529,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
|
||||
|
||||
/* restore our nice, friendly, term to its original state */
|
||||
HB = HB0;
|
||||
clean_dirty_tr(TR0);
|
||||
clean_dirty_tr(TR0 PASS_REGS);
|
||||
/* follow chain of multi-assigned variables */
|
||||
close_attvar_chain(dvarsmin, dvarsmax);
|
||||
return 0;
|
||||
@ -591,7 +593,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
|
||||
}
|
||||
|
||||
static Term
|
||||
CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Term *newarena, UInt min_grow)
|
||||
CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Term *newarena, UInt min_grow USES_REGS)
|
||||
{
|
||||
UInt old_size = ArenaSz(arena);
|
||||
CELL *oldH = H;
|
||||
@ -612,14 +614,14 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
|
||||
*H = t;
|
||||
Hi = H+1;
|
||||
H += 2;
|
||||
if ((res = copy_complex_term(Hi-2, Hi-1, share, copy_att_vars, Hi, Hi)) < 0)
|
||||
if ((res = copy_complex_term(Hi-2, Hi-1, share, copy_att_vars, Hi, Hi PASS_REGS)) < 0)
|
||||
goto error_handler;
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||
return Hi[0];
|
||||
}
|
||||
#endif
|
||||
if (share && VarOfTerm(t) > ArenaPt(arena)) {
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||
return t;
|
||||
}
|
||||
tn = MkVarTerm();
|
||||
@ -627,7 +629,7 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
|
||||
res = -1;
|
||||
goto error_handler;
|
||||
}
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||
return tn;
|
||||
} else if (IsAtomOrIntTerm(t)) {
|
||||
return t;
|
||||
@ -645,10 +647,10 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
|
||||
Hi = H;
|
||||
tf = AbsPair(H);
|
||||
H += 2;
|
||||
if ((res = copy_complex_term(ap-1, ap+1, share, copy_att_vars, Hi, Hi)) < 0) {
|
||||
if ((res = copy_complex_term(ap-1, ap+1, share, copy_att_vars, Hi, Hi PASS_REGS)) < 0) {
|
||||
goto error_handler;
|
||||
}
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||
return tf;
|
||||
} else {
|
||||
Functor f;
|
||||
@ -669,7 +671,7 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
|
||||
if (IsExtensionFunctor(f)) {
|
||||
switch((CELL)f) {
|
||||
case (CELL)FunctorDBRef:
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||
return t;
|
||||
case (CELL)FunctorLongInt:
|
||||
if (H > ASP - (MIN_ARENA_SIZE+3)) {
|
||||
@ -715,16 +717,16 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
|
||||
res = -1;
|
||||
goto error_handler;
|
||||
}
|
||||
if ((res = copy_complex_term(ap, ap+ArityOfFunctor(f), share, copy_att_vars, HB0+1, HB0)) < 0) {
|
||||
if ((res = copy_complex_term(ap, ap+ArityOfFunctor(f), share, copy_att_vars, HB0+1, HB0 PASS_REGS)) < 0) {
|
||||
goto error_handler;
|
||||
}
|
||||
}
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||
return tf;
|
||||
}
|
||||
error_handler:
|
||||
H = HB;
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||
XREGS[arity+1] = t;
|
||||
XREGS[arity+2] = arena;
|
||||
XREGS[arity+3] = (CELL)newarena;
|
||||
@ -737,7 +739,7 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
|
||||
case -1:
|
||||
if (arena == GlobalArena)
|
||||
GlobalArenaOverflows++;
|
||||
if (!GrowArena(arena, old_top, old_size, min_grow, arity+3)) {
|
||||
if (!GrowArena(arena, old_top, old_size, min_grow, arity+3 PASS_REGS)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return 0L;
|
||||
}
|
||||
@ -760,7 +762,7 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
|
||||
}
|
||||
|
||||
static Term
|
||||
CreateTermInArena(Term arena, Atom Na, UInt Nar, UInt arity, Term *newarena, Term init)
|
||||
CreateTermInArena(Term arena, Atom Na, UInt Nar, UInt arity, Term *newarena, Term init USES_REGS)
|
||||
{
|
||||
UInt old_size = ArenaSz(arena);
|
||||
CELL *oldH = H;
|
||||
@ -781,7 +783,7 @@ CreateTermInArena(Term arena, Atom Na, UInt Nar, UInt arity, Term *newarena, Ter
|
||||
if (H > ASP-MIN_ARENA_SIZE) {
|
||||
/* overflow */
|
||||
H = HB;
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||
XREGS[arity+1] = arena;
|
||||
XREGS[arity+2] = (CELL)newarena;
|
||||
{
|
||||
@ -791,7 +793,7 @@ CreateTermInArena(Term arena, Atom Na, UInt Nar, UInt arity, Term *newarena, Ter
|
||||
HB = oldHB;
|
||||
if (arena == GlobalArena)
|
||||
GlobalArenaOverflows++;
|
||||
if (!GrowArena(arena, old_top, old_size, Nar*sizeof(CELL), arity+2)) {
|
||||
if (!GrowArena(arena, old_top, old_size, Nar*sizeof(CELL), arity+2 PASS_REGS)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while creating large global term");
|
||||
return 0L;
|
||||
}
|
||||
@ -813,12 +815,12 @@ CreateTermInArena(Term arena, Atom Na, UInt Nar, UInt arity, Term *newarena, Ter
|
||||
HB0[i] = init;
|
||||
}
|
||||
}
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||
return tf;
|
||||
}
|
||||
|
||||
inline static GlobalEntry *
|
||||
FindGlobalEntry(Atom at)
|
||||
FindGlobalEntry(Atom at USES_REGS)
|
||||
/* get predicate entry for ap/arity; create it if neccessary. */
|
||||
{
|
||||
Prop p0;
|
||||
@ -843,7 +845,7 @@ FindGlobalEntry(Atom at)
|
||||
}
|
||||
|
||||
inline static GlobalEntry *
|
||||
GetGlobalEntry(Atom at)
|
||||
GetGlobalEntry(Atom at USES_REGS)
|
||||
/* get predicate entry for ap/arity; create it if neccessary. */
|
||||
{
|
||||
Prop p0;
|
||||
@ -881,7 +883,7 @@ GetGlobalEntry(Atom at)
|
||||
}
|
||||
|
||||
static UInt
|
||||
garena_overflow_size(CELL *arena)
|
||||
garena_overflow_size(CELL *arena USES_REGS)
|
||||
{
|
||||
UInt dup = (((CELL *)arena-H0)*sizeof(CELL))>>3;
|
||||
if (dup < 64*1024*GlobalArenaOverflows)
|
||||
@ -892,7 +894,7 @@ garena_overflow_size(CELL *arena)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_setarg(void)
|
||||
p_nb_setarg( USES_REGS1 )
|
||||
{
|
||||
Term wheret = Deref(ARG1);
|
||||
Term dest = Deref(ARG2);
|
||||
@ -924,7 +926,7 @@ p_nb_setarg(void)
|
||||
}
|
||||
if (pos < 1 || pos > arity)
|
||||
return FALSE;
|
||||
to = CopyTermToArena(ARG3, GlobalArena, FALSE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||
to = CopyTermToArena(ARG3, GlobalArena, FALSE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
|
||||
if (to == 0L)
|
||||
return FALSE;
|
||||
destp[pos] = to;
|
||||
@ -932,7 +934,7 @@ p_nb_setarg(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_set_shared_arg(void)
|
||||
p_nb_set_shared_arg( USES_REGS1 )
|
||||
{
|
||||
Term wheret = Deref(ARG1);
|
||||
Term dest = Deref(ARG2);
|
||||
@ -964,7 +966,7 @@ p_nb_set_shared_arg(void)
|
||||
}
|
||||
if (pos < 1 || pos > arity)
|
||||
return FALSE;
|
||||
to = CopyTermToArena(ARG3, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||
to = CopyTermToArena(ARG3, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
|
||||
if (to == 0L)
|
||||
return FALSE;
|
||||
destp[pos] = to;
|
||||
@ -972,7 +974,7 @@ p_nb_set_shared_arg(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_linkarg(void)
|
||||
p_nb_linkarg( USES_REGS1 )
|
||||
{
|
||||
Term wheret = Deref(ARG1);
|
||||
Term dest = Deref(ARG2);
|
||||
@ -1008,7 +1010,7 @@ p_nb_linkarg(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_linkval(void)
|
||||
p_nb_linkval( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1), to;
|
||||
GlobalEntry *ge;
|
||||
@ -1019,7 +1021,7 @@ p_nb_linkval(void)
|
||||
Yap_Error(TYPE_ERROR_ATOM,t,"nb_linkval");
|
||||
return (FALSE);
|
||||
}
|
||||
ge = GetGlobalEntry(AtomOfTerm(t));
|
||||
ge = GetGlobalEntry(AtomOfTerm(t) PASS_REGS);
|
||||
to = Deref(ARG2);
|
||||
WRITE_LOCK(ge->GRWLock);
|
||||
ge->global=to;
|
||||
@ -1030,10 +1032,11 @@ p_nb_linkval(void)
|
||||
Term
|
||||
Yap_SetGlobalVal(Atom at, Term t0)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term to;
|
||||
GlobalEntry *ge;
|
||||
ge = GetGlobalEntry(at);
|
||||
to = CopyTermToArena(t0, GlobalArena, FALSE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||
ge = GetGlobalEntry(at PASS_REGS);
|
||||
to = CopyTermToArena(t0, GlobalArena, FALSE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
|
||||
if (to == 0L)
|
||||
return to;
|
||||
WRITE_LOCK(ge->GRWLock);
|
||||
@ -1045,15 +1048,16 @@ Yap_SetGlobalVal(Atom at, Term t0)
|
||||
Term
|
||||
Yap_SaveTerm(Term t0)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term to;
|
||||
to = CopyTermToArena(t0, GlobalArena, FALSE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||
to = CopyTermToArena(t0, GlobalArena, FALSE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
|
||||
if (to == 0L)
|
||||
return to;
|
||||
return to;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_setval(void)
|
||||
p_nb_setval( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
if (IsVarTerm(t)) {
|
||||
@ -1067,7 +1071,7 @@ p_nb_setval(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_set_shared_val(void)
|
||||
p_nb_set_shared_val( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1), to;
|
||||
GlobalEntry *ge;
|
||||
@ -1078,8 +1082,8 @@ p_nb_set_shared_val(void)
|
||||
Yap_Error(TYPE_ERROR_ATOM,t,"nb_setval");
|
||||
return (FALSE);
|
||||
}
|
||||
ge = GetGlobalEntry(AtomOfTerm(t));
|
||||
to = CopyTermToArena(ARG2, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||
ge = GetGlobalEntry(AtomOfTerm(t) PASS_REGS);
|
||||
to = CopyTermToArena(ARG2, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
|
||||
if (to == 0L)
|
||||
return FALSE;
|
||||
WRITE_LOCK(ge->GRWLock);
|
||||
@ -1089,7 +1093,7 @@ p_nb_set_shared_val(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_b_setval(void)
|
||||
p_b_setval( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
GlobalEntry *ge;
|
||||
@ -1101,7 +1105,7 @@ p_b_setval(void)
|
||||
Yap_Error(TYPE_ERROR_ATOM,t,"b_setval");
|
||||
return (FALSE);
|
||||
}
|
||||
ge = GetGlobalEntry(AtomOfTerm(t));
|
||||
ge = GetGlobalEntry(AtomOfTerm(t) PASS_REGS);
|
||||
WRITE_LOCK(ge->GRWLock);
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||
/* the evil deed is to be done now */
|
||||
@ -1125,7 +1129,7 @@ p_b_setval(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_getval(void)
|
||||
p_nb_getval( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1), to;
|
||||
GlobalEntry *ge;
|
||||
@ -1137,7 +1141,7 @@ p_nb_getval(void)
|
||||
Yap_Error(TYPE_ERROR_ATOM,t,"nb_getval");
|
||||
return FALSE;
|
||||
}
|
||||
ge = FindGlobalEntry(AtomOfTerm(t));
|
||||
ge = FindGlobalEntry(AtomOfTerm(t) PASS_REGS);
|
||||
if (!ge) {
|
||||
return Yap_unify(TermNil, ARG3);
|
||||
}
|
||||
@ -1156,13 +1160,13 @@ p_nb_getval(void)
|
||||
|
||||
|
||||
static Int
|
||||
nbdelete(Atom at)
|
||||
nbdelete(Atom at USES_REGS)
|
||||
{
|
||||
GlobalEntry *ge, *g;
|
||||
AtomEntry *ae;
|
||||
Prop gp, g0;
|
||||
|
||||
ge = FindGlobalEntry(at);
|
||||
ge = FindGlobalEntry(at PASS_REGS);
|
||||
if (!ge) {
|
||||
Yap_Error(EXISTENCE_ERROR_VARIABLE,MkAtomTerm(at),"nb_delete");
|
||||
return FALSE;
|
||||
@ -1196,11 +1200,12 @@ nbdelete(Atom at)
|
||||
Int
|
||||
Yap_DeleteGlobal(Atom at)
|
||||
{
|
||||
return nbdelete(at);
|
||||
CACHE_REGS
|
||||
return nbdelete(at PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_delete(void)
|
||||
p_nb_delete( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
|
||||
@ -1211,11 +1216,11 @@ p_nb_delete(void)
|
||||
Yap_Error(TYPE_ERROR_ATOM,t,"nb_delete");
|
||||
return FALSE;
|
||||
}
|
||||
return nbdelete(AtomOfTerm(t));
|
||||
return nbdelete(AtomOfTerm(t) PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_create(void)
|
||||
p_nb_create( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
Term tname = Deref(ARG2);
|
||||
@ -1230,7 +1235,7 @@ p_nb_create(void)
|
||||
Yap_Error(TYPE_ERROR_ATOM,t,"nb_create");
|
||||
return FALSE;
|
||||
}
|
||||
ge = GetGlobalEntry(AtomOfTerm(t));
|
||||
ge = GetGlobalEntry(AtomOfTerm(t) PASS_REGS);
|
||||
if (!ge) {
|
||||
Yap_Error(EXISTENCE_ERROR_VARIABLE,t,"nb_create");
|
||||
return FALSE;
|
||||
@ -1249,7 +1254,7 @@ p_nb_create(void)
|
||||
Yap_Error(TYPE_ERROR_ATOM,tname,"nb_create");
|
||||
return FALSE;
|
||||
}
|
||||
to = CreateTermInArena(GlobalArena, AtomOfTerm(tname), IntegerOfTerm(tarity), 3, &GlobalArena, 0L);
|
||||
to = CreateTermInArena(GlobalArena, AtomOfTerm(tname), IntegerOfTerm(tarity), 3, &GlobalArena, 0L PASS_REGS);
|
||||
if (!to)
|
||||
return FALSE;
|
||||
WRITE_LOCK(ge->GRWLock);
|
||||
@ -1259,7 +1264,7 @@ p_nb_create(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_create2(void)
|
||||
p_nb_create2( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
Term tname = Deref(ARG2);
|
||||
@ -1275,7 +1280,7 @@ p_nb_create2(void)
|
||||
Yap_Error(TYPE_ERROR_ATOM,t,"nb_create");
|
||||
return FALSE;
|
||||
}
|
||||
ge = GetGlobalEntry(AtomOfTerm(t));
|
||||
ge = GetGlobalEntry(AtomOfTerm(t) PASS_REGS);
|
||||
if (!ge) {
|
||||
Yap_Error(EXISTENCE_ERROR_VARIABLE,t,"nb_create");
|
||||
return FALSE;
|
||||
@ -1301,7 +1306,7 @@ p_nb_create2(void)
|
||||
Yap_Error(TYPE_ERROR_ATOM,tname,"nb_create");
|
||||
return FALSE;
|
||||
}
|
||||
to = CreateTermInArena(GlobalArena, AtomOfTerm(tname), IntegerOfTerm(tarity), 4, &GlobalArena, tinit);
|
||||
to = CreateTermInArena(GlobalArena, AtomOfTerm(tname), IntegerOfTerm(tarity), 4, &GlobalArena, tinit PASS_REGS);
|
||||
if (!to)
|
||||
return FALSE;
|
||||
WRITE_LOCK(ge->GRWLock);
|
||||
@ -1313,7 +1318,7 @@ p_nb_create2(void)
|
||||
/* a non-backtrackable queue is a term of the form $array(Arena,Start,End,Size) plus an Arena. */
|
||||
|
||||
static Int
|
||||
nb_queue(UInt arena_sz)
|
||||
nb_queue(UInt arena_sz USES_REGS)
|
||||
{
|
||||
Term queue_arena, queue, ar[QUEUE_FUNCTOR_ARITY], *nar;
|
||||
Term t = Deref(ARG1);
|
||||
@ -1335,7 +1340,7 @@ nb_queue(UInt arena_sz)
|
||||
return FALSE;
|
||||
if (arena_sz < 4*1024)
|
||||
arena_sz = 4*1024;
|
||||
queue_arena = NewArena(arena_sz,1,NULL);
|
||||
queue_arena = NewArena(arena_sz, 1, NULL PASS_REGS);
|
||||
if (queue_arena == 0L) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -1345,7 +1350,7 @@ nb_queue(UInt arena_sz)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_queue(void)
|
||||
p_nb_queue( USES_REGS1 )
|
||||
{
|
||||
UInt arena_sz = (ASP-H)/16;
|
||||
if (DepthArenas > 1)
|
||||
@ -1354,11 +1359,11 @@ p_nb_queue(void)
|
||||
arena_sz = MIN_ARENA_SIZE;
|
||||
if (arena_sz > MAX_ARENA_SIZE)
|
||||
arena_sz = MAX_ARENA_SIZE;
|
||||
return nb_queue(arena_sz);
|
||||
return nb_queue(arena_sz PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_queue_sized(void)
|
||||
p_nb_queue_sized( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG2);
|
||||
if (IsVarTerm(t)) {
|
||||
@ -1369,7 +1374,7 @@ p_nb_queue_sized(void)
|
||||
Yap_Error(TYPE_ERROR_INTEGER,t,"nb_queue");
|
||||
return FALSE;
|
||||
}
|
||||
return nb_queue((UInt)IntegerOfTerm(t));
|
||||
return nb_queue((UInt)IntegerOfTerm(t) PASS_REGS);
|
||||
}
|
||||
|
||||
static CELL *
|
||||
@ -1413,7 +1418,7 @@ GetQueueArena(CELL *qd, char* caller)
|
||||
}
|
||||
|
||||
static void
|
||||
RecoverArena(Term arena)
|
||||
RecoverArena(Term arena USES_REGS)
|
||||
{
|
||||
CELL *pt = ArenaPt(arena),
|
||||
*max = ArenaLimit(arena);
|
||||
@ -1424,7 +1429,7 @@ RecoverArena(Term arena)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_queue_close(void)
|
||||
p_nb_queue_close( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
Int out;
|
||||
@ -1439,7 +1444,7 @@ p_nb_queue_close(void)
|
||||
Yap_unify(ARG3, ARG2);
|
||||
}
|
||||
if (qp[QUEUE_ARENA] != MkIntTerm(0))
|
||||
RecoverArena(qp[QUEUE_ARENA]);
|
||||
RecoverArena(qp[QUEUE_ARENA] PASS_REGS);
|
||||
if (qp[QUEUE_SIZE] == MkIntTerm(0)) {
|
||||
return
|
||||
Yap_unify(ARG3, ARG2);
|
||||
@ -1458,7 +1463,7 @@ p_nb_queue_close(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_queue_enqueue(void)
|
||||
p_nb_queue_enqueue( USES_REGS1 )
|
||||
{
|
||||
CELL *qd = GetQueue(ARG1,"enqueue"), *oldH, *oldHB;
|
||||
UInt old_sz;
|
||||
@ -1475,7 +1480,7 @@ p_nb_queue_enqueue(void)
|
||||
} else {
|
||||
min_size = 0L;
|
||||
}
|
||||
to = CopyTermToArena(ARG2, arena, FALSE, TRUE, 2, qd+QUEUE_ARENA, min_size);
|
||||
to = CopyTermToArena(ARG2, arena, FALSE, TRUE, 2, qd+QUEUE_ARENA, min_size PASS_REGS);
|
||||
if (to == 0L)
|
||||
return FALSE;
|
||||
qd = GetQueue(ARG1,"enqueue");
|
||||
@ -1497,7 +1502,7 @@ p_nb_queue_enqueue(void)
|
||||
}
|
||||
ARG3 = to;
|
||||
/* fprintf(stderr,"growing %ld cells\n",(unsigned long int)gsiz);*/
|
||||
if (!GrowArena(arena, ArenaLimit(arena), old_sz, gsiz, 3)) {
|
||||
if (!GrowArena(arena, ArenaLimit(arena), old_sz, gsiz, 3 PASS_REGS)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, arena, Yap_ErrorMessage);
|
||||
return 0L;
|
||||
}
|
||||
@ -1519,12 +1524,12 @@ p_nb_queue_enqueue(void)
|
||||
RESET_VARIABLE(H);
|
||||
qd[QUEUE_TAIL] = (CELL)H;
|
||||
H++;
|
||||
CloseArena(oldH, oldHB, ASP, qd+QUEUE_ARENA, old_sz);
|
||||
CloseArena(oldH, oldHB, ASP, qd+QUEUE_ARENA, old_sz PASS_REGS);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_queue_dequeue(void)
|
||||
p_nb_queue_dequeue( USES_REGS1 )
|
||||
{
|
||||
CELL *qd = GetQueue(ARG1,"dequeue");
|
||||
UInt old_sz, qsz;
|
||||
@ -1546,12 +1551,12 @@ p_nb_queue_dequeue(void)
|
||||
oldH = H;
|
||||
oldHB = HB;
|
||||
qd[QUEUE_SIZE] = Global_MkIntegerTerm(qsz-1);
|
||||
CloseArena(oldH, oldHB, ASP, &arena, old_sz);
|
||||
CloseArena(oldH, oldHB, ASP, &arena, old_sz PASS_REGS);
|
||||
return Yap_unify(out, ARG2);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_queue_peek(void)
|
||||
p_nb_queue_peek( USES_REGS1 )
|
||||
{
|
||||
CELL *qd = GetQueue(ARG1,"queue_peek");
|
||||
UInt qsz;
|
||||
@ -1565,7 +1570,7 @@ p_nb_queue_peek(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_queue_empty(void)
|
||||
p_nb_queue_empty( USES_REGS1 )
|
||||
{
|
||||
CELL *qd = GetQueue(ARG1,"queue_empty");
|
||||
|
||||
@ -1575,7 +1580,7 @@ p_nb_queue_empty(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_queue_size(void)
|
||||
p_nb_queue_size( USES_REGS1 )
|
||||
{
|
||||
CELL *qd = GetQueue(ARG1,"queue_size");
|
||||
|
||||
@ -1602,7 +1607,7 @@ GetHeap(Term t, char* caller)
|
||||
}
|
||||
|
||||
static Term
|
||||
MkZeroApplTerm(Functor f, UInt sz)
|
||||
MkZeroApplTerm(Functor f, UInt sz USES_REGS)
|
||||
{
|
||||
Term t0, tf;
|
||||
CELL *pt;
|
||||
@ -1621,7 +1626,7 @@ MkZeroApplTerm(Functor f, UInt sz)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_heap(void)
|
||||
p_nb_heap( USES_REGS1 )
|
||||
{
|
||||
Term heap_arena, heap, *ar, *nar;
|
||||
UInt hsize;
|
||||
@ -1639,7 +1644,7 @@ p_nb_heap(void)
|
||||
hsize = IntegerOfTerm(tsize);
|
||||
}
|
||||
|
||||
while ((heap = MkZeroApplTerm(Yap_MkFunctor(AtomHeap,2*hsize+HEAP_START+1),2*hsize+HEAP_START+1)) == TermNil) {
|
||||
while ((heap = MkZeroApplTerm(Yap_MkFunctor(AtomHeap,2*hsize+HEAP_START+1),2*hsize+HEAP_START+1 PASS_REGS)) == TermNil) {
|
||||
if (!Yap_gcl((2*hsize+HEAP_START+1)*sizeof(CELL), 2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
@ -1654,7 +1659,7 @@ p_nb_heap(void)
|
||||
ar[HEAP_MAX] = tsize;
|
||||
if (arena_sz < 1024)
|
||||
arena_sz = 1024;
|
||||
heap_arena = NewArena(arena_sz,1,NULL);
|
||||
heap_arena = NewArena(arena_sz,1,NULL PASS_REGS);
|
||||
if (heap_arena == 0L) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -1664,7 +1669,7 @@ p_nb_heap(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_heap_close(void)
|
||||
p_nb_heap_close( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
if (!IsVarTerm(t)) {
|
||||
@ -1672,7 +1677,7 @@ p_nb_heap_close(void)
|
||||
|
||||
qp = RepAppl(t)+1;
|
||||
if (qp[HEAP_ARENA] != MkIntTerm(0))
|
||||
RecoverArena(qp[HEAP_ARENA]);
|
||||
RecoverArena(qp[HEAP_ARENA] PASS_REGS);
|
||||
qp[-1] = (CELL)Yap_MkFunctor(AtomHeap,1);
|
||||
qp[0] = MkIntegerTerm(0);
|
||||
return TRUE;
|
||||
@ -1737,7 +1742,7 @@ DelHeapRoot(CELL *pt, UInt sz)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_heap_add_to_heap(void)
|
||||
p_nb_heap_add_to_heap( USES_REGS1 )
|
||||
{
|
||||
CELL *qd = GetHeap(ARG1,"add_to_heap"), *oldH, *oldHB, *pt;
|
||||
UInt hsize, hmsize, old_sz;
|
||||
@ -1781,17 +1786,17 @@ p_nb_heap_add_to_heap(void)
|
||||
oldHB = HB;
|
||||
H = HB = ArenaPt(arena);
|
||||
qd[HEAP_MAX] = Global_MkIntegerTerm(hmsize);
|
||||
CloseArena(oldH, oldHB, ASP, qd+HEAP_ARENA, old_sz);
|
||||
CloseArena(oldH, oldHB, ASP, qd+HEAP_ARENA, old_sz PASS_REGS);
|
||||
goto restart;
|
||||
}
|
||||
arena = qd[HEAP_ARENA];
|
||||
if (arena == 0L)
|
||||
return FALSE;
|
||||
mingrow = garena_overflow_size(ArenaPt(arena));
|
||||
ARG2 = CopyTermToArena(ARG2, arena, FALSE, TRUE, 3, qd+HEAP_ARENA, mingrow);
|
||||
mingrow = garena_overflow_size(ArenaPt(arena) PASS_REGS);
|
||||
ARG2 = CopyTermToArena(ARG2, arena, FALSE, TRUE, 3, qd+HEAP_ARENA, mingrow PASS_REGS);
|
||||
qd = GetHeap(ARG1,"add_to_heap");
|
||||
arena = qd[HEAP_ARENA];
|
||||
to = CopyTermToArena(ARG3, arena, FALSE, TRUE, 3, qd+HEAP_ARENA, mingrow);
|
||||
to = CopyTermToArena(ARG3, arena, FALSE, TRUE, 3, qd+HEAP_ARENA, mingrow PASS_REGS);
|
||||
/* protect key in ARG2 in case there is an overflow while copying to */
|
||||
key = ARG2;
|
||||
if (key == 0 || to == 0L)
|
||||
@ -1814,7 +1819,7 @@ p_nb_heap_add_to_heap(void)
|
||||
gsiz = 1024;
|
||||
}
|
||||
ARG3 = to;
|
||||
if (!GrowArena(arena, ArenaLimit(arena), old_sz, gsiz, 3)) {
|
||||
if (!GrowArena(arena, ArenaLimit(arena), old_sz, gsiz, 3 PASS_REGS)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, arena, Yap_ErrorMessage);
|
||||
return 0L;
|
||||
}
|
||||
@ -1831,12 +1836,12 @@ p_nb_heap_add_to_heap(void)
|
||||
pt[2*hsize+1] = to;
|
||||
PushHeap(pt, hsize);
|
||||
qd[HEAP_SIZE] = Global_MkIntegerTerm(hsize+1);
|
||||
CloseArena(oldH, oldHB, ASP, qd+HEAP_ARENA, old_sz);
|
||||
CloseArena(oldH, oldHB, ASP, qd+HEAP_ARENA, old_sz PASS_REGS);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_heap_del(void)
|
||||
p_nb_heap_del( USES_REGS1 )
|
||||
{
|
||||
CELL *qd = GetHeap(ARG1,"deheap");
|
||||
UInt old_sz, qsz;
|
||||
@ -1857,7 +1862,7 @@ p_nb_heap_del(void)
|
||||
oldH = H;
|
||||
oldHB = HB;
|
||||
qd[HEAP_SIZE] = Global_MkIntegerTerm(qsz-1);
|
||||
CloseArena(oldH, oldHB, ASP, &arena, old_sz);
|
||||
CloseArena(oldH, oldHB, ASP, &arena, old_sz PASS_REGS);
|
||||
tk = qd[HEAP_START];
|
||||
tv = qd[HEAP_START+1];
|
||||
DelHeapRoot(qd+HEAP_START, qsz);
|
||||
@ -1866,7 +1871,7 @@ p_nb_heap_del(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_heap_peek(void)
|
||||
p_nb_heap_peek( USES_REGS1 )
|
||||
{
|
||||
CELL *qd = GetHeap(ARG1,"heap_peek");
|
||||
UInt qsz;
|
||||
@ -1884,7 +1889,7 @@ p_nb_heap_peek(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_heap_empty(void)
|
||||
p_nb_heap_empty( USES_REGS1 )
|
||||
{
|
||||
CELL *qd = GetHeap(ARG1,"heap_empty");
|
||||
|
||||
@ -1894,7 +1899,7 @@ p_nb_heap_empty(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_heap_size(void)
|
||||
p_nb_heap_size( USES_REGS1 )
|
||||
{
|
||||
CELL *qd = GetHeap(ARG1,"heap_size");
|
||||
|
||||
@ -1904,7 +1909,7 @@ p_nb_heap_size(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_beam(void)
|
||||
p_nb_beam( USES_REGS1 )
|
||||
{
|
||||
Term beam_arena, beam, *ar, *nar;
|
||||
UInt hsize;
|
||||
@ -1921,7 +1926,7 @@ p_nb_beam(void)
|
||||
}
|
||||
hsize = IntegerOfTerm(tsize);
|
||||
}
|
||||
while ((beam = MkZeroApplTerm(Yap_MkFunctor(AtomHeap,5*hsize+HEAP_START+1),5*hsize+HEAP_START+1)) == TermNil) {
|
||||
while ((beam = MkZeroApplTerm(Yap_MkFunctor(AtomHeap,5*hsize+HEAP_START+1),5*hsize+HEAP_START+1 PASS_REGS)) == TermNil) {
|
||||
if (!Yap_gcl((4*hsize+HEAP_START+1)*sizeof(CELL), 2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
@ -1936,7 +1941,7 @@ p_nb_beam(void)
|
||||
ar[HEAP_MAX] = tsize;
|
||||
if (arena_sz < 1024)
|
||||
arena_sz = 1024;
|
||||
beam_arena = NewArena(arena_sz,1,NULL);
|
||||
beam_arena = NewArena(arena_sz,1,NULL PASS_REGS);
|
||||
if (beam_arena == 0L) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -1946,9 +1951,9 @@ p_nb_beam(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_beam_close(void)
|
||||
p_nb_beam_close( USES_REGS1 )
|
||||
{
|
||||
return p_nb_heap_close();
|
||||
return p_nb_heap_close( PASS_REGS1 );
|
||||
}
|
||||
|
||||
|
||||
@ -2151,7 +2156,7 @@ DelBeamMin(CELL *pt, CELL *pt2, UInt sz)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_beam_add_to_beam(void)
|
||||
p_nb_beam_add_to_beam( USES_REGS1 )
|
||||
{
|
||||
CELL *qd = GetHeap(ARG1,"add_to_beam"), *oldH, *oldHB, *pt;
|
||||
UInt hsize, hmsize, old_sz;
|
||||
@ -2176,10 +2181,10 @@ p_nb_beam_add_to_beam(void)
|
||||
arena = qd[HEAP_ARENA];
|
||||
if (arena == 0L)
|
||||
return FALSE;
|
||||
mingrow = garena_overflow_size(ArenaPt(arena));
|
||||
key = CopyTermToArena(ARG2, qd[HEAP_ARENA], FALSE, TRUE, 3, qd+HEAP_ARENA, mingrow);
|
||||
mingrow = garena_overflow_size(ArenaPt(arena) PASS_REGS);
|
||||
key = CopyTermToArena(ARG2, qd[HEAP_ARENA], FALSE, TRUE, 3, qd+HEAP_ARENA, mingrow PASS_REGS);
|
||||
arena = qd[HEAP_ARENA];
|
||||
to = CopyTermToArena(ARG3, arena, FALSE, TRUE, 3, qd+HEAP_ARENA, mingrow);
|
||||
to = CopyTermToArena(ARG3, arena, FALSE, TRUE, 3, qd+HEAP_ARENA, mingrow PASS_REGS);
|
||||
if (key == 0 || to == 0L)
|
||||
return FALSE;
|
||||
qd = GetHeap(ARG1,"add_to_beam");
|
||||
@ -2200,7 +2205,7 @@ p_nb_beam_add_to_beam(void)
|
||||
gsiz = 1024;
|
||||
}
|
||||
ARG3 = to;
|
||||
if (!GrowArena(arena, ArenaLimit(arena), old_sz, gsiz, 3)) {
|
||||
if (!GrowArena(arena, ArenaLimit(arena), old_sz, gsiz, 3 PASS_REGS)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, arena, Yap_ErrorMessage);
|
||||
return 0L;
|
||||
}
|
||||
@ -2215,12 +2220,12 @@ p_nb_beam_add_to_beam(void)
|
||||
pt = qd+HEAP_START;
|
||||
PushBeam(pt, pt+2*hmsize, hsize, key, to);
|
||||
qd[HEAP_SIZE] = Global_MkIntegerTerm(hsize+1);
|
||||
CloseArena(oldH, oldHB, ASP, qd+HEAP_ARENA, old_sz);
|
||||
CloseArena(oldH, oldHB, ASP, qd+HEAP_ARENA, old_sz PASS_REGS);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_beam_del(void)
|
||||
p_nb_beam_del( USES_REGS1 )
|
||||
{
|
||||
CELL *qd = GetHeap(ARG1,"debeam");
|
||||
UInt old_sz, qsz;
|
||||
@ -2241,7 +2246,7 @@ p_nb_beam_del(void)
|
||||
oldH = H;
|
||||
oldHB = HB;
|
||||
qd[HEAP_SIZE] = Global_MkIntegerTerm(qsz-1);
|
||||
CloseArena(oldH, oldHB, ASP, &arena, old_sz);
|
||||
CloseArena(oldH, oldHB, ASP, &arena, old_sz PASS_REGS);
|
||||
tk = qd[HEAP_START];
|
||||
tv = DelBeamMin(qd+HEAP_START, qd+(HEAP_START+2*IntegerOfTerm(qd[HEAP_MAX])), qsz);
|
||||
return Yap_unify(tk, ARG2) &&
|
||||
@ -2250,7 +2255,7 @@ p_nb_beam_del(void)
|
||||
|
||||
#ifdef DEBUG
|
||||
static Int
|
||||
p_nb_beam_check(void)
|
||||
p_nb_beam_check( USES_REGS1 )
|
||||
{
|
||||
CELL *qd = GetHeap(ARG1,"debeam");
|
||||
UInt qsz, qmax;
|
||||
@ -2293,7 +2298,7 @@ p_nb_beam_check(void)
|
||||
#endif
|
||||
|
||||
static Int
|
||||
p_nb_beam_keys(void)
|
||||
p_nb_beam_keys( USES_REGS1 )
|
||||
{
|
||||
CELL *qd;
|
||||
UInt qsz;
|
||||
@ -2328,7 +2333,7 @@ p_nb_beam_keys(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_beam_peek(void)
|
||||
p_nb_beam_peek( USES_REGS1 )
|
||||
{
|
||||
CELL *qd = GetHeap(ARG1,"beam_peek"), *pt, *pt2;
|
||||
UInt qsz, qbsize;
|
||||
@ -2349,7 +2354,7 @@ p_nb_beam_peek(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_beam_empty(void)
|
||||
p_nb_beam_empty( USES_REGS1 )
|
||||
{
|
||||
CELL *qd = GetHeap(ARG1,"beam_empty");
|
||||
|
||||
@ -2359,7 +2364,7 @@ p_nb_beam_empty(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nb_beam_size(void)
|
||||
p_nb_beam_size( USES_REGS1 )
|
||||
{
|
||||
CELL *qd = GetHeap(ARG1,"beam_size");
|
||||
|
||||
@ -2369,7 +2374,7 @@ p_nb_beam_size(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
cont_current_nb(void)
|
||||
cont_current_nb( USES_REGS1 )
|
||||
{
|
||||
Int unif;
|
||||
GlobalEntry *ge = (GlobalEntry *)IntegerOfTerm(EXTRA_CBACK_ARG(1,1));
|
||||
@ -2388,12 +2393,12 @@ cont_current_nb(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
init_current_nb(void)
|
||||
init_current_nb( USES_REGS1 )
|
||||
{ /* current_atom(?Atom) */
|
||||
Term t1 = Deref(ARG1);
|
||||
if (!IsVarTerm(t1)) {
|
||||
if (IsAtomTerm(t1)) {
|
||||
if (!FindGlobalEntry(AtomOfTerm(t1))) {
|
||||
if (!FindGlobalEntry(AtomOfTerm(t1) PASS_REGS)) {
|
||||
cut_fail();
|
||||
} else {
|
||||
cut_succeed();
|
||||
@ -2405,12 +2410,13 @@ init_current_nb(void)
|
||||
}
|
||||
READ_LOCK(HashChain[0].AERWLock);
|
||||
EXTRA_CBACK_ARG(1,1) = MkIntegerTerm((Int)GlobalVariables);
|
||||
return cont_current_nb();
|
||||
return cont_current_nb( PASS_REGS1 );
|
||||
}
|
||||
|
||||
|
||||
void Yap_InitGlobals(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term cm = CurrentModule;
|
||||
Yap_InitCPred("$allocate_arena", 2, p_allocate_arena, 0);
|
||||
Yap_InitCPred("arena_size", 1, p_default_arena_size, 0);
|
||||
|
62
C/gprof.c
62
C/gprof.c
@ -727,7 +727,7 @@ typedef struct clause_entry {
|
||||
int ts; /* start end timestamp towards retracts, eventually */
|
||||
} clauseentry;
|
||||
|
||||
static Int profend(void);
|
||||
static Int profend( USES_REGS1 );
|
||||
|
||||
static void
|
||||
clean_tree(rb_red_blk_node* node) {
|
||||
@ -773,6 +773,7 @@ static void LookupNode(yamop *current_p) {
|
||||
pp = Yap_PredEntryForCode(current_p, FIND_PRED_FROM_ANYWHERE, &start, &end);
|
||||
if (!pp) {
|
||||
#if DEBUG
|
||||
CACHE_REGS
|
||||
fprintf(stderr,"lost %p, %d\n", P, Yap_op_from_opcode(P->opc));
|
||||
#endif
|
||||
/* lost profiler event !! */
|
||||
@ -832,14 +833,14 @@ static void RemoveCode(CODEADDR clau)
|
||||
#define MAX_LINE_SIZE 1024
|
||||
|
||||
static int
|
||||
showprofres(void) {
|
||||
showprofres( USES_REGS1 ) {
|
||||
char line[MAX_LINE_SIZE];
|
||||
yamop *pr_beg, *pr_end;
|
||||
PredEntry *pr_pp;
|
||||
long int pr_count;
|
||||
|
||||
|
||||
profend(); /* Make sure profiler has ended */
|
||||
profend( PASS_REGS1 ); /* Make sure profiler has ended */
|
||||
|
||||
/* First part: Read information about predicates and store it on yap trail */
|
||||
|
||||
@ -877,14 +878,14 @@ showprofres(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_test(void) {
|
||||
p_test( USES_REGS1 ) {
|
||||
char line[MAX_LINE_SIZE];
|
||||
yamop *pr_beg, *pr_end;
|
||||
PredEntry *pr_pp;
|
||||
long int pr_count;
|
||||
|
||||
|
||||
profend(); /* Make sure profiler has ended */
|
||||
profend( PASS_REGS1 ); /* Make sure profiler has ended */
|
||||
|
||||
/* First part: Read information about predicates and store it on yap trail */
|
||||
|
||||
@ -959,6 +960,7 @@ prof_alrm(int signo, siginfo_t *si, void *scv)
|
||||
|
||||
|
||||
if (oldpc>(void *) &Yap_absmi && oldpc <= (void *) &Yap_absmiEND) {
|
||||
CACHE_REGS
|
||||
/* we are running emulator code */
|
||||
#if BP_FREE
|
||||
current_p =(yamop *) CONTEXT_BP(scv);
|
||||
@ -966,6 +968,7 @@ prof_alrm(int signo, siginfo_t *si, void *scv)
|
||||
current_p = P;
|
||||
#endif
|
||||
} else {
|
||||
CACHE_REGS
|
||||
op_numbers oop = Yap_op_from_opcode(PREVOP(P,Osbpp)->opc);
|
||||
|
||||
if (oop == _call_cpred || oop == _call_usercpred) {
|
||||
@ -1014,10 +1017,10 @@ Yap_InformOfRemoval(CODEADDR clau)
|
||||
ProfOn = FALSE;
|
||||
}
|
||||
|
||||
static Int profend(void);
|
||||
static Int profend( USES_REGS1 );
|
||||
|
||||
static Int
|
||||
profnode(void) {
|
||||
profnode( USES_REGS1 ) {
|
||||
Term t1 = Deref(ARG1), tleft, tright;
|
||||
rb_red_blk_node *node;
|
||||
|
||||
@ -1053,7 +1056,7 @@ profnode(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
profglobs(void) {
|
||||
profglobs( USES_REGS1 ) {
|
||||
return
|
||||
Yap_unify(ARG1,MkIntegerTerm(ProfCalls)) &&
|
||||
Yap_unify(ARG2,MkIntegerTerm(ProfGCs)) &&
|
||||
@ -1064,7 +1067,7 @@ profglobs(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
do_profinit(void)
|
||||
do_profinit( USES_REGS1 )
|
||||
{
|
||||
if (Yap_OffLineProfiler) {
|
||||
// FPreds=fopen(profile_names(PROFPREDS_FILE),"w+");
|
||||
@ -1080,18 +1083,18 @@ do_profinit(void)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int profinit(void)
|
||||
static Int profinit( USES_REGS1 )
|
||||
{
|
||||
if (ProfilerOn!=0) return (FALSE);
|
||||
|
||||
if (!do_profinit())
|
||||
if (!do_profinit( PASS_REGS1 ))
|
||||
return FALSE;
|
||||
|
||||
ProfilerOn = -1; /* Inited but not yet started */
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static Int profinit1(void)
|
||||
static Int profinit1( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
|
||||
@ -1114,11 +1117,11 @@ static Int profinit1(void)
|
||||
Yap_Error(TYPE_ERROR_ATOM,t,"profinit only allows offline,online");
|
||||
return FALSE;
|
||||
}
|
||||
return profinit();
|
||||
return profinit( PASS_REGS1 );
|
||||
}
|
||||
|
||||
|
||||
static Int proftype(void)
|
||||
static Int proftype( USES_REGS1 )
|
||||
{
|
||||
if (Yap_OffLineProfiler)
|
||||
return Yap_unify(ARG1,MkAtomTerm(AtomOffline));
|
||||
@ -1135,7 +1138,8 @@ static Int start_profilers(int msec)
|
||||
if (Yap_OffLineProfiler) {
|
||||
return FALSE; /* have to go through profinit */
|
||||
} else {
|
||||
if (!do_profinit())
|
||||
CACHE_REGS
|
||||
if (!do_profinit( PASS_REGS1 ))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@ -1156,7 +1160,7 @@ static Int start_profilers(int msec)
|
||||
}
|
||||
|
||||
|
||||
static Int profoff(void) {
|
||||
static Int profoff( USES_REGS1 ) {
|
||||
if (ProfilerOn>0) {
|
||||
setitimer(ITIMER_PROF,NULL,NULL);
|
||||
ProfilerOn = -1;
|
||||
@ -1165,32 +1169,32 @@ static Int profoff(void) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Int profon(void) {
|
||||
static Int profon( USES_REGS1 ) {
|
||||
Term p;
|
||||
profoff();
|
||||
profoff( PASS_REGS1 );
|
||||
p=Deref(ARG1);
|
||||
return(start_profilers(IntOfTerm(p)));
|
||||
}
|
||||
|
||||
static Int profon0(void) {
|
||||
profoff();
|
||||
static Int profon0( USES_REGS1 ) {
|
||||
profoff( PASS_REGS1 );
|
||||
return(start_profilers(TIMER_DEFAULT));
|
||||
}
|
||||
|
||||
static Int profison(void) {
|
||||
static Int profison( USES_REGS1 ) {
|
||||
return (ProfilerOn > 0);
|
||||
}
|
||||
|
||||
static Int profalt(void) {
|
||||
static Int profalt( USES_REGS1 ) {
|
||||
if (ProfilerOn==0) return(FALSE);
|
||||
if (ProfilerOn==-1) return profon();
|
||||
return profoff();
|
||||
if (ProfilerOn==-1) return profon( PASS_REGS1 );
|
||||
return profoff( PASS_REGS1 );
|
||||
}
|
||||
|
||||
static Int profend(void)
|
||||
static Int profend( USES_REGS1 )
|
||||
{
|
||||
if (ProfilerOn==0) return(FALSE);
|
||||
profoff(); /* Make sure profiler is off */
|
||||
profoff( PASS_REGS1 ); /* Make sure profiler is off */
|
||||
ProfilerOn=0;
|
||||
if (Yap_OffLineProfiler) {
|
||||
fclose(FProf);
|
||||
@ -1198,7 +1202,7 @@ static Int profend(void)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int getpredinfo(void)
|
||||
static Int getpredinfo( USES_REGS1 )
|
||||
{
|
||||
PredEntry *pp = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
||||
Term mod, name;
|
||||
@ -1234,8 +1238,8 @@ static Int getpredinfo(void)
|
||||
Yap_unify(ARG4, MkIntegerTerm(arity));
|
||||
}
|
||||
|
||||
static Int profres0(void) {
|
||||
return(showprofres());
|
||||
static Int profres0( USES_REGS1 ) {
|
||||
return(showprofres( PASS_REGS1 ));
|
||||
}
|
||||
|
||||
#endif /* LOW_PROF */
|
||||
|
309
C/grow.c
309
C/grow.c
@ -57,47 +57,48 @@ static Int total_trail_overflow_time = 0;
|
||||
static int atom_table_overflows = 0;
|
||||
static Int total_atom_table_overflow_time = 0;
|
||||
|
||||
STATIC_PROTO(Int p_growheap, (void));
|
||||
STATIC_PROTO(Int p_growstack, (void));
|
||||
STATIC_PROTO(Int p_inform_trail_overflows, (void));
|
||||
STATIC_PROTO(Int p_inform_heap_overflows, (void));
|
||||
STATIC_PROTO(Int p_inform_stack_overflows, (void));
|
||||
STATIC_PROTO(Int p_growheap, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_growstack, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_inform_trail_overflows, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_inform_heap_overflows, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_inform_stack_overflows, ( USES_REGS1 ));
|
||||
|
||||
/* #define undf7 */
|
||||
/* #define undf5 */
|
||||
|
||||
STATIC_PROTO(int growstack, (long));
|
||||
STATIC_PROTO(void MoveGlobal, (void));
|
||||
STATIC_PROTO(void MoveLocalAndTrail, (void));
|
||||
STATIC_PROTO(void SetHeapRegs, (int));
|
||||
STATIC_PROTO(void AdjustTrail, (int, int));
|
||||
STATIC_PROTO(void AdjustLocal, (int));
|
||||
STATIC_PROTO(void AdjustGlobal, (long, int));
|
||||
STATIC_PROTO(void AdjustGrowStack, (void));
|
||||
STATIC_PROTO(int static_growheap, (long,int,struct intermediates *,tr_fr_ptr *, TokEntry **, VarEntry **));
|
||||
STATIC_PROTO(int growstack, (long CACHE_TYPE));
|
||||
STATIC_PROTO(void MoveGlobal, ( CACHE_TYPE1 ));
|
||||
STATIC_PROTO(void MoveLocalAndTrail, ( CACHE_TYPE1 ));
|
||||
STATIC_PROTO(void SetHeapRegs, (int CACHE_TYPE));
|
||||
STATIC_PROTO(void AdjustTrail, (int, int CACHE_TYPE));
|
||||
STATIC_PROTO(void AdjustLocal, (int CACHE_TYPE));
|
||||
STATIC_PROTO(void AdjustGlobal, (long, int CACHE_TYPE));
|
||||
STATIC_PROTO(void AdjustGrowStack, ( CACHE_TYPE1 ));
|
||||
STATIC_PROTO(int static_growheap, (long,int,struct intermediates *,tr_fr_ptr *, TokEntry **, VarEntry ** CACHE_TYPE));
|
||||
STATIC_PROTO(void cpcellsd, (CELL *, CELL *, CELL));
|
||||
STATIC_PROTO(CELL AdjustAppl, (CELL));
|
||||
STATIC_PROTO(CELL AdjustPair, (CELL));
|
||||
STATIC_PROTO(void AdjustStacksAndTrail, (long, int));
|
||||
STATIC_PROTO(void AdjustRegs, (int));
|
||||
STATIC_PROTO(Term AdjustGlobTerm, (Term));
|
||||
STATIC_PROTO(CELL AdjustAppl, (CELL CACHE_TYPE));
|
||||
STATIC_PROTO(CELL AdjustPair, (CELL CACHE_TYPE));
|
||||
STATIC_PROTO(void AdjustStacksAndTrail, (long, int CACHE_TYPE));
|
||||
STATIC_PROTO(void AdjustRegs, (int CACHE_TYPE));
|
||||
STATIC_PROTO(Term AdjustGlobTerm, (Term CACHE_TYPE));
|
||||
|
||||
static void
|
||||
LeaveGrowMode(prolog_exec_mode grow_mode)
|
||||
{
|
||||
Yap_PrologMode &= ~grow_mode;
|
||||
if (Yap_PrologMode & AbortMode) {
|
||||
CACHE_REGS
|
||||
Yap_PrologMode &= ~AbortMode;
|
||||
Yap_Error(PURE_ABORT, TermNil, "");
|
||||
/* in case someone mangles the P register */
|
||||
save_machine_regs();
|
||||
Yap_Error(PURE_ABORT, TermNil, "");
|
||||
/* in case someone mangles the P register */
|
||||
save_machine_regs();
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
/* don't even think about trying this */
|
||||
/* don't even think about trying this */
|
||||
#else
|
||||
#if PUSH_REGS
|
||||
restore_absmi_regs(&Yap_standard_regs);
|
||||
restore_absmi_regs(&Yap_standard_regs);
|
||||
#endif
|
||||
siglongjmp (Yap_RestartEnv, 1);
|
||||
siglongjmp (Yap_RestartEnv, 1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -117,7 +118,7 @@ cpcellsd(register CELL *Dest, register CELL *Org, CELL NOf)
|
||||
|
||||
|
||||
static void
|
||||
SetHeapRegs(int copying_threads)
|
||||
SetHeapRegs(int copying_threads USES_REGS)
|
||||
{
|
||||
#ifdef undf7
|
||||
fprintf(Yap_stderr,"HeapBase = %x\tHeapTop=%x\nGlobalBase=%x\tGlobalTop=%x\nLocalBase=%x\tLocatTop=%x\n", Yap_HeapBase, HeapTop, Yap_GlobalBase, H, LCL0, ASP);
|
||||
@ -203,7 +204,7 @@ SetHeapRegs(int copying_threads)
|
||||
}
|
||||
|
||||
static void
|
||||
MoveLocalAndTrail(void)
|
||||
MoveLocalAndTrail( USES_REGS1 )
|
||||
{
|
||||
/* cpcellsd(To,From,NOfCells) - copy the cells downwards */
|
||||
#if USE_SYSTEM_MALLOC
|
||||
@ -216,7 +217,7 @@ MoveLocalAndTrail(void)
|
||||
#ifdef THREADS
|
||||
|
||||
static void
|
||||
CopyLocalAndTrail(void)
|
||||
CopyLocalAndTrail( USES_REGS1 )
|
||||
{
|
||||
/* cpcellsd(To,From,NOfCells) - copy the cells downwards */
|
||||
#if USE_SYSTEM_MALLOC
|
||||
@ -225,7 +226,7 @@ CopyLocalAndTrail(void)
|
||||
}
|
||||
|
||||
static void
|
||||
IncrementalCopyStacksFromWorker(void)
|
||||
IncrementalCopyStacksFromWorker( USES_REGS1 )
|
||||
{
|
||||
memcpy((void *) PtoGloAdjust((CELL *)LOCAL_start_global_copy),
|
||||
(void *) (LOCAL_start_global_copy),
|
||||
@ -244,18 +245,18 @@ worker_p_binding(int worker_p, CELL *aux_ptr)
|
||||
{
|
||||
if (aux_ptr > H) {
|
||||
CELL reg = FOREIGN_ThreadHandle(worker_p).current_yaam_regs->LCL0_[aux_ptr-LCL0];
|
||||
reg = AdjustGlobTerm(reg);
|
||||
reg = AdjustGlobTerm(reg PASS_REGS);
|
||||
return reg;
|
||||
} else {
|
||||
CELL reg = FOREIGN_ThreadHandle(worker_p).current_yaam_regs-> H0_[aux_ptr-H0];
|
||||
reg = AdjustGlobTerm(reg);
|
||||
reg = AdjustGlobTerm(reg PASS_REGS);
|
||||
return reg;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
RestoreTrail(int worker_p)
|
||||
RestoreTrail(int worker_p USES_REGS)
|
||||
{
|
||||
tr_fr_ptr aux_tr;
|
||||
|
||||
@ -311,17 +312,17 @@ RestoreTrail(int worker_p)
|
||||
#endif /* YAPOR && THREADS */
|
||||
|
||||
static void
|
||||
MoveGlobal(void)
|
||||
MoveGlobal( USES_REGS1 )
|
||||
{
|
||||
/*
|
||||
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
|
||||
* absmi.asm
|
||||
*/
|
||||
cpcellsd((CELL *)Yap_GlobalBase, (CELL *)OldGlobalBase, OldH - (CELL *)OldGlobalBase);
|
||||
cpcellsd((CELL *)Yap_GlobalBase, (CELL *)OldGlobalBase, OldH - (CELL *)OldGlobalBase);
|
||||
}
|
||||
|
||||
static void
|
||||
MoveExpandedGlobal(void)
|
||||
MoveExpandedGlobal( USES_REGS1 )
|
||||
{
|
||||
/*
|
||||
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
|
||||
@ -331,7 +332,7 @@ MoveExpandedGlobal(void)
|
||||
}
|
||||
|
||||
static void
|
||||
MoveGlobalWithHole(void)
|
||||
MoveGlobalWithHole( USES_REGS1 )
|
||||
{
|
||||
/*
|
||||
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
|
||||
@ -345,7 +346,7 @@ MoveGlobalWithHole(void)
|
||||
}
|
||||
|
||||
static void
|
||||
MoveHalfGlobal(CELL *OldPt)
|
||||
MoveHalfGlobal(CELL *OldPt USES_REGS)
|
||||
{
|
||||
/*
|
||||
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
|
||||
@ -358,7 +359,7 @@ MoveHalfGlobal(CELL *OldPt)
|
||||
}
|
||||
|
||||
static inline CELL
|
||||
AdjustAppl(register CELL t0)
|
||||
AdjustAppl(register CELL t0 USES_REGS)
|
||||
{
|
||||
register CELL *t = RepAppl(t0);
|
||||
|
||||
@ -378,7 +379,7 @@ AdjustAppl(register CELL t0)
|
||||
}
|
||||
|
||||
static inline CELL
|
||||
AdjustPair(register CELL t0)
|
||||
AdjustPair(register CELL t0 USES_REGS)
|
||||
{
|
||||
register CELL *t = RepPair(t0);
|
||||
|
||||
@ -395,7 +396,7 @@ AdjustPair(register CELL t0)
|
||||
}
|
||||
|
||||
static void
|
||||
AdjustTrail(int adjusting_heap, int thread_copying)
|
||||
AdjustTrail(int adjusting_heap, int thread_copying USES_REGS)
|
||||
{
|
||||
volatile tr_fr_ptr ptt, tr_base = (tr_fr_ptr)Yap_TrailBase;
|
||||
|
||||
@ -428,12 +429,12 @@ AdjustTrail(int adjusting_heap, int thread_copying)
|
||||
RESET_VARIABLE(&TrailTerm(ptt));
|
||||
}
|
||||
} else if (IsPairTerm(reg)) {
|
||||
TrailTerm(ptt) = AdjustPair(reg);
|
||||
TrailTerm(ptt) = AdjustPair(reg PASS_REGS);
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES /* does not work with new structures */
|
||||
/* check it whether we are protecting a
|
||||
multi-assignment */
|
||||
} else if (IsApplTerm(reg)) {
|
||||
TrailTerm(ptt) = AdjustAppl(reg);
|
||||
TrailTerm(ptt) = AdjustAppl(reg PASS_REGS);
|
||||
#endif
|
||||
}
|
||||
#ifdef FROZEN_STACKS
|
||||
@ -445,9 +446,9 @@ AdjustTrail(int adjusting_heap, int thread_copying)
|
||||
else if (IsOldTrail(reg2))
|
||||
TrailVal(ptt) = TrailAdjust(reg2);
|
||||
} else if (IsApplTerm(reg2)) {
|
||||
TrailVal(ptt) = AdjustAppl(reg2);
|
||||
TrailVal(ptt) = AdjustAppl(reg2 PASS_REGS);
|
||||
} else if (IsPairTerm(reg2)) {
|
||||
TrailVal(ptt) = AdjustPair(reg2);
|
||||
TrailVal(ptt) = AdjustPair(reg2 PASS_REGS);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -455,7 +456,7 @@ AdjustTrail(int adjusting_heap, int thread_copying)
|
||||
}
|
||||
|
||||
static void
|
||||
AdjustLocal(int thread_copying)
|
||||
AdjustLocal(int thread_copying USES_REGS)
|
||||
{
|
||||
register CELL reg, *pt, *pt_bot;
|
||||
|
||||
@ -483,16 +484,16 @@ AdjustLocal(int thread_copying)
|
||||
else if (IsOldCode(reg))
|
||||
*pt = CodeAdjust(reg);
|
||||
} else if (IsApplTerm(reg)) {
|
||||
*pt = AdjustAppl(reg);
|
||||
*pt = AdjustAppl(reg PASS_REGS);
|
||||
} else if (IsPairTerm(reg)) {
|
||||
*pt = AdjustPair(reg);
|
||||
*pt = AdjustPair(reg PASS_REGS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static Term
|
||||
AdjustGlobTerm(Term reg)
|
||||
AdjustGlobTerm(Term reg USES_REGS)
|
||||
{
|
||||
if (IsVarTerm(reg)) {
|
||||
if (IsOldGlobal(reg))
|
||||
@ -504,16 +505,16 @@ AdjustGlobTerm(Term reg)
|
||||
return TrailAdjust(reg);
|
||||
#endif
|
||||
} else if (IsApplTerm(reg))
|
||||
return AdjustAppl(reg);
|
||||
return AdjustAppl(reg PASS_REGS);
|
||||
else if (IsPairTerm(reg))
|
||||
return AdjustPair(reg);
|
||||
return AdjustPair(reg PASS_REGS);
|
||||
return AtomTermAdjust(reg);
|
||||
}
|
||||
|
||||
static volatile CELL *cpt=NULL;
|
||||
|
||||
static void
|
||||
AdjustGlobal(long sz, int thread_copying)
|
||||
AdjustGlobal(long sz, int thread_copying USES_REGS)
|
||||
{
|
||||
CELL *pt, *pt_max;
|
||||
ArrayEntry *al = DynamicArrays;
|
||||
@ -521,13 +522,13 @@ AdjustGlobal(long sz, int thread_copying)
|
||||
GlobalEntry *gl = GlobalVariables;
|
||||
|
||||
while (al) {
|
||||
al->ValueOfVE = AdjustGlobTerm(al->ValueOfVE);
|
||||
al->ValueOfVE = AdjustGlobTerm(al->ValueOfVE PASS_REGS);
|
||||
al = al->NextAE;
|
||||
}
|
||||
while (gl) {
|
||||
if (IsVarTerm(gl->global) ||
|
||||
!IsAtomOrIntTerm(gl->global)) {
|
||||
gl->global = AdjustGlobTerm(gl->global);
|
||||
gl->global = AdjustGlobTerm(gl->global PASS_REGS);
|
||||
}
|
||||
gl = gl->NextGE;
|
||||
}
|
||||
@ -538,7 +539,7 @@ AdjustGlobal(long sz, int thread_copying)
|
||||
/* sal->ValueOfVE.lterms[i].tlive = AdjustGlobTerm(sal->ValueOfVE.lterms[i].tlive); */
|
||||
Term tlive = sal->ValueOfVE.lterms[i].tlive;
|
||||
if (!IsVarTerm(tlive) || !IsUnboundVar(&sal->ValueOfVE.lterms[i].tlive)) {
|
||||
sal->ValueOfVE.lterms[i].tlive = AdjustGlobTerm(sal->ValueOfVE.lterms[i].tlive);
|
||||
sal->ValueOfVE.lterms[i].tlive = AdjustGlobTerm(sal->ValueOfVE.lterms[i].tlive PASS_REGS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -607,9 +608,9 @@ AdjustGlobal(long sz, int thread_copying)
|
||||
*pt = TrailAdjust(reg);
|
||||
#endif
|
||||
} else if (IsApplTerm(reg))
|
||||
*pt = AdjustAppl(reg);
|
||||
*pt = AdjustAppl(reg PASS_REGS);
|
||||
else if (IsPairTerm(reg))
|
||||
*pt = AdjustPair(reg);
|
||||
*pt = AdjustPair(reg PASS_REGS);
|
||||
else if (IsAtomTerm(reg))
|
||||
*pt = AtomTermAdjust(reg);
|
||||
pt++;
|
||||
@ -622,17 +623,18 @@ AdjustGlobal(long sz, int thread_copying)
|
||||
* (just once) the trail cells pointing both to the global and to the local
|
||||
*/
|
||||
static void
|
||||
AdjustStacksAndTrail(long sz, int copying_threads)
|
||||
AdjustStacksAndTrail(long sz, int copying_threads USES_REGS)
|
||||
{
|
||||
AdjustTrail(TRUE, copying_threads);
|
||||
AdjustLocal(copying_threads);
|
||||
AdjustGlobal(sz, copying_threads);
|
||||
AdjustTrail(TRUE, copying_threads PASS_REGS);
|
||||
AdjustLocal(copying_threads PASS_REGS);
|
||||
AdjustGlobal(sz, copying_threads PASS_REGS);
|
||||
}
|
||||
|
||||
void
|
||||
Yap_AdjustStacksAndTrail(void)
|
||||
{
|
||||
AdjustStacksAndTrail(0, FALSE);
|
||||
CACHE_REGS
|
||||
AdjustStacksAndTrail(0, FALSE PASS_REGS);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -640,14 +642,14 @@ Yap_AdjustStacksAndTrail(void)
|
||||
* local; the trail cells pointing to the local
|
||||
*/
|
||||
static void
|
||||
AdjustGrowStack(void)
|
||||
AdjustGrowStack( USES_REGS1 )
|
||||
{
|
||||
AdjustTrail(FALSE, STACK_SHIFTING);
|
||||
AdjustLocal(STACK_SHIFTING);
|
||||
AdjustTrail(FALSE, STACK_SHIFTING PASS_REGS);
|
||||
AdjustLocal(STACK_SHIFTING PASS_REGS);
|
||||
}
|
||||
|
||||
static void
|
||||
AdjustRegs(int n)
|
||||
AdjustRegs(int n USES_REGS)
|
||||
{
|
||||
int i;
|
||||
CELL reg;
|
||||
@ -664,28 +666,28 @@ AdjustRegs(int n)
|
||||
else if (IsOldCode(reg))
|
||||
reg = CodeAdjust(reg);
|
||||
} else if (IsApplTerm(reg))
|
||||
reg = AdjustAppl(reg);
|
||||
reg = AdjustAppl(reg PASS_REGS);
|
||||
else if (IsPairTerm(reg))
|
||||
reg = AdjustPair(reg);
|
||||
reg = AdjustPair(reg PASS_REGS);
|
||||
XREGS[i] = (Term) reg;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
AdjustVarTable(VarEntry *ves)
|
||||
AdjustVarTable(VarEntry *ves USES_REGS)
|
||||
{
|
||||
ves->VarAdr = TermNil;
|
||||
if (ves->VarRight != NULL) {
|
||||
if (IsOldVarTableTrailPtr(ves->VarRight)) {
|
||||
ves->VarRight = (VarEntry *)TrailAddrAdjust((ADDR)(ves->VarRight));
|
||||
}
|
||||
AdjustVarTable(ves->VarRight);
|
||||
AdjustVarTable(ves->VarRight PASS_REGS);
|
||||
}
|
||||
if (ves->VarLeft != NULL) {
|
||||
if (IsOldVarTableTrailPtr(ves->VarLeft)) {
|
||||
ves->VarLeft = (VarEntry *)TrailAddrAdjust((ADDR)(ves->VarLeft));
|
||||
}
|
||||
AdjustVarTable(ves->VarLeft);
|
||||
AdjustVarTable(ves->VarLeft PASS_REGS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -694,7 +696,7 @@ AdjustVarTable(VarEntry *ves)
|
||||
pointers created by the scanner (Tokens and Variables)
|
||||
*/
|
||||
static void
|
||||
AdjustScannerStacks(TokEntry **tksp, VarEntry **vep)
|
||||
AdjustScannerStacks(TokEntry **tksp, VarEntry **vep USES_REGS)
|
||||
{
|
||||
TokEntry *tks = *tksp;
|
||||
VarEntry *ves = *vep;
|
||||
@ -731,7 +733,7 @@ AdjustScannerStacks(TokEntry **tksp, VarEntry **vep)
|
||||
if (ves != NULL) {
|
||||
if (IsOldVarTableTrailPtr(ves))
|
||||
ves = *vep = (VarEntry *)TrailAddrAdjust((ADDR)ves);
|
||||
AdjustVarTable(ves);
|
||||
AdjustVarTable(ves PASS_REGS);
|
||||
}
|
||||
ves = Yap_AnonVarTable;
|
||||
if (ves != NULL) {
|
||||
@ -754,12 +756,13 @@ AdjustScannerStacks(TokEntry **tksp, VarEntry **vep)
|
||||
void
|
||||
Yap_AdjustRegs(int n)
|
||||
{
|
||||
AdjustRegs(n);
|
||||
CACHE_REGS
|
||||
AdjustRegs(n PASS_REGS);
|
||||
}
|
||||
|
||||
/* Used by do_goal() when we're short of heap space */
|
||||
static int
|
||||
static_growheap(long size, int fix_code, struct intermediates *cip, tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
static_growheap(long size, int fix_code, struct intermediates *cip, tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep USES_REGS)
|
||||
{
|
||||
UInt start_growth_time, growth_time;
|
||||
int gc_verbose;
|
||||
@ -803,29 +806,29 @@ static_growheap(long size, int fix_code, struct intermediates *cip, tr_fr_ptr *o
|
||||
TrDiff = LDiff = GDiff = GDiff0 = DelayDiff = BaseDiff = size;
|
||||
XDiff = HDiff = 0;
|
||||
GSplit = NULL;
|
||||
SetHeapRegs(FALSE);
|
||||
MoveLocalAndTrail();
|
||||
SetHeapRegs(FALSE PASS_REGS);
|
||||
MoveLocalAndTrail( PASS_REGS1 );
|
||||
if (fix_code) {
|
||||
CELL *SaveOldH = OldH;
|
||||
OldH = (CELL *)cip->freep;
|
||||
MoveGlobal();
|
||||
MoveGlobal( PASS_REGS1 );
|
||||
OldH = SaveOldH;
|
||||
} else {
|
||||
MoveGlobal();
|
||||
MoveGlobal( PASS_REGS1 );
|
||||
}
|
||||
if (old_trp) {
|
||||
tr_fr_ptr nTR;
|
||||
|
||||
AdjustScannerStacks(tksp, vep);
|
||||
AdjustScannerStacks(tksp, vep PASS_REGS);
|
||||
nTR = TR;
|
||||
*old_trp = PtoTRAdjust(*old_trp);
|
||||
TR = *old_trp;
|
||||
AdjustStacksAndTrail(0, FALSE);
|
||||
AdjustStacksAndTrail(0, FALSE PASS_REGS);
|
||||
TR = nTR;
|
||||
} else {
|
||||
AdjustStacksAndTrail(0, FALSE);
|
||||
AdjustStacksAndTrail(0, FALSE PASS_REGS);
|
||||
}
|
||||
AdjustRegs(MaxTemps);
|
||||
AdjustRegs(MaxTemps PASS_REGS);
|
||||
YAPLeaveCriticalSection();
|
||||
ASP += 256;
|
||||
if (minimal_request)
|
||||
@ -842,7 +845,7 @@ static_growheap(long size, int fix_code, struct intermediates *cip, tr_fr_ptr *o
|
||||
/* Used when we're short of heap, usually because of an overflow in
|
||||
the attributed stack, but also because we allocated a zone */
|
||||
static int
|
||||
static_growglobal(long request, CELL **ptr, CELL *hsplit)
|
||||
static_growglobal(long request, CELL **ptr, CELL *hsplit USES_REGS)
|
||||
{
|
||||
UInt start_growth_time, growth_time;
|
||||
int gc_verbose;
|
||||
@ -980,24 +983,24 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit)
|
||||
GSplit = hsplit;
|
||||
XDiff = HDiff = 0;
|
||||
Yap_GlobalBase = old_GlobalBase;
|
||||
SetHeapRegs(FALSE);
|
||||
SetHeapRegs(FALSE PASS_REGS);
|
||||
if (do_grow) {
|
||||
MoveLocalAndTrail();
|
||||
MoveLocalAndTrail( PASS_REGS1 );
|
||||
if (hsplit) {
|
||||
MoveGlobalWithHole();
|
||||
MoveGlobalWithHole( PASS_REGS1 );
|
||||
} else {
|
||||
MoveExpandedGlobal();
|
||||
MoveExpandedGlobal( PASS_REGS1 );
|
||||
}
|
||||
} else if (!hsplit) {
|
||||
MoveExpandedGlobal();
|
||||
MoveExpandedGlobal( PASS_REGS1 );
|
||||
}
|
||||
/* don't run through garbage */
|
||||
if (hsplit && (OldH != hsplit)) {
|
||||
AdjustStacksAndTrail(request, FALSE);
|
||||
AdjustStacksAndTrail(request, FALSE PASS_REGS);
|
||||
} else {
|
||||
AdjustStacksAndTrail(0, FALSE);
|
||||
AdjustStacksAndTrail(0, FALSE PASS_REGS);
|
||||
}
|
||||
AdjustRegs(MaxTemps);
|
||||
AdjustRegs(MaxTemps PASS_REGS);
|
||||
if (ptr) {
|
||||
*ptr = PtoLocAdjust(*ptr);
|
||||
}
|
||||
@ -1006,7 +1009,7 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit)
|
||||
/* we have things not quite where we want to have them */
|
||||
cpcellsd((CELL *)(omax+DelayDiff), (CELL *)(omax+GDiff0), (ADDR)hsplit-omax);
|
||||
} else {
|
||||
MoveHalfGlobal(hsplit);
|
||||
MoveHalfGlobal(hsplit PASS_REGS);
|
||||
}
|
||||
}
|
||||
YAPLeaveCriticalSection();
|
||||
@ -1028,7 +1031,7 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit)
|
||||
}
|
||||
|
||||
static void
|
||||
fix_compiler_instructions(PInstr *pcpc)
|
||||
fix_compiler_instructions(PInstr *pcpc USES_REGS)
|
||||
{
|
||||
while (pcpc != NULL) {
|
||||
PInstr *ncpc = pcpc->nextInst;
|
||||
@ -1071,7 +1074,7 @@ fix_compiler_instructions(PInstr *pcpc)
|
||||
case unify_last_float_op:
|
||||
case write_float_op:
|
||||
/* floats might be in the global */
|
||||
pcpc->rnd1 = AdjustAppl(pcpc->rnd1);
|
||||
pcpc->rnd1 = AdjustAppl(pcpc->rnd1 PASS_REGS);
|
||||
break;
|
||||
/* hopefully nothing to do */
|
||||
case nop_op:
|
||||
@ -1215,7 +1218,7 @@ fix_compiler_instructions(PInstr *pcpc)
|
||||
|
||||
#ifdef TABLING
|
||||
static void
|
||||
fix_tabling_info(void)
|
||||
fix_tabling_info( USES_REGS1 )
|
||||
{
|
||||
/* we must fix the dependency frames and the subgoal frames, as they are
|
||||
pointing back to the global stack. */
|
||||
@ -1239,7 +1242,7 @@ fix_tabling_info(void)
|
||||
#endif /* TABLING */
|
||||
|
||||
static int
|
||||
do_growheap(int fix_code, UInt in_size, struct intermediates *cip, tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
do_growheap(int fix_code, UInt in_size, struct intermediates *cip, tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep USES_REGS)
|
||||
{
|
||||
unsigned long size = sizeof(CELL) * K16;
|
||||
int shift_factor = (heap_overflows > 8 ? 8 : heap_overflows);
|
||||
@ -1257,7 +1260,7 @@ do_growheap(int fix_code, UInt in_size, struct intermediates *cip, tr_fr_ptr *ol
|
||||
size = YAP_ALLOC_SIZE;
|
||||
sz = AdjustPageSize(SizeOfOverflow);
|
||||
}
|
||||
while(sz >= sizeof(CELL) * K16 && !static_growheap(sz, fix_code, cip, old_trp, tksp, vep)) {
|
||||
while(sz >= sizeof(CELL) * K16 && !static_growheap(sz, fix_code, cip, old_trp, tksp, vep PASS_REGS)) {
|
||||
size = size/2;
|
||||
sz = size << shift_factor;
|
||||
if (sz < in_size) {
|
||||
@ -1270,17 +1273,17 @@ do_growheap(int fix_code, UInt in_size, struct intermediates *cip, tr_fr_ptr *ol
|
||||
if (pcpc != NULL) {
|
||||
cip->CodeStart = pcpc = (PInstr *)GlobalAddrAdjust((ADDR)pcpc);
|
||||
}
|
||||
fix_compiler_instructions(pcpc);
|
||||
fix_compiler_instructions(pcpc PASS_REGS);
|
||||
pcpc = cip->BlobsStart;
|
||||
if (pcpc != NULL) {
|
||||
cip->BlobsStart = pcpc = (PInstr *)GlobalAddrAdjust((ADDR)pcpc);
|
||||
}
|
||||
fix_compiler_instructions(pcpc);
|
||||
fix_compiler_instructions(pcpc PASS_REGS);
|
||||
cip->freep = (char *)GlobalAddrAdjust((ADDR)cip->freep);
|
||||
cip->label_offset = (Int *)GlobalAddrAdjust((ADDR)cip->label_offset);
|
||||
}
|
||||
#ifdef TABLING
|
||||
fix_tabling_info();
|
||||
fix_tabling_info( PASS_REGS1 );
|
||||
#endif /* TABLING */
|
||||
if (sz >= sizeof(CELL) * K16) {
|
||||
LOCK(SignalLock);
|
||||
@ -1331,7 +1334,7 @@ cp_atom_table(AtomHashEntry *ntb, UInt nsize)
|
||||
}
|
||||
|
||||
static int
|
||||
growatomtable(void)
|
||||
growatomtable( USES_REGS1 )
|
||||
{
|
||||
AtomHashEntry *ntb;
|
||||
UInt nsize = 4*AtomHashTableSize-1;
|
||||
@ -1379,7 +1382,7 @@ growatomtable(void)
|
||||
/* make sure there is no heap overflow */
|
||||
int res;
|
||||
YAPEnterCriticalSection();
|
||||
res = do_growheap(FALSE, 0, NULL, NULL, NULL, NULL);
|
||||
res = do_growheap(FALSE, 0, NULL, NULL, NULL, NULL PASS_REGS);
|
||||
YAPLeaveCriticalSection();
|
||||
return res;
|
||||
} else {
|
||||
@ -1392,16 +1395,17 @@ growatomtable(void)
|
||||
int
|
||||
Yap_growheap(int fix_code, UInt in_size, void *cip)
|
||||
{
|
||||
CACHE_REGS
|
||||
int res;
|
||||
|
||||
if (NOfAtoms > 2*AtomHashTableSize) {
|
||||
UInt n = NOfAtoms;
|
||||
if (AGcThreshold)
|
||||
Yap_atom_gc();
|
||||
Yap_atom_gc( PASS_REGS1 );
|
||||
/* check if we have a significant improvement from agc */
|
||||
if (n > NOfAtoms+ NOfAtoms/10 ||
|
||||
NOfAtoms > 2*AtomHashTableSize) {
|
||||
res = growatomtable();
|
||||
res = growatomtable( PASS_REGS1 );
|
||||
} else {
|
||||
LOCK(SignalLock);
|
||||
if (ActiveSignals == YAP_CDOVF_SIGNAL) {
|
||||
@ -1414,7 +1418,7 @@ Yap_growheap(int fix_code, UInt in_size, void *cip)
|
||||
LeaveGrowMode(GrowHeapMode);
|
||||
return res;
|
||||
}
|
||||
res=do_growheap(fix_code, in_size, (struct intermediates *)cip, NULL, NULL, NULL);
|
||||
res=do_growheap(fix_code, in_size, (struct intermediates *)cip, NULL, NULL, NULL PASS_REGS);
|
||||
LeaveGrowMode(GrowHeapMode);
|
||||
return res;
|
||||
}
|
||||
@ -1422,9 +1426,10 @@ Yap_growheap(int fix_code, UInt in_size, void *cip)
|
||||
int
|
||||
Yap_growheap_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
{
|
||||
CACHE_REGS
|
||||
int res;
|
||||
|
||||
res=do_growheap(FALSE, 0L, NULL, old_trp, tksp, vep);
|
||||
res=do_growheap(FALSE, 0L, NULL, old_trp, tksp, vep PASS_REGS);
|
||||
LeaveGrowMode(GrowHeapMode);
|
||||
return res;
|
||||
}
|
||||
@ -1432,6 +1437,7 @@ Yap_growheap_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
int
|
||||
Yap_growglobal(CELL **ptr)
|
||||
{
|
||||
CACHE_REGS
|
||||
unsigned long sz = sizeof(CELL) * K16;
|
||||
|
||||
#if defined(YAPOR) && !defined(THREADS)
|
||||
@ -1445,10 +1451,10 @@ Yap_growglobal(CELL **ptr)
|
||||
return(FALSE);
|
||||
}
|
||||
#endif
|
||||
if ( static_growglobal(sz, ptr, NULL) == 0)
|
||||
if ( static_growglobal(sz, ptr, NULL PASS_REGS) == 0)
|
||||
return FALSE;
|
||||
#ifdef TABLING
|
||||
fix_tabling_info();
|
||||
fix_tabling_info( PASS_REGS1 );
|
||||
#endif /* TABLING */
|
||||
return TRUE;
|
||||
}
|
||||
@ -1457,10 +1463,11 @@ Yap_growglobal(CELL **ptr)
|
||||
UInt
|
||||
Yap_InsertInGlobal(CELL *where, UInt howmuch)
|
||||
{
|
||||
if ((howmuch = static_growglobal(howmuch, NULL, where)) == 0)
|
||||
CACHE_REGS
|
||||
if ((howmuch = static_growglobal(howmuch, NULL, where PASS_REGS)) == 0)
|
||||
return 0;
|
||||
#ifdef TABLING
|
||||
fix_tabling_info();
|
||||
fix_tabling_info( PASS_REGS1 );
|
||||
#endif /* TABLING */
|
||||
return howmuch;
|
||||
}
|
||||
@ -1469,16 +1476,17 @@ Yap_InsertInGlobal(CELL *where, UInt howmuch)
|
||||
int
|
||||
Yap_growstack(long size)
|
||||
{
|
||||
CACHE_REGS
|
||||
int res;
|
||||
|
||||
Yap_PrologMode |= GrowStackMode;
|
||||
res=growstack(size);
|
||||
res=growstack(size PASS_REGS);
|
||||
LeaveGrowMode(GrowStackMode);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
execute_growstack(long size0, int from_trail, int in_parser, tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
execute_growstack(long size0, int from_trail, int in_parser, tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep USES_REGS)
|
||||
{
|
||||
UInt minimal_request = 0L;
|
||||
long size = size0;
|
||||
@ -1526,50 +1534,50 @@ execute_growstack(long size0, int from_trail, int in_parser, tr_fr_ptr *old_trp,
|
||||
}
|
||||
#endif
|
||||
ASP -= 256;
|
||||
SetHeapRegs(FALSE);
|
||||
SetHeapRegs(FALSE PASS_REGS);
|
||||
if (from_trail) {
|
||||
Yap_TrailTop += size0;
|
||||
}
|
||||
if (LDiff) {
|
||||
MoveLocalAndTrail();
|
||||
MoveLocalAndTrail( PASS_REGS1 );
|
||||
}
|
||||
if (GDiff) {
|
||||
#if !USE_SYSTEM_MALLOC
|
||||
/* That is done by realloc */
|
||||
MoveGlobal();
|
||||
MoveGlobal( PASS_REGS1 );
|
||||
#endif
|
||||
if (in_parser) {
|
||||
tr_fr_ptr nTR;
|
||||
|
||||
AdjustScannerStacks(tksp, vep);
|
||||
AdjustScannerStacks(tksp, vep PASS_REGS);
|
||||
nTR = TR;
|
||||
*old_trp = PtoTRAdjust(*old_trp);
|
||||
TR = *old_trp;
|
||||
AdjustStacksAndTrail(0, FALSE);
|
||||
AdjustStacksAndTrail(0, FALSE PASS_REGS);
|
||||
TR = nTR;
|
||||
} else {
|
||||
AdjustStacksAndTrail(0, FALSE);
|
||||
AdjustStacksAndTrail(0, FALSE PASS_REGS);
|
||||
}
|
||||
AdjustRegs(MaxTemps);
|
||||
AdjustRegs(MaxTemps PASS_REGS);
|
||||
#ifdef TABLING
|
||||
fix_tabling_info();
|
||||
fix_tabling_info( PASS_REGS1 );
|
||||
#endif /* TABLING */
|
||||
} else if (LDiff) {
|
||||
if (in_parser) {
|
||||
tr_fr_ptr nTR;
|
||||
|
||||
AdjustScannerStacks(tksp, vep);
|
||||
AdjustScannerStacks(tksp, vep PASS_REGS);
|
||||
nTR = TR;
|
||||
*old_trp = PtoTRAdjust(*old_trp);
|
||||
TR = *old_trp;
|
||||
AdjustGrowStack();
|
||||
AdjustGrowStack( PASS_REGS1 );
|
||||
TR = nTR;
|
||||
} else {
|
||||
AdjustGrowStack();
|
||||
AdjustGrowStack( PASS_REGS1 );
|
||||
}
|
||||
AdjustRegs(MaxTemps);
|
||||
AdjustRegs(MaxTemps PASS_REGS);
|
||||
#ifdef TABLING
|
||||
fix_tabling_info();
|
||||
fix_tabling_info( PASS_REGS1 );
|
||||
#endif /* TABLING */
|
||||
}
|
||||
YAPLeaveCriticalSection();
|
||||
@ -1581,7 +1589,7 @@ execute_growstack(long size0, int from_trail, int in_parser, tr_fr_ptr *old_trp,
|
||||
|
||||
/* Used by do_goal() when we're short of stack space */
|
||||
static int
|
||||
growstack(long size)
|
||||
growstack(long size USES_REGS)
|
||||
{
|
||||
UInt start_growth_time, growth_time;
|
||||
int gc_verbose;
|
||||
@ -1605,7 +1613,7 @@ growstack(long size)
|
||||
(unsigned long int)(TR-(tr_fr_ptr)Yap_TrailBase),Yap_TrailBase,TR);
|
||||
fprintf(Yap_stderr, "%% Growing the stacks %ld bytes\n", size);
|
||||
}
|
||||
if (!execute_growstack(size, FALSE, FALSE, NULL, NULL, NULL))
|
||||
if (!execute_growstack(size, FALSE, FALSE, NULL, NULL, NULL PASS_REGS))
|
||||
return FALSE;
|
||||
growth_time = Yap_cputime()-start_growth_time;
|
||||
total_stack_overflow_time += growth_time;
|
||||
@ -1620,6 +1628,7 @@ growstack(long size)
|
||||
int
|
||||
Yap_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
{
|
||||
CACHE_REGS
|
||||
UInt size;
|
||||
UInt start_growth_time, growth_time;
|
||||
int gc_verbose;
|
||||
@ -1642,7 +1651,7 @@ Yap_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
(unsigned long int)(TR-(tr_fr_ptr)Yap_TrailBase),Yap_TrailBase,TR);
|
||||
fprintf(Yap_stderr, "%% Growing the stacks %ld bytes\n", (unsigned long int)size);
|
||||
}
|
||||
if (!execute_growstack(size, FALSE, TRUE, old_trp, tksp, vep)) {
|
||||
if (!execute_growstack(size, FALSE, TRUE, old_trp, tksp, vep PASS_REGS)) {
|
||||
LeaveGrowMode(GrowStackMode);
|
||||
return FALSE;
|
||||
}
|
||||
@ -1656,7 +1665,7 @@ Yap_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep USES_REGS)
|
||||
{
|
||||
UInt start_growth_time = Yap_cputime(), growth_time;
|
||||
int gc_verbose = Yap_is_gc_verbose();
|
||||
@ -1698,7 +1707,7 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr
|
||||
return FALSE;
|
||||
}
|
||||
#if USE_SYSTEM_MALLOC
|
||||
execute_growstack(size, TRUE, in_parser, old_trp, tksp, vep);
|
||||
execute_growstack(size, TRUE, in_parser, old_trp, tksp, vep PASS_REGS);
|
||||
#else
|
||||
if (!Yap_ExtendWorkSpace(size)) {
|
||||
Yap_ErrorMessage = NULL;
|
||||
@ -1707,12 +1716,12 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr
|
||||
trail_overflows--;
|
||||
return FALSE;
|
||||
}
|
||||
execute_growstack(size, TRUE, in_parser, old_trp, tksp, vep);
|
||||
execute_growstack(size, TRUE, in_parser, old_trp, tksp, vep PASS_REGS);
|
||||
} else {
|
||||
YAPEnterCriticalSection();
|
||||
if (in_parser) {
|
||||
TrDiff = LDiff = GDiff = BaseDiff = DelayDiff = XDiff = HDiff = GDiff0 = 0;
|
||||
AdjustScannerStacks(tksp, vep);
|
||||
AdjustScannerStacks(tksp, vep PASS_REGS);
|
||||
}
|
||||
Yap_TrailTop += size;
|
||||
YAPLeaveCriticalSection();
|
||||
@ -1738,18 +1747,21 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr
|
||||
int
|
||||
Yap_growtrail(long size, int contiguous_only)
|
||||
{
|
||||
return do_growtrail(size, contiguous_only, FALSE, NULL, NULL, NULL);
|
||||
CACHE_REGS
|
||||
return do_growtrail(size, contiguous_only, FALSE, NULL, NULL, NULL PASS_REGS);
|
||||
}
|
||||
|
||||
int
|
||||
Yap_growtrail_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
{
|
||||
return do_growtrail(0, FALSE, TRUE, old_trp, tksp, vep);
|
||||
CACHE_REGS
|
||||
return do_growtrail(0, FALSE, TRUE, old_trp, tksp, vep PASS_REGS);
|
||||
}
|
||||
|
||||
CELL **
|
||||
Yap_shift_visit(CELL **to_visit, CELL ***to_visit_maxp)
|
||||
{
|
||||
CACHE_REGS
|
||||
CELL **to_visit_max = *to_visit_maxp;
|
||||
/* relative position of top of stack */
|
||||
Int off = (ADDR)to_visit-AuxBase;
|
||||
@ -1786,7 +1798,7 @@ Yap_shift_visit(CELL **to_visit, CELL ***to_visit_maxp)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_inform_trail_overflows(void)
|
||||
p_inform_trail_overflows( USES_REGS1 )
|
||||
{
|
||||
Term tn = MkIntTerm(trail_overflows);
|
||||
Term tt = MkIntegerTerm(total_trail_overflow_time);
|
||||
@ -1796,7 +1808,7 @@ p_inform_trail_overflows(void)
|
||||
|
||||
/* :- grow_heap(Size) */
|
||||
static Int
|
||||
p_growheap(void)
|
||||
p_growheap( USES_REGS1 )
|
||||
{
|
||||
Int diff;
|
||||
Term t1 = Deref(ARG1);
|
||||
@ -1812,11 +1824,11 @@ p_growheap(void)
|
||||
if (diff < 0) {
|
||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t1, "grow_heap/1");
|
||||
}
|
||||
return(static_growheap(diff, FALSE, NULL, NULL, NULL, NULL));
|
||||
return(static_growheap(diff, FALSE, NULL, NULL, NULL, NULL PASS_REGS));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_inform_heap_overflows(void)
|
||||
p_inform_heap_overflows( USES_REGS1 )
|
||||
{
|
||||
Term tn = MkIntTerm(heap_overflows);
|
||||
Term tt = MkIntegerTerm(total_heap_overflow_time);
|
||||
@ -1828,6 +1840,7 @@ p_inform_heap_overflows(void)
|
||||
void
|
||||
Yap_CopyThreadStacks(int worker_q, int worker_p, int incremental)
|
||||
{
|
||||
CACHE_REGS
|
||||
Int size;
|
||||
|
||||
/* make sure both stacks have same size */
|
||||
@ -1865,9 +1878,9 @@ Yap_CopyThreadStacks(int worker_q, int worker_p, int incremental)
|
||||
DynamicArrays = NULL;
|
||||
StaticArrays = NULL;
|
||||
GlobalVariables = NULL;
|
||||
SetHeapRegs(TRUE);
|
||||
SetHeapRegs(TRUE PASS_REGS);
|
||||
if (incremental) {
|
||||
IncrementalCopyStacksFromWorker();
|
||||
IncrementalCopyStacksFromWorker( PASS_REGS1 );
|
||||
LOCAL_start_global_copy =
|
||||
(CELL)PtoGloAdjust((CELL *)LOCAL_start_global_copy);
|
||||
LOCAL_end_global_copy =
|
||||
@ -1880,20 +1893,20 @@ Yap_CopyThreadStacks(int worker_q, int worker_p, int incremental)
|
||||
(CELL)PtoTRAdjust((tr_fr_ptr)LOCAL_start_trail_copy);
|
||||
LOCAL_end_trail_copy =
|
||||
(CELL)PtoTRAdjust((tr_fr_ptr)LOCAL_end_trail_copy);
|
||||
AdjustStacksAndTrail(0, STACK_INCREMENTAL_COPYING);
|
||||
RestoreTrail(worker_p);
|
||||
AdjustStacksAndTrail(0, STACK_INCREMENTAL_COPYING PASS_REGS);
|
||||
RestoreTrail(worker_p PASS_REGS);
|
||||
TR = (tr_fr_ptr) LOCAL_end_trail_copy;
|
||||
} else {
|
||||
CopyLocalAndTrail();
|
||||
MoveGlobal();
|
||||
AdjustStacksAndTrail(0, STACK_COPYING);
|
||||
CopyLocalAndTrail( PASS_REGS1 );
|
||||
MoveGlobal( PASS_REGS1 );
|
||||
AdjustStacksAndTrail(0, STACK_COPYING PASS_REGS);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* :- grow_stack(Size) */
|
||||
static Int
|
||||
p_growstack(void)
|
||||
p_growstack( USES_REGS1 )
|
||||
{
|
||||
Int diff;
|
||||
Term t1 = Deref(ARG1);
|
||||
@ -1909,11 +1922,11 @@ p_growstack(void)
|
||||
if (diff < 0) {
|
||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t1, "grow_stack/1");
|
||||
}
|
||||
return(growstack(diff));
|
||||
return(growstack(diff PASS_REGS));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_inform_stack_overflows(void)
|
||||
p_inform_stack_overflows( USES_REGS1 )
|
||||
{ /* */
|
||||
Term tn = MkIntTerm(stack_overflows);
|
||||
Term tt = MkIntegerTerm(total_stack_overflow_time);
|
||||
|
515
C/heapgc.c
515
C/heapgc.c
File diff suppressed because it is too large
Load Diff
56
C/index.c
56
C/index.c
@ -830,6 +830,7 @@ sort_group(GroupDef *grp, CELL *top, struct intermediates *cint)
|
||||
|
||||
#if USE_SYSTEM_MALLOC
|
||||
if (!(base = (CELL *)Yap_AllocCodeSpace(2*max*sizeof(CELL)))) {
|
||||
CACHE_REGS
|
||||
save_machine_regs();
|
||||
Yap_Error_Size = 2*max*sizeof(CELL);
|
||||
siglongjmp(cint->CompilerBotch,2);
|
||||
@ -2003,6 +2004,7 @@ skip_to_arg(ClauseDef *clause, PredEntry *ap, UInt argno, int at_point)
|
||||
static UInt
|
||||
groups_in(ClauseDef *min, ClauseDef *max, GroupDef *grp, struct intermediates *cint)
|
||||
{
|
||||
CACHE_REGS
|
||||
UInt groups = 0;
|
||||
|
||||
while(min <= max) {
|
||||
@ -3000,6 +3002,7 @@ cls_head_info(ClauseDef *min, ClauseDef *max, UInt argno, int in_idb)
|
||||
static UInt
|
||||
do_index(ClauseDef *min, ClauseDef* max, struct intermediates *cint, UInt argno, UInt fail_l, int first, int clleft, CELL *top)
|
||||
{
|
||||
CACHE_REGS
|
||||
UInt ngroups, found_pvar = FALSE;
|
||||
UInt i = 0;
|
||||
GroupDef *group = (GroupDef *)top;
|
||||
@ -3137,6 +3140,7 @@ do_index(ClauseDef *min, ClauseDef* max, struct intermediates *cint, UInt argno,
|
||||
static ClauseDef *
|
||||
copy_clauses(ClauseDef *max0, ClauseDef *min0, CELL *top, struct intermediates *cint)
|
||||
{
|
||||
CACHE_REGS
|
||||
UInt sz = ((max0+1)-min0)*sizeof(ClauseDef);
|
||||
if ((char *)top + sz >= Yap_TrailTop-4096) {
|
||||
Yap_Error_Size = sz;
|
||||
@ -3319,6 +3323,7 @@ init_log_upd_clauses(ClauseDef *cl, PredEntry *ap)
|
||||
static UInt
|
||||
compile_index(struct intermediates *cint)
|
||||
{
|
||||
CACHE_REGS
|
||||
PredEntry *ap = cint->CurrentPred;
|
||||
int NClauses = ap->cs.p_code.NOfClauses;
|
||||
CELL *top = (CELL *) TR;
|
||||
@ -3382,6 +3387,7 @@ CleanCls(struct intermediates *cint)
|
||||
yamop *
|
||||
Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc)
|
||||
{
|
||||
CACHE_REGS
|
||||
yamop *indx_out;
|
||||
int setjres;
|
||||
struct intermediates cint;
|
||||
@ -3471,6 +3477,7 @@ Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc)
|
||||
static istack_entry *
|
||||
push_stack(istack_entry *sp, Int arg, Term Tag, Term extra, struct intermediates *cint)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (sp+1 > (istack_entry *)Yap_TrailTop) {
|
||||
save_machine_regs();
|
||||
siglongjmp(cint->CompilerBotch,4);
|
||||
@ -3917,6 +3924,7 @@ code_to_indexcl(yamop *ipc, int is_lu)
|
||||
|
||||
static yamop **
|
||||
expand_index(struct intermediates *cint) {
|
||||
CACHE_REGS
|
||||
/* first clause */
|
||||
PredEntry *ap = cint->CurrentPred;
|
||||
yamop *first, *last = NULL, *alt = NULL;
|
||||
@ -4485,7 +4493,7 @@ expand_index(struct intermediates *cint) {
|
||||
|
||||
|
||||
static yamop *
|
||||
ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop) {
|
||||
ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop USES_REGS) {
|
||||
yamop *indx_out, *expand_clauses;
|
||||
yamop **labp;
|
||||
int cb;
|
||||
@ -4496,6 +4504,7 @@ ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop) {
|
||||
cint.code_addr = NULL;
|
||||
cint.label_offset = NULL;
|
||||
if ((cb = sigsetjmp(cint.CompilerBotch, 0)) == 3) {
|
||||
CACHE_REGS
|
||||
restore_machine_regs();
|
||||
/* grow stack */
|
||||
recover_from_failed_susp_on_cls(&cint, 0);
|
||||
@ -4692,12 +4701,14 @@ ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop) {
|
||||
|
||||
yamop *
|
||||
Yap_ExpandIndex(PredEntry *ap, UInt nargs) {
|
||||
return ExpandIndex(ap, nargs, CP);
|
||||
CACHE_REGS
|
||||
return ExpandIndex(ap, nargs, CP PASS_REGS);
|
||||
}
|
||||
|
||||
static path_stack_entry *
|
||||
push_path(path_stack_entry *sp, yamop **pipc, ClauseDef *clp, struct intermediates *cint)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (sp+1 > (path_stack_entry *)Yap_TrailTop) {
|
||||
save_machine_regs();
|
||||
siglongjmp(cint->CompilerBotch,4);
|
||||
@ -4714,6 +4725,7 @@ push_path(path_stack_entry *sp, yamop **pipc, ClauseDef *clp, struct intermediat
|
||||
static path_stack_entry *
|
||||
fetch_new_block(path_stack_entry *sp, yamop **pipc, PredEntry *ap, struct intermediates *cint)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (sp+1 > (path_stack_entry *)Yap_TrailTop) {
|
||||
save_machine_regs();
|
||||
siglongjmp(cint->CompilerBotch,4);
|
||||
@ -5993,6 +6005,7 @@ add_to_index(struct intermediates *cint, int first, path_stack_entry *sp, Clause
|
||||
|
||||
void
|
||||
Yap_AddClauseToIndex(PredEntry *ap, yamop *beg, int first) {
|
||||
CACHE_REGS
|
||||
ClauseDef cl;
|
||||
/* first clause */
|
||||
path_stack_entry *stack, *sp;
|
||||
@ -6469,6 +6482,7 @@ remove_from_index(PredEntry *ap, path_stack_entry *sp, ClauseDef *cls, yamop *bg
|
||||
/* clause is locked */
|
||||
void
|
||||
Yap_RemoveClauseFromIndex(PredEntry *ap, yamop *beg) {
|
||||
CACHE_REGS
|
||||
ClauseDef cl;
|
||||
/* first clause */
|
||||
path_stack_entry *stack, *sp;
|
||||
@ -6578,7 +6592,7 @@ Yap_RemoveClauseFromIndex(PredEntry *ap, yamop *beg) {
|
||||
|
||||
|
||||
static void
|
||||
store_clause_choice_point(Term t1, Term tb, Term tr, yamop *ipc, PredEntry *pe, yamop *ap_pc, yamop *cp_pc)
|
||||
store_clause_choice_point(Term t1, Term tb, Term tr, yamop *ipc, PredEntry *pe, yamop *ap_pc, yamop *cp_pc USES_REGS)
|
||||
{
|
||||
Term tpc = MkIntegerTerm((Int)ipc);
|
||||
Term tpe = MkIntegerTerm((Int)pe);
|
||||
@ -6610,7 +6624,7 @@ store_clause_choice_point(Term t1, Term tb, Term tr, yamop *ipc, PredEntry *pe,
|
||||
}
|
||||
|
||||
static void
|
||||
update_clause_choice_point(yamop *ipc, yamop *ap_pc)
|
||||
update_clause_choice_point(yamop *ipc, yamop *ap_pc USES_REGS)
|
||||
{
|
||||
Term tpc = MkIntegerTerm((Int)ipc);
|
||||
B->cp_args[1] = tpc;
|
||||
@ -6632,6 +6646,7 @@ to_clause(yamop *ipc, PredEntry *ap)
|
||||
LogUpdClause *
|
||||
Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, yamop *cp_pc)
|
||||
{
|
||||
CACHE_REGS
|
||||
CELL *s_reg = NULL;
|
||||
Term t = TermNil;
|
||||
yamop *start_pc = ipc;
|
||||
@ -6655,7 +6670,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
||||
op_numbers op = Yap_op_from_opcode(ipc->opc);
|
||||
switch(op) {
|
||||
case _try_in:
|
||||
update_clause_choice_point(NEXTOP(ipc,l), ap_pc);
|
||||
update_clause_choice_point(NEXTOP(ipc,l), ap_pc PASS_REGS);
|
||||
if (lu_pred)
|
||||
return lu_clause(ipc->u.l.l, ap);
|
||||
else
|
||||
@ -6666,11 +6681,11 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
||||
case _table_try:
|
||||
#endif
|
||||
if (b0 == NULL)
|
||||
store_clause_choice_point(Terms[0], Terms[1], Terms[2], NEXTOP(ipc,Otapl), ap, ap_pc, cp_pc);
|
||||
store_clause_choice_point(Terms[0], Terms[1], Terms[2], NEXTOP(ipc,Otapl), ap, ap_pc, cp_pc PASS_REGS);
|
||||
else {
|
||||
B = b0;
|
||||
b0 = NULL;
|
||||
update_clause_choice_point(NEXTOP(ipc,Otapl), ap_pc);
|
||||
update_clause_choice_point(NEXTOP(ipc,Otapl), ap_pc PASS_REGS);
|
||||
}
|
||||
if (lu_pred)
|
||||
return lu_clause(ipc->u.Otapl.d, ap);
|
||||
@ -6680,11 +6695,11 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
||||
case _try_clause3:
|
||||
case _try_clause4:
|
||||
if (b0 == NULL)
|
||||
store_clause_choice_point(Terms[0], Terms[1], Terms[2], NEXTOP(ipc,l), ap, ap_pc, cp_pc);
|
||||
store_clause_choice_point(Terms[0], Terms[1], Terms[2], NEXTOP(ipc,l), ap, ap_pc, cp_pc PASS_REGS);
|
||||
else {
|
||||
B = b0;
|
||||
b0 = NULL;
|
||||
update_clause_choice_point(NEXTOP(ipc,l), ap_pc);
|
||||
update_clause_choice_point(NEXTOP(ipc,l), ap_pc PASS_REGS);
|
||||
}
|
||||
if (lu_pred)
|
||||
return lu_clause(ipc->u.l.l, ap);
|
||||
@ -6695,11 +6710,11 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
||||
case _table_try_me:
|
||||
#endif
|
||||
if (b0 == NULL)
|
||||
store_clause_choice_point(Terms[0], Terms[1], Terms[2], ipc->u.Otapl.d, ap, ap_pc, cp_pc);
|
||||
store_clause_choice_point(Terms[0], Terms[1], Terms[2], ipc->u.Otapl.d, ap, ap_pc, cp_pc PASS_REGS);
|
||||
else {
|
||||
B = b0;
|
||||
b0 = NULL;
|
||||
update_clause_choice_point(ipc->u.Otapl.d, ap_pc);
|
||||
update_clause_choice_point(ipc->u.Otapl.d, ap_pc PASS_REGS);
|
||||
}
|
||||
ipc = NEXTOP(ipc,Otapl);
|
||||
break;
|
||||
@ -6711,7 +6726,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
||||
#if TABLING
|
||||
case _table_retry:
|
||||
#endif
|
||||
update_clause_choice_point(NEXTOP(ipc,Otapl),ap_pc);
|
||||
update_clause_choice_point(NEXTOP(ipc,Otapl),ap_pc PASS_REGS);
|
||||
if (lu_pred)
|
||||
return lu_clause(ipc->u.Otapl.d, ap);
|
||||
else
|
||||
@ -6719,13 +6734,13 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
||||
case _retry2:
|
||||
case _retry3:
|
||||
case _retry4:
|
||||
update_clause_choice_point(NEXTOP(ipc,l),ap_pc);
|
||||
update_clause_choice_point(NEXTOP(ipc,l),ap_pc PASS_REGS);
|
||||
if (lu_pred)
|
||||
return lu_clause(ipc->u.l.l, ap);
|
||||
else
|
||||
return (LogUpdClause *)static_clause(ipc->u.l.l, ap, TRUE);
|
||||
case _retry_me:
|
||||
update_clause_choice_point(ipc->u.Otapl.d,ap_pc);
|
||||
update_clause_choice_point(ipc->u.Otapl.d,ap_pc PASS_REGS);
|
||||
ipc = NEXTOP(ipc,Otapl);
|
||||
break;
|
||||
case _trust:
|
||||
@ -6815,11 +6830,11 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
||||
break;
|
||||
case _try_logical:
|
||||
if (b0 == NULL)
|
||||
store_clause_choice_point(Terms[0], Terms[1], Terms[2], ipc->u.OtaLl.n, ap, ap_pc, cp_pc);
|
||||
store_clause_choice_point(Terms[0], Terms[1], Terms[2], ipc->u.OtaLl.n, ap, ap_pc, cp_pc PASS_REGS);
|
||||
else {
|
||||
B = b0;
|
||||
b0 = NULL;
|
||||
update_clause_choice_point(ipc->u.OtaLl.n, ap_pc);
|
||||
update_clause_choice_point(ipc->u.OtaLl.n, ap_pc PASS_REGS);
|
||||
}
|
||||
{
|
||||
UInt timestamp = IntegerOfTerm(((CELL *)(B+1))[5]);
|
||||
@ -6842,7 +6857,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
||||
break;
|
||||
}
|
||||
}
|
||||
update_clause_choice_point(ipc->u.OtILl.n,ap_pc);
|
||||
update_clause_choice_point(ipc->u.OtILl.n,ap_pc PASS_REGS);
|
||||
return ipc->u.OtILl.d;
|
||||
#if TABLING
|
||||
case _table_try_single:
|
||||
@ -7103,7 +7118,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
ipc = ExpandIndex(ap, 5, cp_pc);
|
||||
ipc = ExpandIndex(ap, 5, cp_pc PASS_REGS);
|
||||
s_reg = (CELL *)XREGS[ap->ArityOfPE+1];
|
||||
t = XREGS[ap->ArityOfPE+2];
|
||||
Terms[0] = XREGS[ap->ArityOfPE+3];
|
||||
@ -7117,7 +7132,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
||||
break;
|
||||
#if THREADS
|
||||
case _thread_local:
|
||||
ap = Yap_GetThreadPred(ap);
|
||||
ap = Yap_GetThreadPred(ap PASS_REGS);
|
||||
ipc = ap->CodeOfPred;
|
||||
break;
|
||||
#endif
|
||||
@ -7202,6 +7217,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
||||
LogUpdClause *
|
||||
Yap_NthClause(PredEntry *ap, Int ncls)
|
||||
{
|
||||
CACHE_REGS
|
||||
yamop
|
||||
*ipc = ap->cs.p_code.TrueCodeOfPred,
|
||||
*alt = NULL;
|
||||
@ -7378,7 +7394,7 @@ Yap_NthClause(PredEntry *ap, Int ncls)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
ipc = ExpandIndex(ap, 0, CP);
|
||||
ipc = ExpandIndex(ap, 0, CP PASS_REGS);
|
||||
|
||||
break;
|
||||
case _op_fail:
|
||||
|
9
C/init.c
9
C/init.c
@ -505,6 +505,7 @@ update_flags_from_prolog(UInt flags, PredEntry *pe)
|
||||
void
|
||||
Yap_InitCPred(char *Name, unsigned long int Arity, CPredicate code, UInt flags)
|
||||
{
|
||||
CACHE_REGS
|
||||
Atom atom = NIL;
|
||||
PredEntry *pe = NULL;
|
||||
yamop *p_code;
|
||||
@ -604,6 +605,7 @@ Yap_InitCPred(char *Name, unsigned long int Arity, CPredicate code, UInt flags)
|
||||
void
|
||||
Yap_InitCmpPred(char *Name, unsigned long int Arity, CmpPredicate cmp_code, UInt flags)
|
||||
{
|
||||
CACHE_REGS
|
||||
Atom atom = NIL;
|
||||
PredEntry *pe = NULL;
|
||||
yamop *p_code = NULL;
|
||||
@ -681,6 +683,7 @@ Yap_InitCmpPred(char *Name, unsigned long int Arity, CmpPredicate cmp_code, UInt
|
||||
void
|
||||
Yap_InitAsmPred(char *Name, unsigned long int Arity, int code, CPredicate def, UInt flags)
|
||||
{
|
||||
CACHE_REGS
|
||||
Atom atom = NIL;
|
||||
PredEntry *pe = NULL;
|
||||
Functor f = NULL;
|
||||
@ -852,6 +855,7 @@ Yap_InitCPredBack(char *Name, unsigned long int Arity,
|
||||
CPredicate Cont, UInt flags)
|
||||
#endif
|
||||
{
|
||||
CACHE_REGS
|
||||
PredEntry *pe = NULL;
|
||||
Atom atom = NIL;
|
||||
Functor f = NULL;
|
||||
@ -1181,6 +1185,7 @@ InitThreadHandle(int wid)
|
||||
static void
|
||||
InitFirstWorkerThreadHandle(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
#ifdef THREADS
|
||||
ThreadHandle.id = 0;
|
||||
ThreadHandle.in_use = TRUE;
|
||||
@ -1204,6 +1209,7 @@ InitScratchPad(int wid)
|
||||
void
|
||||
Yap_CloseScratchPad(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
Yap_FreeCodeSpace(ScratchPad.ptr);
|
||||
ScratchPad.sz = SCRATCH_START_SIZE;
|
||||
ScratchPad.msz = SCRATCH_START_SIZE;
|
||||
@ -1234,6 +1240,7 @@ struct worker_local Yap_WLocal;
|
||||
static void
|
||||
InitCodes(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
int wid;
|
||||
#include "ihstruct.h"
|
||||
InitGlobal();
|
||||
@ -1274,6 +1281,7 @@ void
|
||||
Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_size,
|
||||
int n_workers, int sch_loop, int delay_load)
|
||||
{
|
||||
CACHE_REGS
|
||||
int i;
|
||||
|
||||
/* initialise system stuff */
|
||||
@ -1291,6 +1299,7 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
|
||||
#endif /* PUSH_REGS */
|
||||
|
||||
#ifdef THREADS
|
||||
Yap_regp = ((REGSTORE *)pthread_getspecific(Yap_yaamregs_key));
|
||||
Yap_regp->worker_id_ = 0;
|
||||
#endif
|
||||
/* Init signal handling and time */
|
||||
|
78
C/inlines.c
78
C/inlines.c
@ -23,25 +23,25 @@
|
||||
#include "cut_c.h"
|
||||
#endif
|
||||
|
||||
STATIC_PROTO(Int p_atom, (void));
|
||||
STATIC_PROTO(Int p_atomic, (void));
|
||||
STATIC_PROTO(Int p_integer, (void));
|
||||
STATIC_PROTO(Int p_nonvar, (void));
|
||||
STATIC_PROTO(Int p_number, (void));
|
||||
STATIC_PROTO(Int p_var, (void));
|
||||
STATIC_PROTO(Int p_db_ref, (void));
|
||||
STATIC_PROTO(Int p_primitive, (void));
|
||||
STATIC_PROTO(Int p_compound, (void));
|
||||
STATIC_PROTO(Int p_float, (void));
|
||||
STATIC_PROTO(Int p_equal, (void));
|
||||
STATIC_PROTO(Int p_dif, (void));
|
||||
STATIC_PROTO(Int p_eq, (void));
|
||||
STATIC_PROTO(Int p_arg, (void));
|
||||
STATIC_PROTO(Int p_functor, (void));
|
||||
STATIC_PROTO(Int p_atom, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_atomic, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_integer, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_nonvar, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_number, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_var, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_db_ref, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_primitive, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_compound, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_float, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_equal, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_dif, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_eq, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_arg, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_functor, ( USES_REGS1 ));
|
||||
|
||||
|
||||
static Int
|
||||
p_atom(void)
|
||||
p_atom( USES_REGS1 )
|
||||
{ /* atom(?) */
|
||||
BEGD(d0);
|
||||
d0 = ARG1;
|
||||
@ -62,7 +62,7 @@ p_atom(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_atomic(void)
|
||||
p_atomic( USES_REGS1 )
|
||||
{ /* atomic(?) */
|
||||
BEGD(d0);
|
||||
d0 = ARG1;
|
||||
@ -83,7 +83,7 @@ p_atomic(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_integer(void)
|
||||
p_integer( USES_REGS1 )
|
||||
{ /* integer(?,?) */
|
||||
BEGD(d0);
|
||||
d0 = ARG1;
|
||||
@ -118,7 +118,7 @@ p_integer(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_number(void)
|
||||
p_number( USES_REGS1 )
|
||||
{ /* number(?) */
|
||||
BEGD(d0);
|
||||
d0 = ARG1;
|
||||
@ -154,7 +154,7 @@ p_number(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_db_ref(void)
|
||||
p_db_ref( USES_REGS1 )
|
||||
{ /* db_reference(?,?) */
|
||||
BEGD(d0);
|
||||
d0 = ARG1;
|
||||
@ -175,7 +175,7 @@ p_db_ref(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_primitive(void)
|
||||
p_primitive( USES_REGS1 )
|
||||
{ /* primitive(?) */
|
||||
BEGD(d0);
|
||||
d0 = ARG1;
|
||||
@ -196,7 +196,7 @@ p_primitive(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_float(void)
|
||||
p_float( USES_REGS1 )
|
||||
{ /* float(?) */
|
||||
BEGD(d0);
|
||||
d0 = ARG1;
|
||||
@ -217,7 +217,7 @@ p_float(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_compound(void)
|
||||
p_compound( USES_REGS1 )
|
||||
{ /* compound(?) */
|
||||
BEGD(d0);
|
||||
d0 = ARG1;
|
||||
@ -244,7 +244,7 @@ p_compound(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nonvar(void)
|
||||
p_nonvar( USES_REGS1 )
|
||||
{ /* nonvar(?) */
|
||||
BEGD(d0);
|
||||
d0 = ARG1;
|
||||
@ -260,7 +260,7 @@ p_nonvar(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_var(void)
|
||||
p_var( USES_REGS1 )
|
||||
{ /* var(?) */
|
||||
BEGD(d0);
|
||||
d0 = ARG1;
|
||||
@ -276,13 +276,13 @@ p_var(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_equal(void)
|
||||
p_equal( USES_REGS1 )
|
||||
{ /* ?=? */
|
||||
return(Yap_IUnify(ARG1, ARG2));
|
||||
}
|
||||
|
||||
static Int
|
||||
eq(Term t1, Term t2)
|
||||
eq(Term t1, Term t2 USES_REGS)
|
||||
{ /* ? == ? */
|
||||
BEGD(d0);
|
||||
d0 = t1;
|
||||
@ -366,19 +366,20 @@ eq(Term t1, Term t2)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_eq(void)
|
||||
p_eq( USES_REGS1 )
|
||||
{ /* ? == ? */
|
||||
return eq(ARG1,ARG2);
|
||||
return eq(ARG1,ARG2 PASS_REGS);
|
||||
}
|
||||
|
||||
int
|
||||
Yap_eq(Term t1, Term t2)
|
||||
{ /* ? == ? */
|
||||
return eq(t1,t2);
|
||||
CACHE_REGS
|
||||
return eq(t1,t2 PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_dif(void)
|
||||
p_dif( USES_REGS1 )
|
||||
{ /* ? \= ? */
|
||||
#if SHADOW_HB
|
||||
register CELL *HBREG = HB;
|
||||
@ -486,7 +487,7 @@ p_dif(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_arg(void)
|
||||
p_arg( USES_REGS1 )
|
||||
{ /* arg(?,?,?) */
|
||||
#if SHADOW_HB
|
||||
register CELL *HBREG = HB;
|
||||
@ -581,7 +582,7 @@ p_arg(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_functor(void) /* functor(?,?,?) */
|
||||
p_functor( USES_REGS1 ) /* functor(?,?,?) */
|
||||
{
|
||||
#if SHADOW_HB
|
||||
register CELL *HBREG;
|
||||
@ -776,7 +777,7 @@ p_functor(void) /* functor(?,?,?) */
|
||||
}
|
||||
|
||||
static Int
|
||||
p_cut_by( void)
|
||||
p_cut_by( USES_REGS1 )
|
||||
{
|
||||
BEGD(d0);
|
||||
d0 = ARG1;
|
||||
@ -832,14 +833,14 @@ p_cut_by( void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_erroneous_call(void)
|
||||
p_erroneous_call( USES_REGS1 )
|
||||
{
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "bad call to internal built-in");
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
static Int
|
||||
init_genarg(void)
|
||||
init_genarg( USES_REGS1 )
|
||||
{ /* getarg(?Atom) */
|
||||
Term t0 = Deref(ARG1);
|
||||
Term t1 = Deref(ARG2);
|
||||
@ -848,7 +849,7 @@ init_genarg(void)
|
||||
UInt arity;
|
||||
|
||||
if (!IsVarTerm(t0)) {
|
||||
res = p_arg();
|
||||
res = p_arg( PASS_REGS1 );
|
||||
if (res) {
|
||||
cut_succeed();
|
||||
} else {
|
||||
@ -889,7 +890,7 @@ init_genarg(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
cont_genarg(void)
|
||||
cont_genarg( USES_REGS1 )
|
||||
{ /* genarg(?Atom) */
|
||||
CELL *pt, *end;
|
||||
int res;
|
||||
@ -916,6 +917,7 @@ cont_genarg(void)
|
||||
void
|
||||
Yap_InitInlines(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term cm = CurrentModule;
|
||||
Yap_InitAsmPred("$$cut_by", 1, _cut_by, p_cut_by, SafePredFlag);
|
||||
Yap_InitAsmPred("atom", 1, _atom, p_atom, SafePredFlag);
|
||||
|
69
C/iopreds.c
69
C/iopreds.c
@ -84,12 +84,12 @@ static char SccsId[] = "%W% %G%";
|
||||
#endif
|
||||
#include "iopreds.h"
|
||||
|
||||
STATIC_PROTO (Int p_set_read_error_handler, (void));
|
||||
STATIC_PROTO (Int p_get_read_error_handler, (void));
|
||||
STATIC_PROTO (Int p_read, (void));
|
||||
STATIC_PROTO (Int p_startline, (void));
|
||||
STATIC_PROTO (Int p_change_type_of_char, (void));
|
||||
STATIC_PROTO (Int p_type_of_char, (void));
|
||||
STATIC_PROTO (Int p_set_read_error_handler, ( USES_REGS1 ));
|
||||
STATIC_PROTO (Int p_get_read_error_handler, ( USES_REGS1 ));
|
||||
STATIC_PROTO (Int p_read, ( USES_REGS1 ));
|
||||
STATIC_PROTO (Int p_startline, ( USES_REGS1 ));
|
||||
STATIC_PROTO (Int p_change_type_of_char, ( USES_REGS1 ));
|
||||
STATIC_PROTO (Int p_type_of_char, ( USES_REGS1 ));
|
||||
STATIC_PROTO (Term StreamPosition, (IOSTREAM *));
|
||||
|
||||
extern Atom Yap_FileName(IOSTREAM *s);
|
||||
@ -206,6 +206,7 @@ Yap_DebugPlWrite(Term t)
|
||||
void
|
||||
Yap_DebugErrorPutc(int c)
|
||||
{
|
||||
CACHE_REGS
|
||||
Yap_DebugPutc (Yap_c_error_stream, c);
|
||||
}
|
||||
|
||||
@ -215,7 +216,7 @@ Yap_DebugErrorPutc(int c)
|
||||
|
||||
|
||||
static Int
|
||||
p_has_readline(void)
|
||||
p_has_readline( USES_REGS1 )
|
||||
{
|
||||
#if HAVE_LIBREADLINE && HAVE_READLINE_READLINE_H
|
||||
return TRUE;
|
||||
@ -273,6 +274,7 @@ clean_vars(VarEntry *p)
|
||||
static Term
|
||||
syntax_error (TokEntry * tokptr, IOSTREAM *st, Term *outp)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term info;
|
||||
int count = 0, out = 0;
|
||||
Int start, err = 0, end;
|
||||
@ -388,7 +390,7 @@ syntax_error (TokEntry * tokptr, IOSTREAM *st, Term *outp)
|
||||
}
|
||||
|
||||
static void
|
||||
GenerateSyntaxError(Term *tp, TokEntry *tokstart, IOSTREAM *sno)
|
||||
GenerateSyntaxError(Term *tp, TokEntry *tokstart, IOSTREAM *sno USES_REGS)
|
||||
{
|
||||
if (tp) {
|
||||
Term et[2];
|
||||
@ -402,6 +404,7 @@ GenerateSyntaxError(Term *tp, TokEntry *tokstart, IOSTREAM *sno)
|
||||
Term
|
||||
Yap_StringToTerm(char *s,Term *tp)
|
||||
{
|
||||
CACHE_REGS
|
||||
IOSTREAM *sno = Sopenmem(&s, NULL, "r");
|
||||
Term t;
|
||||
TokEntry *tokstart;
|
||||
@ -430,7 +433,7 @@ Yap_StringToTerm(char *s,Term *tp)
|
||||
t = Yap_Parse();
|
||||
TR = TR_before_parse;
|
||||
if (!t || Yap_ErrorMessage) {
|
||||
GenerateSyntaxError(tp, tokstart, sno);
|
||||
GenerateSyntaxError(tp, tokstart, sno PASS_REGS);
|
||||
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
|
||||
Sclose(sno);
|
||||
return FALSE;
|
||||
@ -444,18 +447,19 @@ Yap_StringToTerm(char *s,Term *tp)
|
||||
Int
|
||||
Yap_FirstLineInParse (void)
|
||||
{
|
||||
CACHE_REGS
|
||||
return StartLine;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_startline (void)
|
||||
p_startline ( USES_REGS1 )
|
||||
{
|
||||
return (Yap_unify_constant (ARG1, MkIntegerTerm (StartLine)));
|
||||
}
|
||||
|
||||
/* control the parser error handler */
|
||||
static Int
|
||||
p_set_read_error_handler(void)
|
||||
p_set_read_error_handler( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
char *s;
|
||||
@ -485,7 +489,7 @@ p_set_read_error_handler(void)
|
||||
|
||||
/* return the status for the parser error handler */
|
||||
static Int
|
||||
p_get_read_error_handler(void)
|
||||
p_get_read_error_handler( USES_REGS1 )
|
||||
{
|
||||
Term t;
|
||||
|
||||
@ -512,6 +516,7 @@ p_get_read_error_handler(void)
|
||||
int
|
||||
Yap_readTerm(void *st0, Term *tp, Term *varnames, Term *terror, Term *tpos)
|
||||
{
|
||||
CACHE_REGS
|
||||
TokEntry *tokstart;
|
||||
Term pt;
|
||||
IOSTREAM *st = (IOSTREAM *)st0;
|
||||
@ -530,7 +535,7 @@ Yap_readTerm(void *st0, Term *tp, Term *varnames, Term *terror, Term *tpos)
|
||||
}
|
||||
pt = Yap_Parse();
|
||||
if (Yap_ErrorMessage || pt == (CELL)0) {
|
||||
GenerateSyntaxError(terror, tokstart, st);
|
||||
GenerateSyntaxError(terror, tokstart, st PASS_REGS);
|
||||
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
|
||||
return FALSE;
|
||||
}
|
||||
@ -557,7 +562,7 @@ Yap_readTerm(void *st0, Term *tp, Term *varnames, Term *terror, Term *tpos)
|
||||
Err: ARG6
|
||||
*/
|
||||
static Int
|
||||
do_read(IOSTREAM *inp_stream, int nargs)
|
||||
do_read(IOSTREAM *inp_stream, int nargs USES_REGS)
|
||||
{
|
||||
Term t, v;
|
||||
TokEntry *tokstart;
|
||||
@ -746,23 +751,23 @@ static Int
|
||||
}
|
||||
|
||||
static Int
|
||||
p_read (void)
|
||||
p_read ( USES_REGS1 )
|
||||
{ /* '$read'(+Flag,?Term,?Module,?Vars,-Pos,-Err) */
|
||||
return do_read(NULL, 6);
|
||||
return do_read(NULL, 6 PASS_REGS);
|
||||
}
|
||||
|
||||
extern int Yap_getInputStream(Int, IOSTREAM **);
|
||||
|
||||
static Int
|
||||
p_read2 (void)
|
||||
p_read2 ( USES_REGS1 )
|
||||
{ /* '$read2'(+Flag,?Term,?Module,?Vars,-Pos,-Err,+Stream) */
|
||||
IOSTREAM *inp_stream;
|
||||
Int out;
|
||||
|
||||
if (!Yap_getInputStream(Yap_InitSlot(Deref(ARG7)), &inp_stream)) {
|
||||
if (!Yap_getInputStream(Yap_InitSlot(Deref(ARG7) PASS_REGS), &inp_stream)) {
|
||||
return(FALSE);
|
||||
}
|
||||
out = do_read(inp_stream, 7);
|
||||
out = do_read(inp_stream, 7 PASS_REGS);
|
||||
return out;
|
||||
}
|
||||
|
||||
@ -787,7 +792,7 @@ Yap_StreamPosition(IOSTREAM *st)
|
||||
#if HAVE_SELECT && FALSE
|
||||
/* stream_select(+Streams,+TimeOut,-Result) */
|
||||
static Int
|
||||
p_stream_select(void)
|
||||
p_stream_select( USES_REGS1 )
|
||||
{
|
||||
Term t1 = Deref(ARG1), t2;
|
||||
fd_set readfds, writefds, exceptfds;
|
||||
@ -912,7 +917,7 @@ p_stream_select(void)
|
||||
#endif
|
||||
|
||||
static Int
|
||||
p_change_type_of_char (void)
|
||||
p_change_type_of_char ( USES_REGS1 )
|
||||
{ /* change_type_of_char(+char,+type) */
|
||||
Term t1 = Deref (ARG1);
|
||||
Term t2 = Deref (ARG2);
|
||||
@ -925,7 +930,7 @@ p_change_type_of_char (void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_type_of_char (void)
|
||||
p_type_of_char ( USES_REGS1 )
|
||||
{ /* type_of_char(+char,-type) */
|
||||
Term t;
|
||||
|
||||
@ -938,7 +943,7 @@ p_type_of_char (void)
|
||||
|
||||
|
||||
static Int
|
||||
p_force_char_conversion(void)
|
||||
p_force_char_conversion( USES_REGS1 )
|
||||
{
|
||||
/* don't actually enable it until someone tries to add a conversion */
|
||||
if (CharConversionTable2 == NULL)
|
||||
@ -948,7 +953,7 @@ p_force_char_conversion(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_disable_char_conversion(void)
|
||||
p_disable_char_conversion( USES_REGS1 )
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -961,7 +966,7 @@ p_disable_char_conversion(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_char_conversion(void)
|
||||
p_char_conversion( USES_REGS1 )
|
||||
{
|
||||
Term t0 = Deref(ARG1), t1 = Deref(ARG2);
|
||||
char *s0, *s1;
|
||||
@ -1007,7 +1012,7 @@ p_char_conversion(void)
|
||||
}
|
||||
}
|
||||
if (yap_flags[CHAR_CONVERSION_FLAG] != 0) {
|
||||
if (p_force_char_conversion() == FALSE)
|
||||
if (p_force_char_conversion( PASS_REGS1 ) == FALSE)
|
||||
return(FALSE);
|
||||
}
|
||||
for (i = 0; i < NUMBER_OF_CHARS; i++)
|
||||
@ -1020,7 +1025,7 @@ p_char_conversion(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_current_char_conversion(void)
|
||||
p_current_char_conversion( USES_REGS1 )
|
||||
{
|
||||
Term t0, t1;
|
||||
char *s0, *s1;
|
||||
@ -1065,7 +1070,7 @@ p_current_char_conversion(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_all_char_conversions(void)
|
||||
p_all_char_conversions( USES_REGS1 )
|
||||
{
|
||||
Term out = TermNil;
|
||||
int i;
|
||||
@ -1091,7 +1096,7 @@ p_all_char_conversions(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_float_format(void)
|
||||
p_float_format( USES_REGS1 )
|
||||
{
|
||||
Term in = Deref(ARG1);
|
||||
if (IsVarTerm(in))
|
||||
@ -1105,18 +1110,18 @@ extern void Yap_SetDefaultEncoding(IOENC);
|
||||
extern int PL_get_stream_handle(Int, IOSTREAM **);
|
||||
|
||||
static Int
|
||||
p_get_default_encoding(void)
|
||||
p_get_default_encoding( USES_REGS1 )
|
||||
{
|
||||
Term out = MkIntegerTerm(Yap_DefaultEncoding());
|
||||
return Yap_unify(ARG1, out);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_encoding (void)
|
||||
p_encoding ( USES_REGS1 )
|
||||
{ /* '$encoding'(Stream,N) */
|
||||
IOSTREAM *st;
|
||||
Term t = Deref(ARG2);
|
||||
if (!PL_get_stream_handle(Yap_InitSlot(Deref(ARG1)), &st)) {
|
||||
if (!PL_get_stream_handle(Yap_InitSlot(Deref(ARG1) PASS_REGS), &st)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (IsVarTerm(t)) {
|
||||
|
@ -53,6 +53,7 @@ Yap_LoadForeignFile(char *file, int flags)
|
||||
|
||||
out = (void *)dlopen(file,dlflag);
|
||||
if (!out) {
|
||||
CACHE_REGS
|
||||
Yap_Error(SYSTEM_ERROR, ARG1, "dlopen error %s\n", dlerror());
|
||||
}
|
||||
return out;
|
||||
@ -74,6 +75,7 @@ int
|
||||
Yap_CloseForeignFile(void *handle)
|
||||
{
|
||||
if ( dlclose(handle) < 0) {
|
||||
CACHE_REGS
|
||||
Yap_Error(SYSTEM_ERROR, ARG1, "dlclose error %s\n", dlerror());
|
||||
return -1;
|
||||
}
|
||||
@ -89,9 +91,9 @@ static Int
|
||||
LoadForeign(StringList ofiles, StringList libs,
|
||||
char *proc_name, YapInitProc *init_proc)
|
||||
{
|
||||
CACHE_REGS
|
||||
|
||||
while (libs) {
|
||||
|
||||
if (!Yap_TrueFileName(AtomName(libs->name), Yap_FileNameBuf, TRUE)) {
|
||||
/* use LD_LIBRARY_PATH */
|
||||
strncpy(Yap_FileNameBuf, AtomName(libs->name), YAP_FILENAME_MAX);
|
||||
|
@ -34,10 +34,10 @@ static char SccsId[] = "%W% %G%.2";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
STD_PROTO(Int p_load_foreign, (void));
|
||||
STD_PROTO(Int p_load_foreign, ( USES_REGS1 ));
|
||||
|
||||
Int
|
||||
p_load_foreign(void)
|
||||
p_load_foreign( USES_REGS1 )
|
||||
{
|
||||
StringList ofiles = NULL;
|
||||
StringList libs = NULL;
|
||||
@ -110,7 +110,7 @@ p_load_foreign(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_open_shared_object(void) {
|
||||
p_open_shared_object( USES_REGS1 ) {
|
||||
Term t = Deref(ARG1);
|
||||
Term tflags = Deref(ARG2);
|
||||
char *s;
|
||||
@ -143,7 +143,7 @@ p_open_shared_object(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_close_shared_object(void) {
|
||||
p_close_shared_object( USES_REGS1 ) {
|
||||
Term t = Deref(ARG1);
|
||||
void *handle;
|
||||
|
||||
@ -161,7 +161,7 @@ p_close_shared_object(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_call_shared_object_function(void) {
|
||||
p_call_shared_object_function( USES_REGS1 ) {
|
||||
Term t = Deref(ARG1);
|
||||
Term tfunc = Deref(ARG2);
|
||||
Term tmod;
|
||||
@ -209,12 +209,12 @@ p_call_shared_object_function(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_obj_suffix(void) {
|
||||
p_obj_suffix( USES_REGS1 ) {
|
||||
return Yap_unify(Yap_StringToList(YAP_SHLIB_SUFFIX),ARG1);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_open_shared_objects(void) {
|
||||
p_open_shared_objects( USES_REGS1 ) {
|
||||
#ifdef YAP_SHLIB_SUFFIX
|
||||
return TRUE;
|
||||
#else
|
||||
@ -223,7 +223,7 @@ p_open_shared_objects(void) {
|
||||
}
|
||||
|
||||
void
|
||||
Yap_InitLoadForeign(void)
|
||||
Yap_InitLoadForeign( void )
|
||||
{
|
||||
if (Yap_argv == NULL)
|
||||
Yap_FindExecutable("yap");
|
||||
@ -240,6 +240,7 @@ Yap_InitLoadForeign(void)
|
||||
void
|
||||
Yap_ReOpenLoadForeign(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
ForeignObj *f_code = ForeignCodeLoaded;
|
||||
Term OldModule = CurrentModule;
|
||||
|
||||
|
37
C/mavar.c
37
C/mavar.c
@ -23,14 +23,14 @@
|
||||
#include "YapHeap.h"
|
||||
#include "eval.h"
|
||||
|
||||
STD_PROTO(static Int p_setarg, (void));
|
||||
STD_PROTO(static Int p_create_mutable, (void));
|
||||
STD_PROTO(static Int p_get_mutable, (void));
|
||||
STD_PROTO(static Int p_update_mutable, (void));
|
||||
STD_PROTO(static Int p_is_mutable, (void));
|
||||
STD_PROTO(static Int p_setarg, ( USES_REGS1 ));
|
||||
STD_PROTO(static Int p_create_mutable, ( USES_REGS1 ));
|
||||
STD_PROTO(static Int p_get_mutable, ( USES_REGS1 ));
|
||||
STD_PROTO(static Int p_update_mutable, ( USES_REGS1 ));
|
||||
STD_PROTO(static Int p_is_mutable, ( USES_REGS1 ));
|
||||
|
||||
static Int
|
||||
p_setarg(void)
|
||||
p_setarg( USES_REGS1 )
|
||||
{
|
||||
CELL ti = Deref(ARG1), ts = Deref(ARG2), t3 = Deref(ARG3);
|
||||
Int i;
|
||||
@ -119,7 +119,7 @@ p_setarg(void)
|
||||
*/
|
||||
|
||||
static Term
|
||||
NewTimedVar(CELL val)
|
||||
NewTimedVar(CELL val USES_REGS)
|
||||
{
|
||||
Term out;
|
||||
timed_var *tv;
|
||||
@ -141,12 +141,14 @@ NewTimedVar(CELL val)
|
||||
Term
|
||||
Yap_NewTimedVar(CELL val)
|
||||
{
|
||||
return NewTimedVar(val);
|
||||
CACHE_REGS
|
||||
return NewTimedVar(val PASS_REGS);
|
||||
}
|
||||
|
||||
Term
|
||||
Yap_NewEmptyTimedVar(void)
|
||||
Yap_NewEmptyTimedVar( void )
|
||||
{
|
||||
CACHE_REGS
|
||||
Term out = AbsAppl(H);
|
||||
timed_var *tv;
|
||||
*H++ = (CELL)FunctorMutable;
|
||||
@ -173,7 +175,7 @@ Yap_ReadTimedVar(Term inv)
|
||||
|
||||
/* update a timed var with a new value */
|
||||
static Term
|
||||
UpdateTimedVar(Term inv, Term new)
|
||||
UpdateTimedVar(Term inv, Term new USES_REGS)
|
||||
{
|
||||
timed_var *tv = (timed_var *)(RepAppl(inv)+1);
|
||||
CELL t = tv->value;
|
||||
@ -210,18 +212,19 @@ UpdateTimedVar(Term inv, Term new)
|
||||
Term
|
||||
Yap_UpdateTimedVar(Term inv, Term new)
|
||||
{
|
||||
return UpdateTimedVar(inv, new);
|
||||
CACHE_REGS
|
||||
return UpdateTimedVar(inv, new PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_create_mutable(void)
|
||||
p_create_mutable( USES_REGS1 )
|
||||
{
|
||||
Term t = NewTimedVar(Deref(ARG1));
|
||||
Term t = NewTimedVar(Deref(ARG1) PASS_REGS);
|
||||
return(Yap_unify(ARG2,t));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_get_mutable(void)
|
||||
p_get_mutable( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG2);
|
||||
if (IsVarTerm(t)) {
|
||||
@ -241,7 +244,7 @@ p_get_mutable(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_update_mutable(void)
|
||||
p_update_mutable( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG2);
|
||||
if (IsVarTerm(t)) {
|
||||
@ -256,12 +259,12 @@ p_update_mutable(void)
|
||||
Yap_Error(DOMAIN_ERROR_MUTABLE,t,"update_mutable/3");
|
||||
return(FALSE);
|
||||
}
|
||||
UpdateTimedVar(t, Deref(ARG1));
|
||||
UpdateTimedVar(t, Deref(ARG1) PASS_REGS);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_is_mutable(void)
|
||||
p_is_mutable( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
if (IsVarTerm(t)) {
|
||||
|
23
C/modules.c
23
C/modules.c
@ -22,8 +22,8 @@ static char SccsId[] = "%W% %G%";
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
|
||||
STATIC_PROTO(Int p_current_module, (void));
|
||||
STATIC_PROTO(Int p_current_module1, (void));
|
||||
STATIC_PROTO(Int p_current_module, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_current_module1, ( USES_REGS1 ));
|
||||
|
||||
|
||||
inline static ModEntry *
|
||||
@ -82,6 +82,7 @@ GetModuleEntry(Atom at)
|
||||
Term
|
||||
Yap_Module_Name(PredEntry *ap)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term mod;
|
||||
if (!ap->ModuleOfPred)
|
||||
/* If the system predicate is a metacall I should return the
|
||||
@ -143,7 +144,7 @@ Yap_NewModulePred(Term mod, struct pred_entry *ap)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_current_module(void)
|
||||
p_current_module( USES_REGS1 )
|
||||
{ /* $current_module(Old,New) */
|
||||
Term t;
|
||||
|
||||
@ -167,7 +168,7 @@ p_current_module(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_current_module1(void)
|
||||
p_current_module1( USES_REGS1 )
|
||||
{ /* $current_module(Old) */
|
||||
if (CurrentModule)
|
||||
return Yap_unify_constant(ARG1, CurrentModule);
|
||||
@ -175,7 +176,7 @@ p_current_module1(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_change_module(void)
|
||||
p_change_module( USES_REGS1 )
|
||||
{ /* $change_module(New) */
|
||||
Term mod = Deref(ARG1);
|
||||
LookupModule(mod);
|
||||
@ -184,7 +185,7 @@ p_change_module(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
cont_current_module(void)
|
||||
cont_current_module( USES_REGS1 )
|
||||
{
|
||||
ModEntry *imod = (ModEntry *)IntegerOfTerm(EXTRA_CBACK_ARG(1,1)), *next;
|
||||
Term t = MkAtomTerm(imod->AtomOfME);
|
||||
@ -199,7 +200,7 @@ cont_current_module(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
init_current_module(void)
|
||||
init_current_module( USES_REGS1 )
|
||||
{ /* current_module(?ModuleName) */
|
||||
Term t = Deref(ARG1);
|
||||
if (!IsVarTerm(t)) {
|
||||
@ -212,11 +213,11 @@ init_current_module(void)
|
||||
cut_fail();
|
||||
}
|
||||
EXTRA_CBACK_ARG(1,1) = MkIntegerTerm((Int)CurrentModules);
|
||||
return cont_current_module();
|
||||
return cont_current_module( PASS_REGS1 );
|
||||
}
|
||||
|
||||
static Int
|
||||
p_strip_module(void)
|
||||
p_strip_module( USES_REGS1 )
|
||||
{
|
||||
Term t1 = Deref(ARG1), t2, tmod = CurrentModule;
|
||||
if (tmod == PROLOG_MODULE) {
|
||||
@ -243,7 +244,7 @@ p_strip_module(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_context_module(void)
|
||||
p_context_module( USES_REGS1 )
|
||||
{
|
||||
yamop *parentcp = P;
|
||||
CELL *yenv;
|
||||
@ -267,6 +268,7 @@ p_context_module(void)
|
||||
Term
|
||||
Yap_StripModule(Term t, Term *modp)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term tmod;
|
||||
|
||||
tmod = CurrentModule;
|
||||
@ -313,6 +315,7 @@ Yap_InitModulesC(void)
|
||||
void
|
||||
Yap_InitModules(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
LookupModule(MkAtomTerm(AtomProlog));
|
||||
LookupModule(USER_MODULE);
|
||||
LookupModule(IDB_MODULE);
|
||||
|
@ -51,6 +51,7 @@ REGSTORE Yap_REGS;
|
||||
Term
|
||||
Yap_MkNewPairTerm(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
register CELL *p = H;
|
||||
|
||||
RESET_VARIABLE(H);
|
||||
@ -64,12 +65,13 @@ Yap_MkApplTerm(Functor f, unsigned int n, register Term *a)
|
||||
/* build compound term with functor f and n
|
||||
* args a */
|
||||
{
|
||||
CACHE_REGS
|
||||
CELL *t = H;
|
||||
|
||||
if (n == 0)
|
||||
return (MkAtomTerm(NameOfFunctor(f)));
|
||||
if (f == FunctorList)
|
||||
return (MkPairTerm(a[0], a[1]));
|
||||
return MkPairTerm(a[0], a[1]);
|
||||
*H++ = (CELL) f;
|
||||
while (n--)
|
||||
*H++ = (CELL) * a++;
|
||||
@ -81,6 +83,7 @@ Yap_MkNewApplTerm(Functor f, unsigned int n)
|
||||
/* build compound term with functor f and n
|
||||
* args a */
|
||||
{
|
||||
CACHE_REGS
|
||||
CELL *t = H;
|
||||
|
||||
if (n == 0)
|
||||
@ -103,6 +106,7 @@ Yap_MkNewApplTerm(Functor f, unsigned int n)
|
||||
Term
|
||||
Yap_Globalise(Term t)
|
||||
{
|
||||
CACHE_REGS
|
||||
CELL *vt;
|
||||
Term tn;
|
||||
|
||||
|
94
C/parser.c
94
C/parser.c
@ -68,11 +68,11 @@ typedef struct jmp_buff_struct {
|
||||
sigjmp_buf JmpBuff;
|
||||
} JMPBUFF;
|
||||
|
||||
STATIC_PROTO(void GNextToken, (void));
|
||||
STATIC_PROTO(void checkfor, (Term, JMPBUFF *));
|
||||
STATIC_PROTO(Term ParseArgs, (Atom, JMPBUFF *));
|
||||
STATIC_PROTO(Term ParseList, (JMPBUFF *));
|
||||
STATIC_PROTO(Term ParseTerm, (int, JMPBUFF *));
|
||||
STATIC_PROTO(void GNextToken, ( CACHE_TYPE1 ));
|
||||
STATIC_PROTO(void checkfor, (Term, JMPBUFF * CACHE_TYPE));
|
||||
STATIC_PROTO(Term ParseArgs, (Atom, JMPBUFF * CACHE_TYPE));
|
||||
STATIC_PROTO(Term ParseList, (JMPBUFF * CACHE_TYPE));
|
||||
STATIC_PROTO(Term ParseTerm, (int, JMPBUFF * CACHE_TYPE));
|
||||
|
||||
|
||||
#define TRY(S,P) \
|
||||
@ -118,6 +118,7 @@ STATIC_PROTO(Term ParseTerm, (int, JMPBUFF *));
|
||||
VarEntry *
|
||||
Yap_LookupVar(char *var) /* lookup variable in variables table */
|
||||
{
|
||||
CACHE_REGS
|
||||
VarEntry *p;
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -172,20 +173,20 @@ Yap_LookupVar(char *var) /* lookup variable in variables table */
|
||||
}
|
||||
|
||||
static Term
|
||||
VarNames(VarEntry *p,Term l)
|
||||
VarNames(VarEntry *p,Term l USES_REGS)
|
||||
{
|
||||
if (p != NULL) {
|
||||
if (strcmp(p->VarRep, "_") != 0) {
|
||||
Term o = MkPairTerm(MkPairTerm(Yap_StringToList(p->VarRep), p->VarAdr),
|
||||
VarNames(p->VarRight,
|
||||
VarNames(p->VarLeft,l)));
|
||||
VarNames(p->VarLeft,l PASS_REGS) PASS_REGS));
|
||||
if (H > ASP-4096) {
|
||||
save_machine_regs();
|
||||
siglongjmp(Yap_IOBotch,1);
|
||||
}
|
||||
return(o);
|
||||
} else {
|
||||
return(VarNames(p->VarRight,VarNames(p->VarLeft,l)));
|
||||
return VarNames(p->VarRight,VarNames(p->VarLeft,l PASS_REGS) PASS_REGS);
|
||||
}
|
||||
} else {
|
||||
return (l);
|
||||
@ -195,15 +196,16 @@ VarNames(VarEntry *p,Term l)
|
||||
Term
|
||||
Yap_VarNames(VarEntry *p,Term l)
|
||||
{
|
||||
return VarNames(p,l);
|
||||
CACHE_REGS
|
||||
return VarNames(p,l PASS_REGS);
|
||||
}
|
||||
|
||||
static int
|
||||
IsPrefixOp(Atom op,int *pptr, int *rpptr)
|
||||
IsPrefixOp(Atom op,int *pptr, int *rpptr USES_REGS)
|
||||
{
|
||||
int p;
|
||||
|
||||
OpEntry *opp = Yap_GetOpProp(op, PREFIX_OP);
|
||||
OpEntry *opp = Yap_GetOpProp(op, PREFIX_OP PASS_REGS);
|
||||
if (!opp)
|
||||
return FALSE;
|
||||
if (opp->OpModule &&
|
||||
@ -224,15 +226,16 @@ IsPrefixOp(Atom op,int *pptr, int *rpptr)
|
||||
int
|
||||
Yap_IsPrefixOp(Atom op,int *pptr, int *rpptr)
|
||||
{
|
||||
return IsPrefixOp(op,pptr,rpptr);
|
||||
CACHE_REGS
|
||||
return IsPrefixOp(op,pptr,rpptr PASS_REGS);
|
||||
}
|
||||
|
||||
static int
|
||||
IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr)
|
||||
IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr USES_REGS)
|
||||
{
|
||||
int p;
|
||||
|
||||
OpEntry *opp = Yap_GetOpProp(op, INFIX_OP);
|
||||
OpEntry *opp = Yap_GetOpProp(op, INFIX_OP PASS_REGS);
|
||||
if (!opp)
|
||||
return FALSE;
|
||||
if (opp->OpModule &&
|
||||
@ -255,15 +258,16 @@ IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr)
|
||||
int
|
||||
Yap_IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr)
|
||||
{
|
||||
return IsInfixOp(op, pptr, lpptr, rpptr);
|
||||
CACHE_REGS
|
||||
return IsInfixOp(op, pptr, lpptr, rpptr PASS_REGS);
|
||||
}
|
||||
|
||||
static int
|
||||
IsPosfixOp(Atom op, int *pptr, int *lpptr)
|
||||
IsPosfixOp(Atom op, int *pptr, int *lpptr USES_REGS)
|
||||
{
|
||||
int p;
|
||||
|
||||
OpEntry *opp = Yap_GetOpProp(op, INFIX_OP);
|
||||
OpEntry *opp = Yap_GetOpProp(op, INFIX_OP PASS_REGS);
|
||||
if (!opp)
|
||||
return FALSE;
|
||||
if (opp->OpModule &&
|
||||
@ -284,11 +288,12 @@ IsPosfixOp(Atom op, int *pptr, int *lpptr)
|
||||
int
|
||||
Yap_IsPosfixOp(Atom op, int *pptr, int *lpptr)
|
||||
{
|
||||
return IsPosfixOp(op, pptr, lpptr);
|
||||
CACHE_REGS
|
||||
return IsPosfixOp(op, pptr, lpptr PASS_REGS);
|
||||
}
|
||||
|
||||
inline static void
|
||||
GNextToken(void)
|
||||
GNextToken( USES_REGS1 )
|
||||
{
|
||||
if (Yap_tokptr->Tok == Ord(eot_tok))
|
||||
return;
|
||||
@ -304,7 +309,7 @@ GNextToken(void)
|
||||
}
|
||||
|
||||
inline static void
|
||||
checkfor(Term c, JMPBUFF *FailBuff)
|
||||
checkfor(Term c, JMPBUFF *FailBuff USES_REGS)
|
||||
{
|
||||
if (Yap_tokptr->Tok != Ord(Ponctuation_tok)
|
||||
|| Yap_tokptr->TokInfo != c)
|
||||
@ -313,7 +318,7 @@ checkfor(Term c, JMPBUFF *FailBuff)
|
||||
}
|
||||
|
||||
static Term
|
||||
ParseArgs(Atom a, JMPBUFF *FailBuff)
|
||||
ParseArgs(Atom a, JMPBUFF *FailBuff USES_REGS)
|
||||
{
|
||||
int nargs = 0;
|
||||
Term *p, t;
|
||||
@ -330,7 +335,7 @@ ParseArgs(Atom a, JMPBUFF *FailBuff)
|
||||
Yap_ErrorMessage = "Trail Overflow";
|
||||
FAIL;
|
||||
}
|
||||
*tp++ = Unsigned(ParseTerm(999, FailBuff));
|
||||
*tp++ = Unsigned(ParseTerm(999, FailBuff PASS_REGS));
|
||||
ParserAuxSp = (char *)tp;
|
||||
++nargs;
|
||||
if (Yap_tokptr->Tok != Ord(Ponctuation_tok))
|
||||
@ -369,13 +374,13 @@ ParseArgs(Atom a, JMPBUFF *FailBuff)
|
||||
return TermNil;
|
||||
}
|
||||
/* check for possible overflow against local stack */
|
||||
checkfor((Term) ')', FailBuff);
|
||||
checkfor((Term) ')', FailBuff PASS_REGS);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
static Term
|
||||
ParseList(JMPBUFF *FailBuff)
|
||||
ParseList(JMPBUFF *FailBuff USES_REGS)
|
||||
{
|
||||
Term o;
|
||||
CELL *to_store;
|
||||
@ -383,14 +388,14 @@ ParseList(JMPBUFF *FailBuff)
|
||||
loop:
|
||||
to_store = H;
|
||||
H+=2;
|
||||
to_store[0] = ParseTerm(999, FailBuff);
|
||||
to_store[0] = ParseTerm(999, FailBuff PASS_REGS);
|
||||
if (Yap_tokptr->Tok == Ord(Ponctuation_tok)) {
|
||||
if (((int) Yap_tokptr->TokInfo) == ',') {
|
||||
NextToken;
|
||||
if (Yap_tokptr->Tok == Ord(Name_tok)
|
||||
&& strcmp(RepAtom((Atom)(Yap_tokptr->TokInfo))->StrOfAE, "..") == 0) {
|
||||
NextToken;
|
||||
to_store[1] = ParseTerm(999, FailBuff);
|
||||
to_store[1] = ParseTerm(999, FailBuff PASS_REGS);
|
||||
} else {
|
||||
/* check for possible overflow against local stack */
|
||||
if (H > ASP-4096) {
|
||||
@ -404,7 +409,7 @@ ParseList(JMPBUFF *FailBuff)
|
||||
}
|
||||
} else if (((int) Yap_tokptr->TokInfo) == '|') {
|
||||
NextToken;
|
||||
to_store[1] = ParseTerm(999, FailBuff);
|
||||
to_store[1] = ParseTerm(999, FailBuff PASS_REGS);
|
||||
} else {
|
||||
to_store[1] = MkAtomTerm(AtomNil);
|
||||
}
|
||||
@ -422,7 +427,7 @@ ParseList(JMPBUFF *FailBuff)
|
||||
#endif
|
||||
|
||||
static Term
|
||||
ParseTerm(int prio, JMPBUFF *FailBuff)
|
||||
ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
|
||||
{
|
||||
/* parse term with priority prio */
|
||||
Volatile Term t;
|
||||
@ -437,7 +442,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
||||
NextToken;
|
||||
if ((Yap_tokptr->Tok != Ord(Ponctuation_tok)
|
||||
|| Unsigned(Yap_tokptr->TokInfo) != 'l')
|
||||
&& IsPrefixOp((Atom)t, &opprio, &oprprio)
|
||||
&& IsPrefixOp((Atom)t, &opprio, &oprprio PASS_REGS)
|
||||
) {
|
||||
/* special rules apply for +1, -2.3, etc... */
|
||||
if (Yap_tokptr->Tok == Number_tok) {
|
||||
@ -492,7 +497,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
||||
Yap_ErrorMessage = "Heap Overflow";
|
||||
FAIL;
|
||||
}
|
||||
t = ParseTerm(oprprio, FailBuff);
|
||||
t = ParseTerm(oprprio, FailBuff PASS_REGS);
|
||||
t = Yap_MkApplTerm(func, 1, &t);
|
||||
/* check for possible overflow against local stack */
|
||||
if (H > ASP-4096) {
|
||||
@ -507,7 +512,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
||||
}
|
||||
if (Yap_tokptr->Tok == Ord(Ponctuation_tok)
|
||||
&& Unsigned(Yap_tokptr->TokInfo) == 'l')
|
||||
t = ParseArgs((Atom) t, FailBuff);
|
||||
t = ParseArgs((Atom) t, FailBuff PASS_REGS);
|
||||
else
|
||||
t = MkAtomTerm((Atom)t);
|
||||
break;
|
||||
@ -568,24 +573,24 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
||||
case '(':
|
||||
case 'l': /* non solo ( */
|
||||
NextToken;
|
||||
t = ParseTerm(1200, FailBuff);
|
||||
checkfor((Term) ')', FailBuff);
|
||||
t = ParseTerm(1200, FailBuff PASS_REGS);
|
||||
checkfor((Term) ')', FailBuff PASS_REGS);
|
||||
break;
|
||||
case '[':
|
||||
NextToken;
|
||||
t = ParseList(FailBuff);
|
||||
checkfor((Term) ']', FailBuff);
|
||||
t = ParseList(FailBuff PASS_REGS);
|
||||
checkfor((Term) ']', FailBuff PASS_REGS);
|
||||
break;
|
||||
case '{':
|
||||
NextToken;
|
||||
t = ParseTerm(1200, FailBuff);
|
||||
t = ParseTerm(1200, FailBuff PASS_REGS);
|
||||
t = Yap_MkApplTerm(FunctorBraces, 1, &t);
|
||||
/* check for possible overflow against local stack */
|
||||
if (H > ASP-4096) {
|
||||
Yap_ErrorMessage = "Stack Overflow";
|
||||
FAIL;
|
||||
}
|
||||
checkfor((Term) '}', FailBuff);
|
||||
checkfor((Term) '}', FailBuff PASS_REGS);
|
||||
break;
|
||||
default:
|
||||
FAIL;
|
||||
@ -602,7 +607,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
||||
if (Yap_tokptr->Tok == Ord(Name_tok)
|
||||
&& Yap_HasOp((Atom)(Yap_tokptr->TokInfo))) {
|
||||
Atom save_opinfo = opinfo = (Atom)(Yap_tokptr->TokInfo);
|
||||
if (IsInfixOp(save_opinfo, &opprio, &oplprio, &oprprio)
|
||||
if (IsInfixOp(save_opinfo, &opprio, &oplprio, &oprprio PASS_REGS)
|
||||
&& opprio <= prio && oplprio >= curprio) {
|
||||
/* try parsing as infix operator */
|
||||
Volatile int oldprio = curprio;
|
||||
@ -616,7 +621,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
||||
{
|
||||
Term args[2];
|
||||
args[0] = t;
|
||||
args[1] = ParseTerm(oprprio, FailBuff);
|
||||
args[1] = ParseTerm(oprprio, FailBuff PASS_REGS);
|
||||
t = Yap_MkApplTerm(func, 2, args);
|
||||
/* check for possible overflow against local stack */
|
||||
if (H > ASP-4096) {
|
||||
@ -632,7 +637,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
||||
curprio = oldprio;
|
||||
)
|
||||
}
|
||||
if (IsPosfixOp(opinfo, &opprio, &oplprio)
|
||||
if (IsPosfixOp(opinfo, &opprio, &oplprio PASS_REGS)
|
||||
&& opprio <= prio && oplprio >= curprio) {
|
||||
/* parse as posfix operator */
|
||||
Functor func = Yap_MkFunctor((Atom) Yap_tokptr->TokInfo, 1);
|
||||
@ -658,7 +663,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
||||
Volatile Term args[2];
|
||||
NextToken;
|
||||
args[0] = t;
|
||||
args[1] = ParseTerm(1000, FailBuff);
|
||||
args[1] = ParseTerm(1000, FailBuff PASS_REGS);
|
||||
t = Yap_MkApplTerm(FunctorComma, 2, args);
|
||||
/* check for possible overflow against local stack */
|
||||
if (H > ASP-4096) {
|
||||
@ -668,12 +673,12 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
||||
curprio = 1000;
|
||||
continue;
|
||||
} else if (Unsigned(Yap_tokptr->TokInfo) == '|' &&
|
||||
IsInfixOp(AtomVBar, &opprio, &oplprio, &oprprio)
|
||||
IsInfixOp(AtomVBar, &opprio, &oplprio, &oprprio PASS_REGS)
|
||||
&& opprio <= prio && oplprio >= curprio) {
|
||||
Volatile Term args[2];
|
||||
NextToken;
|
||||
args[0] = t;
|
||||
args[1] = ParseTerm(oprprio, FailBuff);
|
||||
args[1] = ParseTerm(oprprio, FailBuff PASS_REGS);
|
||||
t = Yap_MkApplTerm(FunctorVBar, 2, args);
|
||||
/* check for possible overflow against local stack */
|
||||
if (H > ASP-4096) {
|
||||
@ -703,11 +708,12 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
||||
Term
|
||||
Yap_Parse(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
Volatile Term t;
|
||||
JMPBUFF FailBuff;
|
||||
|
||||
if (!sigsetjmp(FailBuff.JmpBuff, 0)) {
|
||||
t = ParseTerm(1200, &FailBuff);
|
||||
t = ParseTerm(1200, &FailBuff PASS_REGS);
|
||||
if (Yap_tokptr->Tok != Ord(eot_tok))
|
||||
return (0L);
|
||||
return (t);
|
||||
|
146
C/save.c
146
C/save.c
@ -92,32 +92,31 @@ STATIC_PROTO(Int putout, (CELL));
|
||||
STATIC_PROTO(Int putcellptr, (CELL *));
|
||||
STATIC_PROTO(CELL get_cell, (void));
|
||||
STATIC_PROTO(CELL *get_cellptr, ( /* CELL * */ void));
|
||||
STATIC_PROTO(int put_info, (int, int));
|
||||
STATIC_PROTO(int save_regs, (int));
|
||||
STATIC_PROTO(int put_info, (int, int CACHE_TYPE));
|
||||
STATIC_PROTO(int save_regs, (int CACHE_TYPE));
|
||||
STATIC_PROTO(int save_code_info, (void));
|
||||
STATIC_PROTO(int save_heap, (void));
|
||||
STATIC_PROTO(int save_stacks, (int));
|
||||
STATIC_PROTO(int save_stacks, (int CACHE_TYPE));
|
||||
STATIC_PROTO(int save_crc, (void));
|
||||
STATIC_PROTO(Int do_save, (int));
|
||||
STATIC_PROTO(Int p_save2, (void));
|
||||
STATIC_PROTO(Int p_save_program, (void));
|
||||
STATIC_PROTO(int check_header, (CELL *, CELL *, CELL *, CELL *));
|
||||
STATIC_PROTO(int get_heap_info, (void));
|
||||
STATIC_PROTO(int get_regs, (int));
|
||||
STATIC_PROTO(Int do_save, (int CACHE_TYPE));
|
||||
STATIC_PROTO(Int p_save2, ( CACHE_TYPE1 ));
|
||||
STATIC_PROTO(Int p_save_program, ( CACHE_TYPE1 ));
|
||||
STATIC_PROTO(int check_header, (CELL *, CELL *, CELL *, CELL * CACHE_TYPE));
|
||||
STATIC_PROTO(int get_heap_info, (CACHE_TYPE1));
|
||||
STATIC_PROTO(int get_regs, (int CACHE_TYPE));
|
||||
STATIC_PROTO(int get_insts, (OPCODE []));
|
||||
STATIC_PROTO(int get_hash, (void));
|
||||
STATIC_PROTO(int CopyCode, (void));
|
||||
STATIC_PROTO(int CopyStacks, (void));
|
||||
STATIC_PROTO(int get_coded, (int, OPCODE []));
|
||||
STATIC_PROTO(int CopyCode, ( CACHE_TYPE1 ));
|
||||
STATIC_PROTO(int CopyStacks, ( CACHE_TYPE1 ));
|
||||
STATIC_PROTO(int get_coded, (int, OPCODE [] CACHE_TYPE));
|
||||
STATIC_PROTO(void restore_codes, (void));
|
||||
STATIC_PROTO(Term AdjustDBTerm, (Term, Term *));
|
||||
STATIC_PROTO(void RestoreDB, (DBEntry *));
|
||||
STATIC_PROTO(void RestoreDBTerm, (DBTerm *, int));
|
||||
STATIC_PROTO(void CleanClauses, (yamop *, yamop *,PredEntry *));
|
||||
STATIC_PROTO(void rehash, (CELL *, int, int));
|
||||
STATIC_PROTO(void CleanCode, (PredEntry *));
|
||||
STATIC_PROTO(void RestoreEntries, (PropEntry *, int));
|
||||
STATIC_PROTO(void RestoreFreeSpace, (void));
|
||||
STATIC_PROTO(void RestoreDB, (DBEntry * CACHE_TYPE));
|
||||
STATIC_PROTO(void RestoreDBTerm, (DBTerm *, int CACHE_TYPE));
|
||||
STATIC_PROTO(void CleanClauses, (yamop *, yamop *,PredEntry * CACHE_TYPE));
|
||||
STATIC_PROTO(void rehash, (CELL *, int, int CACHE_TYPE));
|
||||
STATIC_PROTO(void CleanCode, (PredEntry * CACHE_TYPE));
|
||||
STATIC_PROTO(void RestoreEntries, (PropEntry *, int CACHE_TYPE));
|
||||
STATIC_PROTO(void RestoreFreeSpace, ( CACHE_TYPE1 ));
|
||||
STATIC_PROTO(void restore_heap, (void));
|
||||
#ifdef DEBUG_RESTORE3
|
||||
STATIC_PROTO(void ShowAtoms, (void));
|
||||
@ -128,10 +127,10 @@ STATIC_PROTO(void CloseRestore, (void));
|
||||
#ifndef _WIN32
|
||||
STATIC_PROTO(int check_opcodes, (OPCODE []));
|
||||
#endif
|
||||
STATIC_PROTO(void RestoreHeap, (OPCODE []));
|
||||
STATIC_PROTO(Int p_restore, (void));
|
||||
STATIC_PROTO(void restore_heap_regs, (void));
|
||||
STATIC_PROTO(void restore_regs, (int));
|
||||
STATIC_PROTO(void RestoreHeap, (OPCODE [] CACHE_TYPE));
|
||||
STATIC_PROTO(Int p_restore, ( CACHE_TYPE1 ));
|
||||
STATIC_PROTO(void restore_heap_regs, ( CACHE_TYPE1 ));
|
||||
STATIC_PROTO(void restore_regs, (int CACHE_TYPE));
|
||||
#ifdef MACYAP
|
||||
STATIC_PROTO(void NewFileInfo, (long, long));
|
||||
extern int DefVol;
|
||||
@ -162,6 +161,7 @@ LightBug(s)
|
||||
static Int
|
||||
do_system_error(yap_error_number etype, const char *msg)
|
||||
{
|
||||
CACHE_REGS
|
||||
#if HAVE_SNPRINTF
|
||||
#if HAVE_STRERROR
|
||||
snprintf(Yap_ErrorSay,MAX_ERROR_MSG_SIZE,"%s (%s when reading %s)", msg, strerror(errno), Yap_FileNameBuf);
|
||||
@ -335,7 +335,7 @@ get_cellptr(void)
|
||||
* set, the work size, and the space ocuppied
|
||||
*/
|
||||
static int
|
||||
put_info(int info, int mode)
|
||||
put_info(int info, int mode USES_REGS)
|
||||
{
|
||||
char msg[256];
|
||||
|
||||
@ -373,7 +373,7 @@ put_info(int info, int mode)
|
||||
}
|
||||
|
||||
static int
|
||||
save_regs(int mode)
|
||||
save_regs(int mode USES_REGS)
|
||||
{
|
||||
/* save all registers */
|
||||
if (putout((CELL)compile_arrays) < 0)
|
||||
@ -516,7 +516,7 @@ save_heap(void)
|
||||
}
|
||||
|
||||
static int
|
||||
save_stacks(int mode)
|
||||
save_stacks(int mode USES_REGS)
|
||||
{
|
||||
int j;
|
||||
|
||||
@ -572,7 +572,7 @@ save_crc(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
do_save(int mode) {
|
||||
do_save(int mode USES_REGS) {
|
||||
Term t1 = Deref(ARG1);
|
||||
|
||||
if (Yap_HoleSize) {
|
||||
@ -590,15 +590,15 @@ do_save(int mode) {
|
||||
"restore/1, open(%s)", strerror(errno));
|
||||
return(FALSE);
|
||||
}
|
||||
if (put_info(FullSaved, mode) < 0)
|
||||
if (put_info(FullSaved, mode PASS_REGS) < 0)
|
||||
return -1;
|
||||
if (save_regs(mode) < 0)
|
||||
if (save_regs(mode PASS_REGS) < 0)
|
||||
return -1;
|
||||
if (save_code_info() < 0)
|
||||
return -1;
|
||||
if (save_heap() < 0)
|
||||
return -1;
|
||||
if (save_stacks(mode) < 0)
|
||||
if (save_stacks(mode PASS_REGS) < 0)
|
||||
return -1;
|
||||
if (save_crc() < 0)
|
||||
return -1;
|
||||
@ -608,7 +608,7 @@ do_save(int mode) {
|
||||
|
||||
/* Saves a complete prolog environment */
|
||||
static Int
|
||||
p_save2(void)
|
||||
p_save2( USES_REGS1 )
|
||||
{
|
||||
Int res;
|
||||
|
||||
@ -632,25 +632,25 @@ p_save2(void)
|
||||
if (!Yap_unify(ARG2,MkIntTerm(1)))
|
||||
return FALSE;
|
||||
which_save = 2;
|
||||
Yap_StartSlots();
|
||||
res = do_save(DO_EVERYTHING);
|
||||
Yap_CloseSlots();
|
||||
Yap_StartSlots( PASS_REGS1 );
|
||||
res = do_save(DO_EVERYTHING PASS_REGS);
|
||||
Yap_CloseSlots( PASS_REGS1 );
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Just save the program, not the stacks */
|
||||
static Int
|
||||
p_save_program(void)
|
||||
p_save_program( USES_REGS1 )
|
||||
{
|
||||
which_save = 0;
|
||||
return do_save(DO_ONLY_CODE);
|
||||
return do_save(DO_ONLY_CODE PASS_REGS);
|
||||
}
|
||||
|
||||
/* Now, to restore the saved code */
|
||||
|
||||
/* First check out if we are dealing with a valid file */
|
||||
static int
|
||||
check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap)
|
||||
check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS)
|
||||
{
|
||||
char pp[256];
|
||||
char msg[256];
|
||||
@ -756,7 +756,7 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap)
|
||||
|
||||
/* Gets the state of the heap, and evaluates the related variables */
|
||||
static int
|
||||
get_heap_info(void)
|
||||
get_heap_info(USES_REGS1)
|
||||
{
|
||||
OldHeapBase = (ADDR) get_cellptr();
|
||||
if (Yap_ErrorMessage)
|
||||
@ -797,7 +797,7 @@ get_heap_info(void)
|
||||
/* Saves the old bases for the work areas */
|
||||
/* and evaluates the difference from the old areas to the new ones */
|
||||
static int
|
||||
get_regs(int flag)
|
||||
get_regs(int flag USES_REGS)
|
||||
{
|
||||
CELL *NewGlobalBase = (CELL *)Yap_GlobalBase;
|
||||
CELL *NewLCL0 = LCL0;
|
||||
@ -897,7 +897,7 @@ get_regs(int flag)
|
||||
XDiff = (CELL)XREGS - (CELL)OldXREGS;
|
||||
if (Yap_ErrorMessage)
|
||||
return -1;
|
||||
if (get_heap_info() < 0)
|
||||
if (get_heap_info( PASS_REGS1 ) < 0)
|
||||
return -1;
|
||||
if (flag == DO_EVERYTHING) {
|
||||
ARG1 = get_cell();
|
||||
@ -944,7 +944,7 @@ get_hash(void)
|
||||
|
||||
/* Copy all of the old code to the new Heap */
|
||||
static int
|
||||
CopyCode(void)
|
||||
CopyCode( USES_REGS1 )
|
||||
{
|
||||
if (myread(splfild, (char *) Yap_HeapBase, (Unsigned(OldHeapTop) - Unsigned(OldHeapBase))) < 0) {
|
||||
return -1;
|
||||
@ -955,7 +955,7 @@ CopyCode(void)
|
||||
/* Copy the local and global stack and also the trail to their new home */
|
||||
/* In REGS we still have nonadjusted values !! */
|
||||
static int
|
||||
CopyStacks(void)
|
||||
CopyStacks( USES_REGS1 )
|
||||
{
|
||||
Int j;
|
||||
char *NewASP;
|
||||
@ -976,7 +976,7 @@ CopyStacks(void)
|
||||
/* Copy the local and global stack and also the trail to their new home */
|
||||
/* In REGS we still have nonadjusted values !! */
|
||||
static int
|
||||
CopyTrailEntries(void)
|
||||
CopyTrailEntries( USES_REGS1 )
|
||||
{
|
||||
CELL entry, *Entries;
|
||||
|
||||
@ -991,25 +991,25 @@ CopyTrailEntries(void)
|
||||
|
||||
/* get things which are saved in the file */
|
||||
static int
|
||||
get_coded(int flag, OPCODE old_ops[])
|
||||
get_coded(int flag, OPCODE old_ops[] USES_REGS)
|
||||
{
|
||||
char my_end_msg[256];
|
||||
|
||||
if (get_regs(flag) < 0)
|
||||
if (get_regs(flag PASS_REGS) < 0)
|
||||
return -1;
|
||||
if (get_insts(old_ops) < 0)
|
||||
return -1;
|
||||
if (get_hash() < 0)
|
||||
return -1;
|
||||
if (CopyCode() < 0)
|
||||
if (CopyCode( PASS_REGS1 ) < 0)
|
||||
return -1;
|
||||
switch (flag) {
|
||||
case DO_EVERYTHING:
|
||||
if (CopyStacks() < 0)
|
||||
if (CopyStacks( PASS_REGS1 ) < 0)
|
||||
return -1;
|
||||
break;
|
||||
case DO_ONLY_CODE:
|
||||
if (CopyTrailEntries() < 0)
|
||||
if (CopyTrailEntries( PASS_REGS1 ) < 0)
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
@ -1025,7 +1025,7 @@ get_coded(int flag, OPCODE old_ops[])
|
||||
|
||||
/* restore some heap registers */
|
||||
static void
|
||||
restore_heap_regs(void)
|
||||
restore_heap_regs( USES_REGS1 )
|
||||
{
|
||||
if (HeapTop) {
|
||||
HeapTop = AddrAdjust(HeapTop);
|
||||
@ -1037,9 +1037,9 @@ restore_heap_regs(void)
|
||||
|
||||
/* adjust abstract machine registers */
|
||||
static void
|
||||
restore_regs(int flag)
|
||||
restore_regs(int flag USES_REGS)
|
||||
{
|
||||
restore_heap_regs();
|
||||
restore_heap_regs( PASS_REGS1 );
|
||||
if (CurrentModule) {
|
||||
CurrentModule = AtomTermAdjust(CurrentModule);;
|
||||
}
|
||||
@ -1056,7 +1056,7 @@ restore_regs(int flag)
|
||||
S = PtoGloAdjust(S);
|
||||
if (EX) {
|
||||
EX = DBTermAdjust(EX);
|
||||
RestoreDBTerm(EX, TRUE);
|
||||
RestoreDBTerm(EX, TRUE PASS_REGS);
|
||||
}
|
||||
WokenGoals = AbsAppl(PtoGloAdjust(RepAppl(WokenGoals)));
|
||||
}
|
||||
@ -1124,7 +1124,7 @@ recompute_mask(DBRef dbr)
|
||||
* previous "hit" order
|
||||
*/
|
||||
static void
|
||||
rehash(CELL *oldcode, int NOfE, int KindOfEntries)
|
||||
rehash(CELL *oldcode, int NOfE, int KindOfEntries USES_REGS)
|
||||
{
|
||||
register CELL *savep, *basep;
|
||||
CELL *oldp = oldcode;
|
||||
@ -1207,7 +1207,7 @@ RestoreIOStructures(void)
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreFreeSpace(void)
|
||||
RestoreFreeSpace( USES_REGS1 )
|
||||
{
|
||||
#if USE_DL_MALLOC
|
||||
Yap_av = (struct malloc_state *)AddrAdjust((ADDR)Yap_av);
|
||||
@ -1255,7 +1255,7 @@ RestoreFreeSpace(void)
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreAtomList(Atom atm)
|
||||
RestoreAtomList(Atom atm USES_REGS)
|
||||
{
|
||||
AtomEntry *at;
|
||||
|
||||
@ -1263,14 +1263,14 @@ RestoreAtomList(Atom atm)
|
||||
if (EndOfPAEntr(at))
|
||||
return;
|
||||
do {
|
||||
RestoreAtom(at);
|
||||
RestoreAtom(at PASS_REGS);
|
||||
at = RepAtom(at->NextOfAE);
|
||||
} while (!EndOfPAEntr(at));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
RestoreHashPreds(void)
|
||||
RestoreHashPreds( USES_REGS1 )
|
||||
{
|
||||
UInt size = PredHashTableSize;
|
||||
int malloced = FALSE;
|
||||
@ -1301,7 +1301,7 @@ RestoreHashPreds(void)
|
||||
if (p->NextOfPE)
|
||||
p->NextOfPE = PropAdjust(p->NextOfPE);
|
||||
nextp = p->NextOfPE;
|
||||
CleanCode(p);
|
||||
CleanCode(p PASS_REGS);
|
||||
hsh = PRED_HASH(p->FunctorOfPred, p->ModuleOfPred, size);
|
||||
p->NextOfPE = AbsPredProp(np[hsh]);
|
||||
np[hsh] = p;
|
||||
@ -1375,9 +1375,10 @@ ShowAtoms()
|
||||
|
||||
static int
|
||||
commit_to_saved_state(char *s, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap) {
|
||||
CACHE_REGS
|
||||
int mode;
|
||||
|
||||
if ((mode = check_header(Astate,ATrail,AStack,AHeap)) == FAIL_RESTORE)
|
||||
if ((mode = check_header(Astate,ATrail,AStack,AHeap PASS_REGS)) == FAIL_RESTORE)
|
||||
return(FAIL_RESTORE);
|
||||
Yap_PrologMode = BootMode;
|
||||
if (Yap_HeapBase) {
|
||||
@ -1418,6 +1419,7 @@ static int try_open(char *inpf, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *
|
||||
if (buf[0] == '\0')
|
||||
strncpy(buf, inpf, YAP_FILENAME_MAX);
|
||||
if ((mode = commit_to_saved_state(inpf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE) {
|
||||
CACHE_REGS
|
||||
Yap_ErrorMessage = NULL;
|
||||
return mode;
|
||||
}
|
||||
@ -1427,6 +1429,7 @@ static int try_open(char *inpf, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *
|
||||
static int
|
||||
OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap)
|
||||
{
|
||||
CACHE_REGS
|
||||
int mode = FAIL_RESTORE;
|
||||
char save_buffer[YAP_FILENAME_MAX+1];
|
||||
|
||||
@ -1580,7 +1583,7 @@ check_opcodes(OPCODE old_ops[])
|
||||
#endif
|
||||
|
||||
static void
|
||||
RestoreHeap(OPCODE old_ops[])
|
||||
RestoreHeap(OPCODE old_ops[] USES_REGS)
|
||||
{
|
||||
int heap_moved = (OldHeapBase != Yap_HeapBase ||
|
||||
XDiff), opcodes_moved;
|
||||
@ -1597,7 +1600,7 @@ RestoreHeap(OPCODE old_ops[])
|
||||
/* opcodes_moved has side-effects and should be tried first */
|
||||
if (heap_moved) {
|
||||
opcodes_moved = TRUE;
|
||||
RestoreFreeSpace();
|
||||
RestoreFreeSpace( PASS_REGS1 );
|
||||
}
|
||||
if (heap_moved || opcodes_moved) {
|
||||
restore_heap();
|
||||
@ -1644,7 +1647,7 @@ Yap_SavedInfo(char *FileName, char *YapLibDir, CELL *ATrail, CELL *AStack, CELL
|
||||
}
|
||||
|
||||
static void
|
||||
UnmarkTrEntries(void)
|
||||
UnmarkTrEntries( USES_REGS1 )
|
||||
{
|
||||
CELL entry, *Entries;
|
||||
|
||||
@ -1713,7 +1716,7 @@ FreeRecords(void) {
|
||||
* associated registers
|
||||
*/
|
||||
static int
|
||||
Restore(char *s, char *lib_dir)
|
||||
Restore(char *s, char *lib_dir USES_REGS)
|
||||
{
|
||||
int restore_mode;
|
||||
|
||||
@ -1724,12 +1727,12 @@ Restore(char *s, char *lib_dir)
|
||||
return(FALSE);
|
||||
Yap_ShutdownLoadForeign();
|
||||
in_limbo = TRUE;
|
||||
if (get_coded(restore_mode, old_ops) < 0)
|
||||
if (get_coded(restore_mode, old_ops PASS_REGS) < 0)
|
||||
return FAIL_RESTORE;
|
||||
restore_regs(restore_mode);
|
||||
restore_regs(restore_mode PASS_REGS);
|
||||
in_limbo = FALSE;
|
||||
/*#endif*/
|
||||
RestoreHeap(old_ops);
|
||||
RestoreHeap(old_ops PASS_REGS);
|
||||
switch(restore_mode) {
|
||||
case DO_EVERYTHING:
|
||||
if (OldHeapBase != Yap_HeapBase ||
|
||||
@ -1749,7 +1752,7 @@ Restore(char *s, char *lib_dir)
|
||||
}
|
||||
break;
|
||||
case DO_ONLY_CODE:
|
||||
UnmarkTrEntries();
|
||||
UnmarkTrEntries( PASS_REGS1 );
|
||||
Yap_InitYaamRegs();
|
||||
break;
|
||||
}
|
||||
@ -1777,11 +1780,12 @@ Restore(char *s, char *lib_dir)
|
||||
int
|
||||
Yap_Restore(char *s, char *lib_dir)
|
||||
{
|
||||
return Restore(s, lib_dir);
|
||||
CACHE_REGS
|
||||
return Restore(s, lib_dir PASS_REGS);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_restore(void)
|
||||
p_restore( USES_REGS1 )
|
||||
{
|
||||
int mode;
|
||||
char s[YAP_FILENAME_MAX+1];
|
||||
@ -1802,7 +1806,7 @@ p_restore(void)
|
||||
Yap_Error(TYPE_ERROR_LIST,t1,"restore/1");
|
||||
return(FALSE);
|
||||
}
|
||||
if ((mode = Restore(s, NULL)) == DO_ONLY_CODE) {
|
||||
if ((mode = Restore(s, NULL PASS_REGS)) == DO_ONLY_CODE) {
|
||||
#if PUSH_REGS
|
||||
restore_absmi_regs(&Yap_standard_regs);
|
||||
#endif
|
||||
|
95
C/scanner.c
95
C/scanner.c
@ -170,6 +170,7 @@ typedef struct scanner_extra_alloc {
|
||||
static char *
|
||||
AllocScannerMemory(unsigned int size)
|
||||
{
|
||||
CACHE_REGS
|
||||
char *AuxSpScan;
|
||||
|
||||
AuxSpScan = ScannerStack;
|
||||
@ -206,6 +207,7 @@ AllocScannerMemory(unsigned int size)
|
||||
static void
|
||||
PopScannerMemory(char *block, unsigned int size)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (block == ScannerStack-size) {
|
||||
ScannerStack -= size;
|
||||
} else if (block == (char *)(ScannerExtraBlocks+1)) {
|
||||
@ -232,6 +234,7 @@ float_send(char *s, int sign)
|
||||
#if HAVE_FINITE
|
||||
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) { /* iso */
|
||||
if (!finite(f)) {
|
||||
CACHE_REGS
|
||||
Yap_ErrorMessage = "Float overflow while scanning";
|
||||
return(MkEvalFl(0.0));
|
||||
}
|
||||
@ -261,6 +264,13 @@ read_int_overflow(const char *s, Int base, Int val, int sign)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
send_error_message(char s[])
|
||||
{
|
||||
CACHE_REGS
|
||||
Yap_ErrorMessage = s;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static wchar_t
|
||||
read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
||||
@ -285,8 +295,7 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
||||
return '\b';
|
||||
case 'c':
|
||||
if (yap_flags[CHARACTER_ESCAPE_FLAG] == ISO_CHARACTER_ESCAPES) {
|
||||
Yap_ErrorMessage = "invalid escape sequence \\c";
|
||||
return 0;
|
||||
return send_error_message("invalid escape sequence \\c");
|
||||
} else {
|
||||
/* sicstus */
|
||||
ch = getchrq(inp_stream);
|
||||
@ -322,8 +331,7 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
||||
} else if (ch>='A' && ch <= 'F') {
|
||||
wc += ((ch-'A')+10)<<((3-i)*4);
|
||||
} else {
|
||||
Yap_ErrorMessage = "invalid escape sequence";
|
||||
return 0;
|
||||
return send_error_message("invalid escape sequence");
|
||||
}
|
||||
}
|
||||
return wc;
|
||||
@ -342,8 +350,7 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
||||
} else if (ch>='A' && ch <= 'F') {
|
||||
wc += ((ch-'A')+10)<<((7-i)*4);
|
||||
} else {
|
||||
Yap_ErrorMessage = "invalid escape sequence";
|
||||
return 0;
|
||||
return send_error_message("invalid escape sequence");
|
||||
}
|
||||
}
|
||||
return wc;
|
||||
@ -360,8 +367,7 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
||||
return '`';
|
||||
case '^':
|
||||
if (yap_flags[CHARACTER_ESCAPE_FLAG] == ISO_CHARACTER_ESCAPES) {
|
||||
Yap_ErrorMessage = "invalid escape sequence";
|
||||
return 0;
|
||||
return send_error_message("invalid escape sequence");
|
||||
} else {
|
||||
ch = getchrq(inp_stream);
|
||||
if (ch == '?') {/* delete character */
|
||||
@ -393,20 +399,17 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
||||
so_far = so_far*8+(ch-'0');
|
||||
ch = getchrq(inp_stream);
|
||||
if (ch != '\\') {
|
||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
||||
return 0;
|
||||
return send_error_message("invalid octal escape sequence");
|
||||
}
|
||||
} else if (ch == '\\') {
|
||||
return so_far;
|
||||
} else {
|
||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
||||
return 0;
|
||||
return send_error_message("invalid octal escape sequence");
|
||||
}
|
||||
} else if (ch == '\\') {
|
||||
return so_far;
|
||||
} else {
|
||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
||||
return 0;
|
||||
return send_error_message("invalid octal escape sequence");
|
||||
}
|
||||
} else {
|
||||
/* sicstus */
|
||||
@ -442,20 +445,17 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
||||
if (ch == '\\') {
|
||||
return so_far;
|
||||
} else {
|
||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
return 0;
|
||||
return send_error_message("invalid hexadecimal escape sequence");
|
||||
}
|
||||
} else if (ch == '\\') {
|
||||
return so_far;
|
||||
} else {
|
||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
return 0;
|
||||
return send_error_message("invalid hexadecimal escape sequence");
|
||||
}
|
||||
} else if (ch == '\\') {
|
||||
return so_far;
|
||||
} else {
|
||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
||||
return 0;
|
||||
return send_error_message("invalid hexadecimal escape sequence");
|
||||
}
|
||||
} else {
|
||||
/* sicstus mode */
|
||||
@ -474,8 +474,7 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
||||
consider this sequence legal, whereas SICStus would
|
||||
eat up the escape sequence. */
|
||||
if (yap_flags[CHARACTER_ESCAPE_FLAG] == ISO_CHARACTER_ESCAPES) {
|
||||
Yap_ErrorMessage = "invalid escape sequence";
|
||||
return 0;
|
||||
return send_error_message("invalid escape sequence");
|
||||
} else {
|
||||
/* sicstus */
|
||||
if (chtype(ch) == SL) {
|
||||
@ -487,8 +486,17 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
num_send_error_message(char s[])
|
||||
{
|
||||
CACHE_REGS
|
||||
Yap_ErrorMessage = s;
|
||||
return TermNil;
|
||||
}
|
||||
|
||||
/* reads a number, either integer or float */
|
||||
|
||||
|
||||
static Term
|
||||
get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, int sign)
|
||||
{
|
||||
@ -506,21 +514,18 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
|
||||
if (chtype(ch) == NU) {
|
||||
*sp++ = ch;
|
||||
if (--max_size == 0) {
|
||||
Yap_ErrorMessage = "Number Too Long";
|
||||
return TermNil;
|
||||
return num_send_error_message("Number Too Long");
|
||||
}
|
||||
base = 10 * base + ch - '0';
|
||||
ch = getchr(inp_stream);
|
||||
}
|
||||
if (ch == '\'') {
|
||||
if (base > 36) {
|
||||
Yap_ErrorMessage = "Admissible bases are 0..36";
|
||||
return TermNil;
|
||||
return num_send_error_message("Admissible bases are 0..36");
|
||||
}
|
||||
might_be_float = FALSE;
|
||||
if (--max_size == 0) {
|
||||
Yap_ErrorMessage = "Number Too Long";
|
||||
return TermNil;
|
||||
return num_send_error_message("Number Too Long");
|
||||
}
|
||||
*sp++ = ch;
|
||||
ch = getchr(inp_stream);
|
||||
@ -548,8 +553,7 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
|
||||
int chval = (chtype(ch) == NU ? ch - '0' :
|
||||
(my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
|
||||
if (--max_size == 0) {
|
||||
Yap_ErrorMessage = "Number Too Long";
|
||||
return TermNil;
|
||||
return num_send_error_message("Number Too Long");
|
||||
}
|
||||
*sp++ = ch;
|
||||
val = oval * base + chval;
|
||||
@ -561,8 +565,7 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
|
||||
} else if (ch == 'x' && base == 0) {
|
||||
might_be_float = FALSE;
|
||||
if (--max_size == 0) {
|
||||
Yap_ErrorMessage = "Number Too Long";
|
||||
return TermNil;
|
||||
return num_send_error_message("Number Too Long");
|
||||
}
|
||||
*sp++ = ch;
|
||||
ch = getchr(inp_stream);
|
||||
@ -571,8 +574,7 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
|
||||
int chval = (chtype(ch) == NU ? ch - '0' :
|
||||
(my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
|
||||
if (--max_size == 0) {
|
||||
Yap_ErrorMessage = "Number Too Long";
|
||||
return TermNil;
|
||||
return num_send_error_message("Number Too Long");
|
||||
}
|
||||
*sp++ = ch;
|
||||
val = val * 16 + chval;
|
||||
@ -598,8 +600,7 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
|
||||
Int oval = val;
|
||||
if (!(val == 0 && ch == '0') || has_overflow) {
|
||||
if (--max_size == 0) {
|
||||
Yap_ErrorMessage = "Number Too Long";
|
||||
return (TermNil);
|
||||
return num_send_error_message("Number Too Long");
|
||||
}
|
||||
*sp++ = ch;
|
||||
}
|
||||
@ -615,13 +616,11 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
|
||||
}
|
||||
if (might_be_float && ( ch == '.' || ch == 'e' || ch == 'E')) {
|
||||
if (yap_flags[STRICT_ISO_FLAG] && (ch == 'e' || ch == 'E')) {
|
||||
Yap_ErrorMessage = "Float format not allowed in ISO mode";
|
||||
return TermNil;
|
||||
return num_send_error_message("Float format not allowed in ISO mode");
|
||||
}
|
||||
if (ch == '.') {
|
||||
if (--max_size == 0) {
|
||||
Yap_ErrorMessage = "Number Too Long";
|
||||
return TermNil;
|
||||
return num_send_error_message("Number Too Long");
|
||||
}
|
||||
*sp++ = '.';
|
||||
if (chtype(ch = getchr(inp_stream)) != NU) {
|
||||
@ -636,8 +635,7 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
|
||||
}
|
||||
do {
|
||||
if (--max_size == 0) {
|
||||
Yap_ErrorMessage = "Number Too Long";
|
||||
return TermNil;
|
||||
return num_send_error_message("Number Too Long");
|
||||
}
|
||||
*sp++ = ch;
|
||||
}
|
||||
@ -648,16 +646,14 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
|
||||
char cbuff = ch;
|
||||
|
||||
if (--max_size == 0) {
|
||||
Yap_ErrorMessage = "Number Too Long";
|
||||
return TermNil;
|
||||
return num_send_error_message("Number Too Long");
|
||||
}
|
||||
*sp++ = ch;
|
||||
ch = getchr(inp_stream);
|
||||
if (ch == '-') {
|
||||
cbuff = '-';
|
||||
if (--max_size == 0) {
|
||||
Yap_ErrorMessage = "Number Too Long";
|
||||
return TermNil;
|
||||
return num_send_error_message("Number Too Long");
|
||||
}
|
||||
*sp++ = '-';
|
||||
ch = getchr(inp_stream);
|
||||
@ -679,8 +675,7 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
|
||||
}
|
||||
do {
|
||||
if (--max_size == 0) {
|
||||
Yap_ErrorMessage = "Number Too Long";
|
||||
return TermNil;
|
||||
return num_send_error_message("Number Too Long");
|
||||
}
|
||||
*sp++ = ch;
|
||||
} while (chtype(ch = getchr(inp_stream)) == NU);
|
||||
@ -714,6 +709,7 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
|
||||
Term
|
||||
Yap_scan_num(IOSTREAM *inp)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term out;
|
||||
int sign = 1;
|
||||
int ch, cherr;
|
||||
@ -756,6 +752,7 @@ Yap_scan_num(IOSTREAM *inp)
|
||||
static wchar_t *
|
||||
ch_to_wide(char *base, char *charp)
|
||||
{
|
||||
CACHE_REGS
|
||||
int n = charp-base, i;
|
||||
wchar_t *nb = (wchar_t *)base;
|
||||
|
||||
@ -784,6 +781,7 @@ ch_to_wide(char *base, char *charp)
|
||||
TokEntry *
|
||||
Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
|
||||
{
|
||||
CACHE_REGS
|
||||
TokEntry *t, *l, *p;
|
||||
enum TokenKinds kind;
|
||||
int solo_flag = TRUE;
|
||||
@ -1269,6 +1267,7 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
|
||||
void
|
||||
Yap_clean_tokenizer(TokEntry *tokstart, VarEntry *vartable, VarEntry *anonvartable)
|
||||
{
|
||||
CACHE_REGS
|
||||
struct scanner_extra_alloc *ptr = ScannerExtraBlocks;
|
||||
while (ptr) {
|
||||
struct scanner_extra_alloc *next = ptr->next;
|
||||
|
22
C/sort.c
22
C/sort.c
@ -28,18 +28,18 @@
|
||||
#define M_EVEN 0
|
||||
#define M_ODD 1
|
||||
|
||||
STATIC_PROTO(Int build_new_list, (CELL *, Term));
|
||||
STATIC_PROTO(Int build_new_list, (CELL *, Term CACHE_TYPE));
|
||||
STATIC_PROTO(void simple_mergesort, (CELL *, Int, int));
|
||||
STATIC_PROTO(Int compact_mergesort, (CELL *, Int, int));
|
||||
STATIC_PROTO(int key_mergesort, (CELL *, Int, int, Functor));
|
||||
STATIC_PROTO(void adjust_vector, (CELL *, Int));
|
||||
STATIC_PROTO(Int p_sort, (void));
|
||||
STATIC_PROTO(Int p_msort, (void));
|
||||
STATIC_PROTO(Int p_ksort, (void));
|
||||
STATIC_PROTO(Int p_sort, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_msort, ( USES_REGS1 ));
|
||||
STATIC_PROTO(Int p_ksort, ( USES_REGS1 ));
|
||||
|
||||
/* copy to a new list of terms */
|
||||
static Int
|
||||
build_new_list(CELL *pt, Term t)
|
||||
build_new_list(CELL *pt, Term t USES_REGS)
|
||||
{
|
||||
Int out = 0;
|
||||
if (IsVarTerm(t))
|
||||
@ -343,14 +343,14 @@ adjust_vector(CELL *pt, Int size)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_sort(void)
|
||||
p_sort( USES_REGS1 )
|
||||
{
|
||||
/* use the heap to build a new list */
|
||||
CELL *pt = H;
|
||||
Term out;
|
||||
/* list size */
|
||||
Int size;
|
||||
size = build_new_list(pt, Deref(ARG1));
|
||||
size = build_new_list(pt, Deref(ARG1) PASS_REGS);
|
||||
if (size < 0)
|
||||
return(FALSE);
|
||||
if (size < 2)
|
||||
@ -368,14 +368,14 @@ p_sort(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_msort(void)
|
||||
p_msort( USES_REGS1 )
|
||||
{
|
||||
/* use the heap to build a new list */
|
||||
CELL *pt = H;
|
||||
Term out;
|
||||
/* list size */
|
||||
Int size;
|
||||
size = build_new_list(pt, Deref(ARG1));
|
||||
size = build_new_list(pt, Deref(ARG1) PASS_REGS);
|
||||
if (size < 0)
|
||||
return(FALSE);
|
||||
if (size < 2)
|
||||
@ -390,14 +390,14 @@ p_msort(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_ksort(void)
|
||||
p_ksort( USES_REGS1 )
|
||||
{
|
||||
/* use the heap to build a new list */
|
||||
CELL *pt = H;
|
||||
Term out;
|
||||
/* list size */
|
||||
Int size;
|
||||
size = build_new_list(pt, Deref(ARG1));
|
||||
size = build_new_list(pt, Deref(ARG1) PASS_REGS);
|
||||
if (size < 0)
|
||||
return(FALSE);
|
||||
if (size < 2)
|
||||
|
352
C/stdpreds.c
352
C/stdpreds.c
File diff suppressed because it is too large
Load Diff
80
C/sysbits.c
80
C/sysbits.c
@ -91,16 +91,16 @@ static char SccsId[] = "%W% %G%";
|
||||
STATIC_PROTO (void InitPageSize, (void));
|
||||
STATIC_PROTO (void InitTime, (void));
|
||||
STATIC_PROTO (void InitWTime, (void));
|
||||
STATIC_PROTO (Int p_sh, (void));
|
||||
STATIC_PROTO (Int p_shell, (void));
|
||||
STATIC_PROTO (Int p_system, (void));
|
||||
STATIC_PROTO (Int p_mv, (void));
|
||||
STATIC_PROTO (Int p_dir_sp, (void));
|
||||
STATIC_PROTO (Int p_sh, ( USES_REGS1 ));
|
||||
STATIC_PROTO (Int p_shell, ( USES_REGS1 ));
|
||||
STATIC_PROTO (Int p_system, ( USES_REGS1 ));
|
||||
STATIC_PROTO (Int p_mv, ( USES_REGS1 ));
|
||||
STATIC_PROTO (Int p_dir_sp, ( USES_REGS1 ));
|
||||
STATIC_PROTO (void InitRandom, (void));
|
||||
STATIC_PROTO (Int p_srandom, (void));
|
||||
STATIC_PROTO (Int p_alarm, (void));
|
||||
STATIC_PROTO (Int p_getenv, (void));
|
||||
STATIC_PROTO (Int p_putenv, (void));
|
||||
STATIC_PROTO (Int p_srandom, ( USES_REGS1 ));
|
||||
STATIC_PROTO (Int p_alarm, ( USES_REGS1 ));
|
||||
STATIC_PROTO (Int p_getenv, ( USES_REGS1 ));
|
||||
STATIC_PROTO (Int p_putenv, ( USES_REGS1 ));
|
||||
STATIC_PROTO (void set_fpu_exceptions, (int));
|
||||
#ifdef MACYAP
|
||||
STATIC_PROTO (int chdir, (char *));
|
||||
@ -181,6 +181,7 @@ char *libdir = NULL;
|
||||
|
||||
void
|
||||
Yap_InitSysPath(void) {
|
||||
CACHE_REGS
|
||||
int len;
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
int dir_done = FALSE;
|
||||
@ -269,7 +270,7 @@ Yap_InitSysPath(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_dir_sp (void)
|
||||
p_dir_sp ( USES_REGS1 )
|
||||
{
|
||||
#ifdef MAC
|
||||
Term t = MkIntTerm(':');
|
||||
@ -347,6 +348,7 @@ static struct timeval StartOfTimes_sys;
|
||||
static void
|
||||
InitTime (void)
|
||||
{
|
||||
CACHE_REGS
|
||||
struct rusage rusage;
|
||||
|
||||
#if THREADS
|
||||
@ -362,8 +364,9 @@ InitTime (void)
|
||||
|
||||
|
||||
UInt
|
||||
Yap_cputime (void)
|
||||
Yap_cputime ( void )
|
||||
{
|
||||
CACHE_REGS
|
||||
struct rusage rusage;
|
||||
|
||||
getrusage(RUSAGE_SELF, &rusage);
|
||||
@ -373,6 +376,7 @@ Yap_cputime (void)
|
||||
|
||||
void Yap_cputime_interval(Int *now,Int *interval)
|
||||
{
|
||||
CACHE_REGS
|
||||
struct rusage rusage;
|
||||
|
||||
getrusage(RUSAGE_SELF, &rusage);
|
||||
@ -466,7 +470,7 @@ sub_utime(FILETIME t1, FILETIME t2)
|
||||
#endif
|
||||
|
||||
UInt
|
||||
Yap_cputime (void)
|
||||
Yap_cputime ( USES_REGS1 )
|
||||
{
|
||||
HANDLE hProcess = GetCurrentProcess();
|
||||
FILETIME CreationTime, ExitTime, KernelTime, UserTime;
|
||||
@ -991,7 +995,7 @@ Yap_random (void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_srandom (void)
|
||||
p_srandom ( USES_REGS1 )
|
||||
{
|
||||
register Term t0 = Deref (ARG1);
|
||||
if (IsVarTerm (t0)) {
|
||||
@ -1654,6 +1658,7 @@ HandleSIGINT (int sig, siginfo_t *x, ucontext_t *y)
|
||||
HandleSIGINT (int sig)
|
||||
#endif
|
||||
{
|
||||
CACHE_REGS
|
||||
my_signal(SIGINT, HandleSIGINT);
|
||||
/* do this before we act */
|
||||
#if HAVE_ISATTY
|
||||
@ -1866,6 +1871,7 @@ Yap_volume_header(char *file)
|
||||
|
||||
int Yap_getcwd(const char *buf, int len)
|
||||
{
|
||||
CACHE_REGS
|
||||
#if __simplescalar__
|
||||
/* does not implement getcwd */
|
||||
strncpy(Yap_buf,yap_pwd,len);
|
||||
@ -1897,6 +1903,7 @@ int Yap_getcwd(const char *buf, int len)
|
||||
static int
|
||||
TrueFileName (char *source, char *root, char *result, int in_lib)
|
||||
{
|
||||
CACHE_REGS
|
||||
char *work;
|
||||
char ares1[YAP_FILENAME_MAX];
|
||||
|
||||
@ -2082,7 +2089,7 @@ Yap_TrueFileName (char *source, char *result, int in_lib)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_true_file_name (void)
|
||||
p_true_file_name ( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
|
||||
@ -2099,7 +2106,7 @@ p_true_file_name (void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_true_file_name3 (void)
|
||||
p_true_file_name3 ( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1), t2 = Deref(ARG2);
|
||||
char *root = NULL;
|
||||
@ -2126,7 +2133,7 @@ p_true_file_name3 (void)
|
||||
/* Executes $SHELL under Prolog */
|
||||
|
||||
static Int
|
||||
p_sh (void)
|
||||
p_sh ( USES_REGS1 )
|
||||
{ /* sh */
|
||||
#ifdef HAVE_SYSTEM
|
||||
char *shell;
|
||||
@ -2156,7 +2163,7 @@ p_sh (void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_shell (void)
|
||||
p_shell ( USES_REGS1 )
|
||||
{ /* '$shell'(+SystCommand) */
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"shell not available in this configuration");
|
||||
@ -2216,7 +2223,7 @@ p_shell (void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_system (void)
|
||||
p_system ( USES_REGS1 )
|
||||
{ /* '$system'(+SystCommand) */
|
||||
#ifdef HAVE_SYSTEM
|
||||
Term t1 = Deref (ARG1);
|
||||
@ -2266,7 +2273,7 @@ p_system (void)
|
||||
|
||||
/* Rename a file */
|
||||
static Int
|
||||
p_mv (void)
|
||||
p_mv ( USES_REGS1 )
|
||||
{ /* rename(+OldName,+NewName) */
|
||||
#if HAVE_LINK
|
||||
int r;
|
||||
@ -2333,7 +2340,7 @@ Yap_SetTextFile (name)
|
||||
|
||||
|
||||
/* return YAP's environment */
|
||||
static Int p_getenv(void)
|
||||
static Int p_getenv( USES_REGS1 )
|
||||
{
|
||||
#if HAVE_GETENV
|
||||
Term t1 = Deref(ARG1), to;
|
||||
@ -2360,7 +2367,7 @@ static Int p_getenv(void)
|
||||
}
|
||||
|
||||
/* set a variable in YAP's environment */
|
||||
static Int p_putenv(void)
|
||||
static Int p_putenv( USES_REGS1 )
|
||||
{
|
||||
#if HAVE_PUTENV
|
||||
Term t1 = Deref(ARG1), t2 = Deref(ARG2);
|
||||
@ -2443,7 +2450,7 @@ DoTimerThread(LPVOID targ)
|
||||
#endif
|
||||
|
||||
static Int
|
||||
p_alarm(void)
|
||||
p_alarm( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
Term t2 = Deref(ARG2);
|
||||
@ -2543,7 +2550,7 @@ p_alarm(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_virtual_alarm(void)
|
||||
p_virtual_alarm( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
Term t2 = Deref(ARG2);
|
||||
@ -2679,7 +2686,7 @@ Yap_set_fpu_exceptions(int flag)
|
||||
set_fpu_exceptions(flag);
|
||||
}
|
||||
static Int
|
||||
p_set_fpu_exceptions(void) {
|
||||
p_set_fpu_exceptions( USES_REGS1 ) {
|
||||
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) {
|
||||
set_fpu_exceptions(FALSE); /* can't make it work right */
|
||||
} else {
|
||||
@ -2689,19 +2696,19 @@ p_set_fpu_exceptions(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
p_host_type(void) {
|
||||
p_host_type( USES_REGS1 ) {
|
||||
Term out = MkAtomTerm(Yap_LookupAtom(HOST_ALIAS));
|
||||
return(Yap_unify(out,ARG1));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_yap_home(void) {
|
||||
p_yap_home( USES_REGS1 ) {
|
||||
Term out = MkAtomTerm(Yap_LookupAtom(YAP_ROOTDIR));
|
||||
return(Yap_unify(out,ARG1));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_env_separator(void) {
|
||||
p_env_separator( USES_REGS1 ) {
|
||||
#if defined(_WIN32)
|
||||
return Yap_unify(MkIntegerTerm(';'),ARG1);
|
||||
#else
|
||||
@ -2745,7 +2752,7 @@ Yap_ReInitWallTime (void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_first_signal(void)
|
||||
p_first_signal( USES_REGS1 )
|
||||
{
|
||||
LOCK(SignalLock);
|
||||
#ifdef THREADS
|
||||
@ -2891,7 +2898,7 @@ p_first_signal(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_continue_signals(void)
|
||||
p_continue_signals( USES_REGS1 )
|
||||
{
|
||||
/* hack to force the signal anew */
|
||||
if (ActiveSignals & YAP_ITI_SIGNAL) {
|
||||
@ -2946,7 +2953,7 @@ p_continue_signals(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_unix(void)
|
||||
p_unix( USES_REGS1 )
|
||||
{
|
||||
#ifdef unix
|
||||
return TRUE;
|
||||
@ -2964,7 +2971,7 @@ p_unix(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_win32(void)
|
||||
p_win32( USES_REGS1 )
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return TRUE;
|
||||
@ -2979,7 +2986,7 @@ p_win32(void)
|
||||
|
||||
|
||||
static Int
|
||||
p_enable_interrupts(void)
|
||||
p_enable_interrupts( USES_REGS1 )
|
||||
{
|
||||
LOCK(SignalLock);
|
||||
Yap_InterruptsDisabled--;
|
||||
@ -2991,7 +2998,7 @@ p_enable_interrupts(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_disable_interrupts(void)
|
||||
p_disable_interrupts( USES_REGS1 )
|
||||
{
|
||||
LOCK(SignalLock);
|
||||
Yap_InterruptsDisabled++;
|
||||
@ -3003,13 +3010,13 @@ p_disable_interrupts(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_ld_path(void)
|
||||
p_ld_path( USES_REGS1 )
|
||||
{
|
||||
return Yap_unify(ARG1,MkAtomTerm(Yap_LookupAtom(YAP_LIBDIR)));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_address_bits(void)
|
||||
p_address_bits( USES_REGS1 )
|
||||
{
|
||||
#if SIZEOF_INT_P==4
|
||||
return Yap_unify(ARG1,MkIntTerm(32));
|
||||
@ -3112,7 +3119,7 @@ WideStringFromAtom(Atom KeyAt)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_win_registry_get_value(void)
|
||||
p_win_registry_get_value( USES_REGS1 )
|
||||
{
|
||||
DWORD type;
|
||||
BYTE data[MAXREGSTRLEN];
|
||||
@ -3213,6 +3220,7 @@ Yap_RegistryGetString(char *name)
|
||||
void
|
||||
Yap_InitSysPreds(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term cm = CurrentModule;
|
||||
|
||||
/* can only do after heap is initialised */
|
||||
|
82
C/threads.c
82
C/threads.c
@ -70,6 +70,7 @@ allocate_new_tid(void)
|
||||
static int
|
||||
store_specs(int new_worker_id, UInt ssize, UInt tsize, UInt sysize, Term *tpgoal, Term *tpdetach, Term *tpexit)
|
||||
{
|
||||
CACHE_REGS
|
||||
UInt pm; /* memory to be requested */
|
||||
Term tmod;
|
||||
Term tdetach, tgoal;
|
||||
@ -111,6 +112,7 @@ store_specs(int new_worker_id, UInt ssize, UInt tsize, UInt sysize, Term *tpgoal
|
||||
static void
|
||||
kill_thread_engine (int wid, int always_die)
|
||||
{
|
||||
CACHE_REGS
|
||||
Prop p0 = AbsPredProp(FOREIGN_ThreadHandle(wid).local_preds);
|
||||
GlobalEntry *gl = GlobalVariables;
|
||||
|
||||
@ -159,6 +161,7 @@ thread_die(int wid, int always_die)
|
||||
static void
|
||||
setup_engine(int myworker_id, int init_thread)
|
||||
{
|
||||
CACHE_REGS
|
||||
REGSTORE *standard_regs;
|
||||
|
||||
standard_regs = (REGSTORE *)calloc(1,sizeof(REGSTORE));
|
||||
@ -191,6 +194,7 @@ start_thread(int myworker_id)
|
||||
static void *
|
||||
thread_run(void *widp)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term tgoal, t;
|
||||
Term tgs[2];
|
||||
int myworker_id = *((int *)widp);
|
||||
@ -225,7 +229,7 @@ thread_run(void *widp)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_new_tid(void)
|
||||
p_thread_new_tid( USES_REGS1 )
|
||||
{
|
||||
int new_worker = allocate_new_tid();
|
||||
if (new_worker == -1) {
|
||||
@ -242,7 +246,7 @@ init_thread_engine(int new_worker_id, UInt ssize, UInt tsize, UInt sysize, Term
|
||||
}
|
||||
|
||||
static Int
|
||||
p_create_thread(void)
|
||||
p_create_thread( USES_REGS1 )
|
||||
{
|
||||
UInt ssize;
|
||||
UInt tsize;
|
||||
@ -279,7 +283,7 @@ p_create_thread(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_sleep(void)
|
||||
p_thread_sleep( USES_REGS1 )
|
||||
{
|
||||
UInt time = IntegerOfTerm(Deref(ARG1));
|
||||
#if HAVE_NANOSLEEP
|
||||
@ -314,7 +318,7 @@ p_thread_sleep(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_self(void)
|
||||
p_thread_self( USES_REGS1 )
|
||||
{
|
||||
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
|
||||
return Yap_unify(MkIntegerTerm(-1), ARG1);
|
||||
@ -323,7 +327,7 @@ p_thread_self(void)
|
||||
|
||||
|
||||
static Int
|
||||
p_thread_zombie_self(void)
|
||||
p_thread_zombie_self( USES_REGS1 )
|
||||
{
|
||||
/* make sure the lock is available */
|
||||
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
|
||||
@ -342,7 +346,7 @@ p_thread_zombie_self(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_status_lock(void)
|
||||
p_thread_status_lock( USES_REGS1 )
|
||||
{
|
||||
/* make sure the lock is available */
|
||||
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
|
||||
@ -352,7 +356,7 @@ p_thread_status_lock(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_status_unlock(void)
|
||||
p_thread_status_unlock( USES_REGS1 )
|
||||
{
|
||||
/* make sure the lock is available */
|
||||
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
|
||||
@ -364,6 +368,7 @@ p_thread_status_unlock(void)
|
||||
Int
|
||||
Yap_thread_self(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
|
||||
return -1;
|
||||
return worker_id;
|
||||
@ -412,6 +417,7 @@ Yap_thread_create_engine(thread_attr *ops)
|
||||
Int
|
||||
Yap_thread_attach_engine(int wid)
|
||||
{
|
||||
CACHE_REGS
|
||||
/*
|
||||
already locked
|
||||
pthread_mutex_lock(&(FOREIGN_ThreadHandle(wid).tlock));
|
||||
@ -462,7 +468,7 @@ Yap_thread_destroy_engine(int wid)
|
||||
|
||||
|
||||
static Int
|
||||
p_thread_join(void)
|
||||
p_thread_join( USES_REGS1 )
|
||||
{
|
||||
Int tid = IntegerOfTerm(Deref(ARG1));
|
||||
|
||||
@ -487,7 +493,7 @@ p_thread_join(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_destroy(void)
|
||||
p_thread_destroy( USES_REGS1 )
|
||||
{
|
||||
Int tid = IntegerOfTerm(Deref(ARG1));
|
||||
|
||||
@ -501,7 +507,7 @@ p_thread_destroy(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_detach(void)
|
||||
p_thread_detach( USES_REGS1 )
|
||||
{
|
||||
Int tid = IntegerOfTerm(Deref(ARG1));
|
||||
pthread_mutex_lock(&(FOREIGN_ThreadHandle(tid).tlock));
|
||||
@ -520,7 +526,7 @@ p_thread_detach(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_detached(void)
|
||||
p_thread_detached( USES_REGS1 )
|
||||
{
|
||||
if (MY_ThreadHandle.tdetach)
|
||||
return Yap_unify(ARG1,MY_ThreadHandle.tdetach);
|
||||
@ -529,7 +535,7 @@ p_thread_detached(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_detached2(void)
|
||||
p_thread_detached2( USES_REGS1 )
|
||||
{
|
||||
Int tid = IntegerOfTerm(Deref(ARG1));
|
||||
if (FOREIGN_ThreadHandle(tid).tdetach)
|
||||
@ -539,7 +545,7 @@ p_thread_detached2(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_exit(void)
|
||||
p_thread_exit( USES_REGS1 )
|
||||
{
|
||||
thread_die(worker_id, FALSE);
|
||||
pthread_exit(NULL);
|
||||
@ -548,7 +554,7 @@ p_thread_exit(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_set_concurrency(void)
|
||||
p_thread_set_concurrency( USES_REGS1 )
|
||||
{
|
||||
Term tnew = Deref(ARG2);
|
||||
int newc, cur;
|
||||
@ -569,7 +575,7 @@ p_thread_set_concurrency(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_yield(void)
|
||||
p_thread_yield( USES_REGS1 )
|
||||
{
|
||||
if (sched_yield() != 0) {
|
||||
return FALSE;
|
||||
@ -578,7 +584,7 @@ p_thread_yield(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_valid_thread(void)
|
||||
p_valid_thread( USES_REGS1 )
|
||||
{
|
||||
Int i = IntegerOfTerm(Deref(ARG1));
|
||||
return FOREIGN_ThreadHandle(i).in_use || FOREIGN_ThreadHandle(i).zombie;
|
||||
@ -593,7 +599,7 @@ typedef struct swi_mutex {
|
||||
} SWIMutex;
|
||||
|
||||
static Int
|
||||
p_new_mutex(void)
|
||||
p_new_mutex( USES_REGS1 )
|
||||
{
|
||||
SWIMutex* mutp;
|
||||
pthread_mutexattr_t mat;
|
||||
@ -617,7 +623,7 @@ p_new_mutex(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_destroy_mutex(void)
|
||||
p_destroy_mutex( USES_REGS1 )
|
||||
{
|
||||
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG1));
|
||||
|
||||
@ -628,7 +634,7 @@ p_destroy_mutex(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_lock_mutex(void)
|
||||
p_lock_mutex( USES_REGS1 )
|
||||
{
|
||||
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG1));
|
||||
|
||||
@ -640,7 +646,7 @@ p_lock_mutex(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_trylock_mutex(void)
|
||||
p_trylock_mutex( USES_REGS1 )
|
||||
{
|
||||
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG1));
|
||||
|
||||
@ -652,7 +658,7 @@ p_trylock_mutex(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_unlock_mutex(void)
|
||||
p_unlock_mutex( USES_REGS1 )
|
||||
{
|
||||
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG1));
|
||||
|
||||
@ -663,7 +669,7 @@ p_unlock_mutex(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_mutex_info(void)
|
||||
p_mutex_info( USES_REGS1 )
|
||||
{
|
||||
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG1));
|
||||
|
||||
@ -673,7 +679,7 @@ p_mutex_info(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_cond_create(void)
|
||||
p_cond_create( USES_REGS1 )
|
||||
{
|
||||
pthread_cond_t* condp;
|
||||
|
||||
@ -686,7 +692,7 @@ p_cond_create(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_cond_destroy(void)
|
||||
p_cond_destroy( USES_REGS1 )
|
||||
{
|
||||
pthread_cond_t *condp = (pthread_cond_t *)IntegerOfTerm(Deref(ARG1));
|
||||
|
||||
@ -697,7 +703,7 @@ p_cond_destroy(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_cond_signal(void)
|
||||
p_cond_signal( USES_REGS1 )
|
||||
{
|
||||
pthread_cond_t *condp = (pthread_cond_t *)IntegerOfTerm(Deref(ARG1));
|
||||
|
||||
@ -707,7 +713,7 @@ p_cond_signal(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_cond_broadcast(void)
|
||||
p_cond_broadcast( USES_REGS1 )
|
||||
{
|
||||
pthread_cond_t *condp = (pthread_cond_t *)IntegerOfTerm(Deref(ARG1));
|
||||
|
||||
@ -717,7 +723,7 @@ p_cond_broadcast(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_cond_wait(void)
|
||||
p_cond_wait( USES_REGS1 )
|
||||
{
|
||||
pthread_cond_t *condp = (pthread_cond_t *)IntegerOfTerm(Deref(ARG1));
|
||||
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG2));
|
||||
@ -727,7 +733,7 @@ p_cond_wait(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_stacks(void)
|
||||
p_thread_stacks( USES_REGS1 )
|
||||
{ /* '$thread_signal'(+P) */
|
||||
Int tid = IntegerOfTerm(Deref(ARG1));
|
||||
Int status= TRUE;
|
||||
@ -746,7 +752,7 @@ p_thread_stacks(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_atexit(void)
|
||||
p_thread_atexit( USES_REGS1 )
|
||||
{ /* '$thread_signal'(+P) */
|
||||
Term t;
|
||||
|
||||
@ -781,7 +787,7 @@ p_thread_atexit(void)
|
||||
|
||||
|
||||
static Int
|
||||
p_thread_signal(void)
|
||||
p_thread_signal( USES_REGS1 )
|
||||
{ /* '$thread_signal'(+P) */
|
||||
Int wid = IntegerOfTerm(Deref(ARG1));
|
||||
/* make sure the lock is available */
|
||||
@ -804,13 +810,13 @@ p_thread_signal(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_no_threads(void)
|
||||
p_no_threads( USES_REGS1 )
|
||||
{ /* '$thread_signal'(+P) */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nof_threads(void)
|
||||
p_nof_threads( USES_REGS1 )
|
||||
{ /* '$nof_threads'(+P) */
|
||||
int i = 0, wid;
|
||||
LOCK(ThreadHandlesLock);
|
||||
@ -823,38 +829,38 @@ p_nof_threads(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_max_workers(void)
|
||||
p_max_workers( USES_REGS1 )
|
||||
{ /* '$max_workers'(+P) */
|
||||
return Yap_unify(ARG1,MkIntegerTerm(MAX_WORKERS));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_max_threads(void)
|
||||
p_max_threads( USES_REGS1 )
|
||||
{ /* '$max_threads'(+P) */
|
||||
return Yap_unify(ARG1,MkIntegerTerm(MAX_THREADS));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_nof_threads_created(void)
|
||||
p_nof_threads_created( USES_REGS1 )
|
||||
{ /* '$nof_threads'(+P) */
|
||||
return Yap_unify(ARG1,MkIntTerm(NOfThreadsCreated));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_runtime(void)
|
||||
p_thread_runtime( USES_REGS1 )
|
||||
{ /* '$thread_runtime'(+P) */
|
||||
return Yap_unify(ARG1,MkIntegerTerm(ThreadsTotalTime));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_self_lock(void)
|
||||
p_thread_self_lock( USES_REGS1 )
|
||||
{ /* '$thread_unlock' */
|
||||
pthread_mutex_lock(&(MY_ThreadHandle.tlock));
|
||||
return Yap_unify(ARG1,MkIntegerTerm(worker_id));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_unlock(void)
|
||||
p_thread_unlock( USES_REGS1 )
|
||||
{ /* '$thread_unlock' */
|
||||
Int wid = IntegerOfTerm(Deref(ARG1));
|
||||
DEBUG_TLOCK_ACCESS(19, wid);
|
||||
|
17
C/tracer.c
17
C/tracer.c
@ -39,7 +39,7 @@ TracePutchar(int sno, int ch)
|
||||
static void
|
||||
send_tracer_message(char *start, char *name, Int arity, char *mname, CELL *args)
|
||||
{
|
||||
|
||||
CACHE_REGS
|
||||
if (name == NULL) {
|
||||
#ifdef YAPOR
|
||||
fprintf(Yap_stderr, "(%d)%s", worker_id, start);
|
||||
@ -154,6 +154,7 @@ Term old_x1[10000], old_x2[10000], old_x3[10000];
|
||||
void
|
||||
low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
{
|
||||
CACHE_REGS
|
||||
char *s;
|
||||
char *mname;
|
||||
Int arity;
|
||||
@ -357,31 +358,31 @@ toggle_low_level_trace(void)
|
||||
Yap_do_low_level_trace = !Yap_do_low_level_trace;
|
||||
}
|
||||
|
||||
static Int p_start_low_level_trace(void)
|
||||
static Int p_start_low_level_trace( USES_REGS1 )
|
||||
{
|
||||
Yap_do_low_level_trace = TRUE;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static Int p_total_choicepoints(void)
|
||||
static Int p_total_choicepoints( USES_REGS1 )
|
||||
{
|
||||
return Yap_unify(MkIntegerTerm(Yap_total_choicepoints),ARG1);
|
||||
}
|
||||
|
||||
static Int p_reset_total_choicepoints(void)
|
||||
static Int p_reset_total_choicepoints( USES_REGS1 )
|
||||
{
|
||||
Yap_total_choicepoints = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int p_show_low_level_trace(void)
|
||||
static Int p_show_low_level_trace( USES_REGS1 )
|
||||
{
|
||||
fprintf(stderr,"Call counter=%lld\n",vsc_count);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
#ifdef THREADS
|
||||
static Int p_start_low_level_trace2(void)
|
||||
static Int p_start_low_level_trace2( USES_REGS1 )
|
||||
{
|
||||
thread_trace = IntegerOfTerm(Deref(ARG1))+1;
|
||||
Yap_do_low_level_trace = TRUE;
|
||||
@ -391,7 +392,7 @@ static Int p_start_low_level_trace2(void)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static Int p_stop_low_level_trace(void)
|
||||
static Int p_stop_low_level_trace( USES_REGS1 )
|
||||
{
|
||||
Yap_do_low_level_trace = FALSE;
|
||||
do_trace_primitives = TRUE;
|
||||
@ -400,7 +401,7 @@ static Int p_stop_low_level_trace(void)
|
||||
|
||||
volatile int vsc_wait;
|
||||
|
||||
static Int p_vsc_wait(void)
|
||||
static Int p_vsc_wait( USES_REGS1 )
|
||||
{
|
||||
while (!vsc_wait);
|
||||
vsc_wait=1;
|
||||
|
2
C/udi.c
2
C/udi.c
@ -48,7 +48,7 @@ add_udi_block(void *info, PredEntry *p, UdiControlBlock cmd)
|
||||
the second argument is the term.
|
||||
******/
|
||||
static Int
|
||||
p_new_udi(void)
|
||||
p_new_udi( USES_REGS1 )
|
||||
{
|
||||
Term spec = Deref(ARG2), udi_type = Deref(ARG1);
|
||||
PredEntry *p;
|
||||
|
22
C/unify.c
22
C/unify.c
@ -16,13 +16,15 @@
|
||||
*************************************************************************/
|
||||
#define IN_UNIFY_C 1
|
||||
|
||||
#define HAS_CACHE_REGS 1
|
||||
|
||||
#include "absmi.h"
|
||||
|
||||
STD_PROTO(int Yap_rational_tree_loop, (CELL *, CELL *, CELL **, CELL **));
|
||||
|
||||
STATIC_PROTO(int OCUnify_complex, (CELL *, CELL *, CELL *));
|
||||
STATIC_PROTO(int OCUnify, (register CELL, register CELL));
|
||||
STATIC_PROTO(Int p_ocunify, (void));
|
||||
STATIC_PROTO(Int p_ocunify, ( USES_REGS1 ));
|
||||
#ifdef THREADED_CODE
|
||||
STATIC_PROTO(int rtable_hash_op, (OPCODE));
|
||||
STATIC_PROTO(void InitReverseLookupOpcode, (void));
|
||||
@ -35,7 +37,6 @@ STATIC_PROTO(void InitReverseLookupOpcode, (void));
|
||||
int
|
||||
Yap_rational_tree_loop(CELL *pt0, CELL *pt0_end, CELL **to_visit, CELL **to_visit_max)
|
||||
{
|
||||
|
||||
CELL ** base = to_visit;
|
||||
rtree_loop:
|
||||
while (pt0 < pt0_end) {
|
||||
@ -114,6 +115,7 @@ cufail:
|
||||
|
||||
static inline int
|
||||
rational_tree(Term d0) {
|
||||
CACHE_REGS
|
||||
CELL **to_visit_max = (CELL **)AuxBase, **to_visit = (CELL **)AuxSp;
|
||||
|
||||
if (IsPairTerm(d0)) {
|
||||
@ -134,6 +136,7 @@ rational_tree(Term d0) {
|
||||
static int
|
||||
OCUnify_complex(CELL *pt0, CELL *pt0_end, CELL *pt1)
|
||||
{
|
||||
CACHE_REGS
|
||||
#ifdef THREADS
|
||||
#undef Yap_REGS
|
||||
register REGSTORE *regp = Yap_regp;
|
||||
@ -339,7 +342,7 @@ cufail:
|
||||
static int
|
||||
OCUnify(register CELL d0, register CELL d1)
|
||||
{
|
||||
|
||||
CACHE_REGS
|
||||
register CELL *pt0, *pt1;
|
||||
|
||||
#if SHADOW_HB
|
||||
@ -451,13 +454,13 @@ oc_unify_var_nvar:
|
||||
}
|
||||
|
||||
static Int
|
||||
p_ocunify(void)
|
||||
p_ocunify( USES_REGS1 )
|
||||
{
|
||||
return(OCUnify(ARG1,ARG2));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_cyclic(void)
|
||||
p_cyclic( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
if (IsVarTerm(t))
|
||||
@ -466,7 +469,7 @@ p_cyclic(void)
|
||||
}
|
||||
|
||||
static Int
|
||||
p_acyclic(void)
|
||||
p_acyclic( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
if (IsVarTerm(t))
|
||||
@ -477,6 +480,7 @@ p_acyclic(void)
|
||||
int
|
||||
Yap_IUnify(register CELL d0, register CELL d1)
|
||||
{
|
||||
CACHE_REGS
|
||||
#if THREADS
|
||||
#undef Yap_REGS
|
||||
register REGSTORE *regp = Yap_regp;
|
||||
@ -665,6 +669,7 @@ InitReverseLookupOpcode(void)
|
||||
static int
|
||||
unifiable_complex(CELL *pt0, CELL *pt0_end, CELL *pt1)
|
||||
{
|
||||
CACHE_REGS
|
||||
#ifdef THREADS
|
||||
#undef Yap_REGS
|
||||
register REGSTORE *regp = Yap_regp;
|
||||
@ -865,6 +870,7 @@ cufail:
|
||||
static int
|
||||
unifiable(CELL d0, CELL d1)
|
||||
{
|
||||
CACHE_REGS
|
||||
#if THREADS
|
||||
#undef Yap_REGS
|
||||
register REGSTORE *regp = Yap_regp;
|
||||
@ -985,7 +991,7 @@ unifiable_var_nvar_trail:
|
||||
|
||||
|
||||
static Int
|
||||
p_unifiable(void)
|
||||
p_unifiable( USES_REGS1 )
|
||||
{
|
||||
tr_fr_ptr trp;
|
||||
Term tf = TermNil;
|
||||
@ -1007,6 +1013,7 @@ p_unifiable(void)
|
||||
void
|
||||
Yap_InitUnify(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term cm = CurrentModule;
|
||||
Yap_InitCPred("unify_with_occurs_check", 2, p_ocunify, SafePredFlag);
|
||||
Yap_InitCPred("acyclic_term", 1, p_acyclic, SafePredFlag|TestPredFlag);
|
||||
@ -1030,6 +1037,7 @@ Yap_InitAbsmi(void)
|
||||
void
|
||||
Yap_TrimTrail(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
#ifdef saveregs
|
||||
#undef saveregs
|
||||
#define saveregs()
|
||||
|
294
C/utilpreds.c
294
C/utilpreds.c
File diff suppressed because it is too large
Load Diff
84
C/write.c
84
C/write.c
@ -91,6 +91,7 @@ static void
|
||||
wrputn(Int n, wrf writewch) /* writes an integer */
|
||||
|
||||
{
|
||||
CACHE_REGS
|
||||
char s[256], *s1=s; /* that should be enough for most integers */
|
||||
if (n < 0) {
|
||||
if (lastw == symbol)
|
||||
@ -112,6 +113,7 @@ wrputn(Int n, wrf writewch) /* writes an integer */
|
||||
static void
|
||||
wrputs(char *s, wrf writewch) /* writes a string */
|
||||
{
|
||||
CACHE_REGS
|
||||
while (*s) {
|
||||
wrputc((unsigned char)(*s++), writewch);
|
||||
}
|
||||
@ -120,6 +122,7 @@ wrputs(char *s, wrf writewch) /* writes a string */
|
||||
static void
|
||||
wrputws(wchar_t *s, wrf writewch) /* writes a string */
|
||||
{
|
||||
CACHE_REGS
|
||||
while (*s)
|
||||
wrputc(*s++, writewch);
|
||||
}
|
||||
@ -128,6 +131,7 @@ wrputws(wchar_t *s, wrf writewch) /* writes a string */
|
||||
|
||||
static char *
|
||||
ensure_space(size_t sz) {
|
||||
CACHE_REGS
|
||||
char *s;
|
||||
|
||||
s = (char *) Yap_PreAllocCodeSpace();
|
||||
@ -165,6 +169,7 @@ ensure_space(size_t sz) {
|
||||
|
||||
static void
|
||||
write_mpint(MP_INT *big, wrf writewch) {
|
||||
CACHE_REGS
|
||||
char *s;
|
||||
|
||||
s = ensure_space(3+mpz_sizeinbase(big, 10));
|
||||
@ -212,6 +217,7 @@ static void
|
||||
wrputf(Float f, wrf writewch) /* writes a float */
|
||||
|
||||
{
|
||||
CACHE_REGS
|
||||
char s[256], *pt = s, ch;
|
||||
int found_dot = FALSE, found_exp = FALSE;
|
||||
|
||||
@ -341,6 +347,7 @@ AtomIsSymbols(unsigned char *s) /* Is this atom just formed by symbols ? */
|
||||
static void
|
||||
write_quoted(int ch, int quote, wrf writewch)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (yap_flags[CHARACTER_ESCAPE_FLAG] == CPROLOG_CHARACTER_ESCAPES) {
|
||||
wrputc(ch, writewch);
|
||||
if (ch == '\'')
|
||||
@ -409,6 +416,7 @@ static void
|
||||
putAtom(Atom atom, int Quote_illegal, wrf writewch) /* writes an atom */
|
||||
|
||||
{
|
||||
CACHE_REGS
|
||||
unsigned char *s = (unsigned char *)RepAtom(atom)->StrOfAE;
|
||||
wtype atom_or_symbol = AtomIsSymbols(s);
|
||||
|
||||
@ -481,6 +489,7 @@ static void
|
||||
putString(Term string, wrf writewch) /* writes a string */
|
||||
|
||||
{
|
||||
CACHE_REGS
|
||||
wrputc('"', writewch);
|
||||
while (string != TermNil) {
|
||||
int ch = IntOfTerm(HeadOfTerm(string));
|
||||
@ -495,6 +504,7 @@ static void
|
||||
putUnquotedString(Term string, wrf writewch) /* writes a string */
|
||||
|
||||
{
|
||||
CACHE_REGS
|
||||
while (string != TermNil) {
|
||||
int ch = IntOfTerm(HeadOfTerm(string));
|
||||
wrputc(ch, writewch);
|
||||
@ -507,6 +517,7 @@ putUnquotedString(Term string, wrf writewch) /* writes a string */
|
||||
static void
|
||||
write_var(CELL *t, struct write_globs *wglb, struct rewind_term *rwt)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (lastw == alphanum) {
|
||||
wrputc(' ', wglb->writewch);
|
||||
}
|
||||
@ -531,14 +542,14 @@ write_var(CELL *t, struct write_globs *wglb, struct rewind_term *rwt)
|
||||
wrputc(',', wglb->writewch);
|
||||
if (wglb->keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
sl = Yap_InitSlot((CELL)attv);
|
||||
sl = Yap_InitSlot((CELL)attv PASS_REGS);
|
||||
}
|
||||
writeTerm((Term)&(attv->Value), 999, 1, FALSE, wglb, rwt);
|
||||
wrputc(',', wglb->writewch);
|
||||
writeTerm(l, 999, 1, FALSE, wglb, rwt);
|
||||
if (wglb->keep_terms) {
|
||||
attv = (attvar_record *)Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
attv = (attvar_record *)Yap_GetFromSlot(sl PASS_REGS);
|
||||
Yap_RecoverSlots(1 PASS_REGS);
|
||||
}
|
||||
wrputc(')', wglb->writewch);
|
||||
}
|
||||
@ -557,6 +568,7 @@ write_var(CELL *t, struct write_globs *wglb, struct rewind_term *rwt)
|
||||
static Term
|
||||
from_pointer(CELL *ptr, struct rewind_term *rwt, struct write_globs *wglb)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t;
|
||||
|
||||
while (IsVarTerm(*ptr) && !IsUnboundVar(ptr))
|
||||
@ -565,10 +577,10 @@ from_pointer(CELL *ptr, struct rewind_term *rwt, struct write_globs *wglb)
|
||||
if (!IsVarTerm(t) && !IsAtomOrIntTerm(t)) {
|
||||
struct rewind_term *x = rwt->parent;
|
||||
if (wglb->keep_terms) {
|
||||
rwt->u.s.old = Yap_InitSlot(t);
|
||||
rwt->u.s.ptr = Yap_InitSlot((CELL)ptr);
|
||||
rwt->u.s.old = Yap_InitSlot(t PASS_REGS);
|
||||
rwt->u.s.ptr = Yap_InitSlot((CELL)ptr PASS_REGS);
|
||||
while (x) {
|
||||
if (Yap_GetFromSlot(x->u.s.old) == t)
|
||||
if (Yap_GetFromSlot(x->u.s.old PASS_REGS) == t)
|
||||
return TermFoundVar;
|
||||
x = x->parent;
|
||||
}
|
||||
@ -590,9 +602,10 @@ from_pointer(CELL *ptr, struct rewind_term *rwt, struct write_globs *wglb)
|
||||
static Term
|
||||
check_infinite_loop(Term t, struct rewind_term *x, struct write_globs *wglb)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (wglb->keep_terms) {
|
||||
while (x) {
|
||||
if (Yap_GetFromSlot(x->u.s.old) == t)
|
||||
if (Yap_GetFromSlot(x->u.s.old PASS_REGS) == t)
|
||||
return TermFoundVar;
|
||||
x = x->parent;
|
||||
}
|
||||
@ -609,13 +622,14 @@ check_infinite_loop(Term t, struct rewind_term *x, struct write_globs *wglb)
|
||||
static void
|
||||
restore_from_write(struct rewind_term *rwt, struct write_globs *wglb)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t;
|
||||
if (rwt->u.s.ptr) {
|
||||
CELL *ptr;
|
||||
if (wglb->keep_terms) {
|
||||
ptr = (CELL *)Yap_GetPtrFromSlot(rwt->u.s.ptr);
|
||||
t = Yap_GetPtrFromSlot(rwt->u.s.old);
|
||||
Yap_RecoverSlots(2);
|
||||
ptr = (CELL *)Yap_GetPtrFromSlot(rwt->u.s.ptr PASS_REGS);
|
||||
t = Yap_GetPtrFromSlot(rwt->u.s.old PASS_REGS);
|
||||
Yap_RecoverSlots(2 PASS_REGS);
|
||||
} else {
|
||||
ptr = rwt->u.d.ptr;
|
||||
t = rwt->u.d.old;
|
||||
@ -627,6 +641,7 @@ restore_from_write(struct rewind_term *rwt, struct write_globs *wglb)
|
||||
static void
|
||||
write_list(Term t, int direction, int depth, struct write_globs *wglb, struct rewind_term *rwt)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term ti;
|
||||
struct rewind_term nrwt;
|
||||
nrwt.parent = rwt;
|
||||
@ -639,13 +654,13 @@ write_list(Term t, int direction, int depth, struct write_globs *wglb, struct re
|
||||
|
||||
if (wglb->keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
sl = Yap_InitSlot(t);
|
||||
sl = Yap_InitSlot(t PASS_REGS);
|
||||
}
|
||||
writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth+1, FALSE, wglb, &nrwt);
|
||||
restore_from_write(&nrwt, wglb);
|
||||
if (wglb->keep_terms) {
|
||||
t = Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
t = Yap_GetFromSlot(sl PASS_REGS);
|
||||
Yap_RecoverSlots(1 PASS_REGS);
|
||||
}
|
||||
ti = TailOfTerm(t);
|
||||
if (IsVarTerm(ti))
|
||||
@ -704,6 +719,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
||||
/* context priority */
|
||||
|
||||
{
|
||||
CACHE_REGS
|
||||
struct rewind_term nrwt;
|
||||
nrwt.parent = rwt;
|
||||
nrwt.u.s.ptr = 0;
|
||||
@ -730,10 +746,10 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
||||
targs[0] = t;
|
||||
Yap_PutValue(AtomPortray, MkAtomTerm(AtomNil));
|
||||
if (EX) old_EX = EX;
|
||||
sl = Yap_InitSlot(t);
|
||||
sl = Yap_InitSlot(t PASS_REGS);
|
||||
Yap_execute_goal(Yap_MkApplTerm(FunctorPortray, 1, targs), 0, 1);
|
||||
t = Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
t = Yap_GetFromSlot(sl PASS_REGS);
|
||||
Yap_RecoverSlots(1 PASS_REGS);
|
||||
if (old_EX != NULL) EX = old_EX;
|
||||
if (Yap_GetValue(AtomPortray) == MkAtomTerm(AtomTrue))
|
||||
return;
|
||||
@ -821,10 +837,10 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
||||
targs[0] = t;
|
||||
Yap_PutValue(AtomPortray, MkAtomTerm(AtomNil));
|
||||
if (EX) old_EX = EX;
|
||||
sl = Yap_InitSlot(t);
|
||||
sl = Yap_InitSlot(t PASS_REGS);
|
||||
Yap_execute_goal(Yap_MkApplTerm(FunctorPortray, 1, targs),0, 1);
|
||||
t = Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
t = Yap_GetFromSlot(sl PASS_REGS);
|
||||
Yap_RecoverSlots(1 PASS_REGS);
|
||||
if (old_EX) EX = old_EX;
|
||||
if (Yap_GetValue(AtomPortray) == MkAtomTerm(AtomTrue) || EX)
|
||||
return;
|
||||
@ -887,14 +903,14 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
||||
}
|
||||
if (wglb->keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
sl = Yap_InitSlot(t);
|
||||
sl = Yap_InitSlot(t PASS_REGS);
|
||||
}
|
||||
writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), lp, depth + 1, rinfixarg, wglb, &nrwt);
|
||||
restore_from_write(&nrwt, wglb);
|
||||
if (wglb->keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
t = Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
t = Yap_GetFromSlot(sl PASS_REGS);
|
||||
Yap_RecoverSlots(1 PASS_REGS);
|
||||
}
|
||||
if (bracket_left) {
|
||||
wrputc(')', wglb->writewch);
|
||||
@ -931,14 +947,14 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
||||
}
|
||||
if (wglb->keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
sl = Yap_InitSlot(t);
|
||||
sl = Yap_InitSlot(t PASS_REGS);
|
||||
}
|
||||
writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), lp, depth + 1, rinfixarg, wglb, &nrwt);
|
||||
restore_from_write(&nrwt, wglb);
|
||||
if (wglb->keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
t = Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
t = Yap_GetFromSlot(sl PASS_REGS);
|
||||
Yap_RecoverSlots(1 PASS_REGS);
|
||||
}
|
||||
if (bracket_left) {
|
||||
wrputc(')', wglb->writewch);
|
||||
@ -996,14 +1012,14 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
||||
lastw = separator;
|
||||
if (wglb->keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
sl = Yap_InitSlot(t);
|
||||
sl = Yap_InitSlot(t PASS_REGS);
|
||||
}
|
||||
writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||
restore_from_write(&nrwt, wglb);
|
||||
if (wglb->keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
t = Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
t = Yap_GetFromSlot(sl PASS_REGS);
|
||||
Yap_RecoverSlots(1 PASS_REGS);
|
||||
}
|
||||
wrputc(')', wglb->writewch);
|
||||
lastw = separator;
|
||||
@ -1029,14 +1045,14 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
||||
}
|
||||
if (wglb->keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
sl = Yap_InitSlot(t);
|
||||
sl = Yap_InitSlot(t PASS_REGS);
|
||||
}
|
||||
writeTerm(from_pointer(RepAppl(t)+op, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||
restore_from_write(&nrwt, wglb);
|
||||
if (wglb->keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
t = Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
t = Yap_GetFromSlot(sl PASS_REGS);
|
||||
Yap_RecoverSlots(1 PASS_REGS);
|
||||
}
|
||||
if (op != Arity) {
|
||||
wrputc(',', wglb->writewch);
|
||||
@ -1060,14 +1076,14 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
||||
}
|
||||
if (wglb->keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
sl = Yap_InitSlot(t);
|
||||
sl = Yap_InitSlot(t PASS_REGS);
|
||||
}
|
||||
writeTerm(from_pointer(RepAppl(t)+op, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||
restore_from_write(&nrwt, wglb);
|
||||
if (wglb->keep_terms) {
|
||||
/* garbage collection may be called */
|
||||
t = Yap_GetFromSlot(sl);
|
||||
Yap_RecoverSlots(1);
|
||||
t = Yap_GetFromSlot(sl PASS_REGS);
|
||||
Yap_RecoverSlots(1 PASS_REGS);
|
||||
}
|
||||
if (op != Arity) {
|
||||
wrputc(',', wglb->writewch);
|
||||
|
33
H/Regs.h
33
H/Regs.h
@ -78,7 +78,14 @@ EXTERN void save_H(void);
|
||||
EXTERN void restore_B(void);
|
||||
EXTERN void save_B(void);
|
||||
|
||||
typedef struct
|
||||
#define CACHE_REGS
|
||||
#define INIT_REGS
|
||||
#define PASS_REGS1
|
||||
#define PASS_REGS
|
||||
#define USES_REGS1 void
|
||||
#define USES_REGS
|
||||
|
||||
typedef struct regstore_t
|
||||
{
|
||||
Int CurSlot_;
|
||||
CELL CreepFlag_; /* 13 */
|
||||
@ -171,16 +178,19 @@ extern Term Yap_XREGS[MaxTemps]; /* 29 */
|
||||
|
||||
extern pthread_key_t Yap_yaamregs_key;
|
||||
|
||||
#if CACHE_REGS
|
||||
|
||||
#define ENTER_FUNC REGSTORE *regcache = ((REGSTORE *)pthread_getspecific(Yap_yaamregs_key))
|
||||
#define Yap_regp ->((REGSTORE *)pthread_getspecific(Yap_yaamregs_key))
|
||||
|
||||
#else
|
||||
|
||||
#define Yap_regp ((REGSTORE *)pthread_getspecific(Yap_yaamregs_key))
|
||||
|
||||
#endif
|
||||
#undef CACHE_REGS
|
||||
#undef INIT_REGS
|
||||
#undef PASS_REGS
|
||||
#undef PASS_REGS1
|
||||
#undef USES_REGS
|
||||
#undef USES_REGS1
|
||||
#define CACHE_REGS REGSTORE *regcache = ((REGSTORE *)pthread_getspecific(Yap_yaamregs_key));
|
||||
#define INIT_REGS , ((REGSTORE *)pthread_getspecific(Yap_yaamregs_key))
|
||||
#define PASS_REGS1 regcache
|
||||
#define PASS_REGS , regcache
|
||||
#define USES_REGS1 struct regstore_t *regcache
|
||||
#define USES_REGS , struct regstore_t *regcache
|
||||
#define Yap_regp regcache
|
||||
|
||||
#endif
|
||||
|
||||
@ -701,6 +711,7 @@ extern REGSTORE Yap_standard_regs;
|
||||
static inline UInt
|
||||
CalculateStackGap(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
UInt gmin = (LCL0-H0)>>2;
|
||||
|
||||
if (gmin < MinStackGap) gmin = MinStackGap;
|
||||
|
@ -63,6 +63,7 @@ inline EXTERN int IsAttVar (CELL *pt);
|
||||
inline EXTERN int
|
||||
IsAttVar (CELL *pt)
|
||||
{
|
||||
CACHE_REGS
|
||||
return (pt)[-1] == (CELL)attvar_e && pt < H;
|
||||
}
|
||||
|
||||
@ -106,12 +107,12 @@ typedef struct
|
||||
{
|
||||
/* what to do when someone tries to bind our term to someone else
|
||||
in some predefined context */
|
||||
void (*bind_op) (Term *, Term);
|
||||
void (*bind_op) (Term *, Term CACHE_TYPE);
|
||||
/* what to do if someone wants to copy our constraint */
|
||||
int (*copy_term_op) (CELL *, struct cp_frame **, CELL *);
|
||||
int (*copy_term_op) (CELL *, struct cp_frame **, CELL * CACHE_TYPE);
|
||||
/* copy the constraint into a term and back */
|
||||
Term (*to_term_op) (CELL *);
|
||||
int (*term_to_op) (Term, Term);
|
||||
int (*term_to_op) (Term, Term CACHE_TYPE);
|
||||
/* op called to do marking in GC */
|
||||
void (*mark_op) (CELL *);
|
||||
} ext_op;
|
||||
@ -166,6 +167,7 @@ inline EXTERN Term MkFloatTerm (Float);
|
||||
inline EXTERN Term
|
||||
MkFloatTerm (Float dbl)
|
||||
{
|
||||
CACHE_REGS
|
||||
return (Term) ((H[0] = (CELL) FunctorDouble, *(Float *) (H + 1) =
|
||||
dbl, H[2] = EndSpecials, H +=
|
||||
3, AbsAppl (H - 3)));
|
||||
@ -271,6 +273,7 @@ inline EXTERN Term MkLongIntTerm (Int);
|
||||
inline EXTERN Term
|
||||
MkLongIntTerm (Int i)
|
||||
{
|
||||
CACHE_REGS
|
||||
H[0] = (CELL) FunctorLongInt;
|
||||
H[1] = (CELL) (i);
|
||||
H[2] = EndSpecials;
|
||||
|
20
H/Yap.h
20
H/Yap.h
@ -815,6 +815,8 @@ extern char Yap_ErrorSay[MAX_ERROR_MSG_SIZE];
|
||||
extern int Yap_output_msg;
|
||||
#endif
|
||||
|
||||
#define MkVarTerm() MkVarTerm__( PASS_REGS1 )
|
||||
#define MkPairTerm(A,B) MkPairTerm__( A, B PASS_REGS )
|
||||
|
||||
/* applies to unbound variables */
|
||||
|
||||
@ -829,10 +831,10 @@ VarOfTerm (Term t)
|
||||
|
||||
#ifdef SBA
|
||||
|
||||
inline EXTERN Term MkVarTerm (void);
|
||||
inline EXTERN Term MkVarTerm__ ( USES_REGS1 );
|
||||
|
||||
inline EXTERN Term
|
||||
MkVarTerm ()
|
||||
MkVarTerm__ ( USES_REGS1 )
|
||||
{
|
||||
return (Term) ((*H = 0, H++));
|
||||
}
|
||||
@ -850,10 +852,10 @@ IsUnboundVar (Term * t)
|
||||
|
||||
#else
|
||||
|
||||
inline EXTERN Term MkVarTerm (void);
|
||||
inline EXTERN Term MkVarTerm__ ( USES_REGS1 );
|
||||
|
||||
inline EXTERN Term
|
||||
MkVarTerm ()
|
||||
MkVarTerm__ ( USES_REGS1 )
|
||||
{
|
||||
return (Term) ((*H = (CELL) H, H++));
|
||||
}
|
||||
@ -980,10 +982,10 @@ IsIntTerm (Term t)
|
||||
|
||||
|
||||
|
||||
EXTERN inline Term STD_PROTO (MkPairTerm, (Term, Term));
|
||||
EXTERN inline Term STD_PROTO (MkPairTerm__, (Term, Term CACHE_TYPE) );
|
||||
|
||||
EXTERN inline Term
|
||||
MkPairTerm (Term head, Term tail)
|
||||
MkPairTerm__ (Term head, Term tail USES_REGS)
|
||||
{
|
||||
register CELL *p = H;
|
||||
|
||||
@ -1321,14 +1323,14 @@ typedef enum
|
||||
|
||||
|
||||
static inline void
|
||||
Yap_StartSlots(void) {
|
||||
Yap_StartSlots( USES_REGS1 ) {
|
||||
*--ASP = MkIntegerTerm(CurSlot);
|
||||
*--ASP = MkIntTerm(0);
|
||||
CurSlot = LCL0-ASP;
|
||||
}
|
||||
|
||||
static inline void
|
||||
Yap_CloseSlots(void) {
|
||||
Yap_CloseSlots( USES_REGS1 ) {
|
||||
Int old_slots;
|
||||
old_slots = IntOfTerm(ASP[0]);
|
||||
ASP += (old_slots+1);
|
||||
@ -1337,7 +1339,7 @@ Yap_CloseSlots(void) {
|
||||
}
|
||||
|
||||
static inline Int
|
||||
Yap_CurrentSlot(void) {
|
||||
Yap_CurrentSlot( USES_REGS1 ) {
|
||||
return IntOfTerm(ASP[0]);
|
||||
}
|
||||
|
||||
|
@ -236,6 +236,7 @@ ADDR STD_PROTO(Yap_InitPreAllocCodeSpace, (void));
|
||||
EXTERN inline ADDR
|
||||
Yap_PreAllocCodeSpace(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
return AuxBase;
|
||||
}
|
||||
|
||||
|
18
H/Yapproto.h
18
H/Yapproto.h
@ -47,7 +47,7 @@ Term STD_PROTO(Yap_StringToList,(char *));
|
||||
Term STD_PROTO(Yap_NStringToList,(char *, size_t));
|
||||
Term STD_PROTO(Yap_WideStringToList,(wchar_t *));
|
||||
Term STD_PROTO(Yap_NWideStringToList,(wchar_t *, size_t));
|
||||
Term STD_PROTO(Yap_StringToDiffList,(char *,Term));
|
||||
Term STD_PROTO(Yap_StringToDiffList,(char *,Term CACHE_TYPE));
|
||||
Term STD_PROTO(Yap_NStringToDiffList,(char *,Term, size_t));
|
||||
Term STD_PROTO(Yap_WideStringToDiffList,(wchar_t *,Term));
|
||||
Term STD_PROTO(Yap_NWideStringToDiffList,(wchar_t *,Term, size_t));
|
||||
@ -59,13 +59,13 @@ Term STD_PROTO(Yap_NWideStringToDiffListOfAtoms,(wchar_t *, Term, size_t));
|
||||
int STD_PROTO(Yap_AtomIncreaseHold,(Atom));
|
||||
int STD_PROTO(Yap_AtomDecreaseHold,(Atom));
|
||||
|
||||
Int STD_PROTO(Yap_InitSlot,(Term));
|
||||
Int STD_PROTO(Yap_NewSlots,(int));
|
||||
Term STD_PROTO(Yap_GetFromSlot,(Int));
|
||||
int STD_PROTO(Yap_RecoverSlots,(int));
|
||||
Term STD_PROTO(Yap_GetPtrFromSlot,(Int));
|
||||
Term *STD_PROTO(Yap_AddressFromSlot,(Int));
|
||||
void STD_PROTO(Yap_PutInSlot,(Int, Term));
|
||||
Int STD_PROTO(Yap_InitSlot,(Term CACHE_TYPE));
|
||||
Int STD_PROTO(Yap_NewSlots,(int CACHE_TYPE));
|
||||
Term STD_PROTO(Yap_GetFromSlot,(Int CACHE_TYPE));
|
||||
int STD_PROTO(Yap_RecoverSlots,(int CACHE_TYPE));
|
||||
Term STD_PROTO(Yap_GetPtrFromSlot,(Int CACHE_TYPE));
|
||||
Term *STD_PROTO(Yap_AddressFromSlot,(Int CACHE_TYPE));
|
||||
void STD_PROTO(Yap_PutInSlot,(Int, Term CACHE_TYPE));
|
||||
|
||||
|
||||
#ifdef SFUNC
|
||||
@ -82,7 +82,7 @@ Prop STD_PROTO(Yap_GetExpProp,(Atom,unsigned int));
|
||||
Prop STD_PROTO(Yap_GetExpPropHavingLock,(AtomEntry *,unsigned int));
|
||||
|
||||
/* agc.c */
|
||||
void STD_PROTO(Yap_atom_gc, (void));
|
||||
void STD_PROTO(Yap_atom_gc, (CACHE_TYPE1));
|
||||
void STD_PROTO(Yap_init_agc, (void));
|
||||
|
||||
/* alloc.c */
|
||||
|
16
H/Yatom.h
16
H/Yatom.h
@ -487,7 +487,7 @@ typedef enum
|
||||
} op_type;
|
||||
|
||||
|
||||
OpEntry *STD_PROTO(Yap_GetOpProp,(Atom, op_type));
|
||||
OpEntry *STD_PROTO(Yap_GetOpProp,(Atom, op_type CACHE_TYPE));
|
||||
|
||||
int STD_PROTO(Yap_IsPrefixOp,(Atom,int *,int *));
|
||||
int STD_PROTO(Yap_IsOp,(Atom));
|
||||
@ -1482,12 +1482,12 @@ EXTERN inline Prop STD_PROTO(GetPredPropByFuncHavingLock, (FunctorEntry *, Term)
|
||||
|
||||
#ifdef THREADS
|
||||
|
||||
Prop STD_PROTO(Yap_NewThreadPred, (struct pred_entry *));
|
||||
Prop STD_PROTO(Yap_NewThreadPred, (struct pred_entry * CACHE_TYPE));
|
||||
Prop STD_PROTO(Yap_NewPredPropByFunctor, (Functor, Term));
|
||||
EXTERN inline struct pred_entry *STD_PROTO(Yap_GetThreadPred, (struct pred_entry *));
|
||||
EXTERN inline struct pred_entry *STD_PROTO(Yap_GetThreadPred, (struct pred_entry * CACHE_TYPE));
|
||||
|
||||
EXTERN inline struct pred_entry *
|
||||
Yap_GetThreadPred(struct pred_entry *ap)
|
||||
Yap_GetThreadPred(struct pred_entry *ap USES_REGS)
|
||||
{
|
||||
Functor f = ap->FunctorOfPred;
|
||||
Term mod = ap->ModuleOfPred;
|
||||
@ -1499,7 +1499,7 @@ Yap_GetThreadPred(struct pred_entry *ap)
|
||||
ap->ModuleOfPred == mod) return ap;
|
||||
p0 = ap->NextOfPE;
|
||||
}
|
||||
return RepPredProp(Yap_NewThreadPred(ap));
|
||||
return RepPredProp(Yap_NewThreadPred(ap PASS_REGS));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1516,7 +1516,7 @@ GetPredPropByFuncHavingLock (FunctorEntry *fe, Term cur_mod)
|
||||
#ifdef THREADS
|
||||
/* Thread Local Predicates */
|
||||
if (p->PredFlags & ThreadLocalPredFlag) {
|
||||
return AbsPredProp (Yap_GetThreadPred (p));
|
||||
return AbsPredProp (Yap_GetThreadPred (p INIT_REGS));
|
||||
}
|
||||
#endif
|
||||
return AbsPredProp(p);
|
||||
@ -1534,7 +1534,7 @@ GetPredPropByFuncHavingLock (FunctorEntry *fe, Term cur_mod)
|
||||
/* Thread Local Predicates */
|
||||
if (p->PredFlags & ThreadLocalPredFlag) {
|
||||
READ_UNLOCK(PredHashRWLock);
|
||||
return AbsPredProp (Yap_GetThreadPred (p));
|
||||
return AbsPredProp (Yap_GetThreadPred (p INIT_REGS));
|
||||
}
|
||||
#endif
|
||||
READ_UNLOCK(PredHashRWLock);
|
||||
@ -1582,7 +1582,7 @@ PredPropByAtom (Atom at, Term cur_mod)
|
||||
if (pe->PredFlags & ThreadLocalPredFlag)
|
||||
{
|
||||
WRITE_UNLOCK (ae->ARWLock);
|
||||
return AbsPredProp (Yap_GetThreadPred (pe));
|
||||
return AbsPredProp (Yap_GetThreadPred (pe INIT_REGS));
|
||||
}
|
||||
#endif
|
||||
WRITE_UNLOCK (ae->ARWLock);
|
||||
|
@ -181,12 +181,14 @@ register struct yami* P1REG asm ("bp"); /* can't use yamop before Yap.h */
|
||||
inline EXTERN void
|
||||
init_absmi_regs(REGSTORE * absmi_regs)
|
||||
{
|
||||
CACHE_REGS
|
||||
memcpy(absmi_regs, Yap_regp, sizeof(REGSTORE));
|
||||
}
|
||||
|
||||
inline EXTERN void
|
||||
restore_absmi_regs(REGSTORE * old_regs)
|
||||
{
|
||||
CACHE_REGS
|
||||
memcpy(old_regs, Yap_regp, sizeof(REGSTORE));
|
||||
#ifdef THREADS
|
||||
pthread_setspecific(Yap_yaamregs_key, (void *)old_regs);
|
||||
@ -1113,6 +1115,7 @@ typedef struct v_record {
|
||||
static int
|
||||
IUnify_complex(CELL *pt0, CELL *pt0_end, CELL *pt1)
|
||||
{
|
||||
CACHE_REGS
|
||||
#ifdef THREADS
|
||||
#undef Yap_REGS
|
||||
register REGSTORE *regp = Yap_regp;
|
||||
@ -1310,6 +1313,7 @@ iequ_complex(register CELL *pt0, register CELL *pt0_end,
|
||||
register CELL *pt1
|
||||
)
|
||||
{
|
||||
CACHE_REGS
|
||||
#ifdef THREADS
|
||||
#undef Yap_REGS
|
||||
register REGSTORE *regp = Yap_regp;
|
||||
@ -1551,6 +1555,7 @@ Yap_regtoregno(wamreg reg)
|
||||
static inline void
|
||||
prune(choiceptr cp)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (SHOULD_CUT_UP_TO(B,cp))
|
||||
{
|
||||
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
|
||||
@ -1582,6 +1587,7 @@ prune(choiceptr cp)
|
||||
|
||||
static inline
|
||||
void SET_ASP(CELL *yreg, Int sz) {
|
||||
CACHE_REGS
|
||||
ASP = (CELL *) (((char *) yreg) + sz);
|
||||
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
|
||||
ASP = (CELL *)PROTECT_FROZEN_B(B);
|
||||
|
15
H/amidefs.h
15
H/amidefs.h
@ -103,8 +103,21 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if THREADS
|
||||
|
||||
typedef Int (*CPredicate)(void);
|
||||
typedef struct regstore_t *regstruct_ptr;
|
||||
|
||||
#define CACHE_TYPE1 regstruct_ptr
|
||||
#define CACHE_TYPE , regstruct_ptr
|
||||
|
||||
#else
|
||||
|
||||
#define CACHE_TYPE
|
||||
#define CACHE_TYPE1 void
|
||||
|
||||
#endif
|
||||
|
||||
typedef Int (*CPredicate)(CACHE_TYPE1);
|
||||
|
||||
typedef Int (*CmpPredicate)(Term, Term);
|
||||
|
||||
|
@ -409,6 +409,7 @@ inline EXTERN void STD_PROTO(reset_trail,(tr_fr_ptr));
|
||||
|
||||
inline EXTERN void
|
||||
reset_trail(tr_fr_ptr TR0) {
|
||||
CACHE_REGS
|
||||
while(TR != TR0) {
|
||||
CELL d1;
|
||||
--TR;
|
||||
@ -458,6 +459,7 @@ inline EXTERN void close_attvar_chain(CELL *dvarsmin, CELL *dvarsmax);
|
||||
|
||||
inline EXTERN void
|
||||
close_attvar_chain(CELL *dvarsmin, CELL *dvarsmax) {
|
||||
CACHE_REGS
|
||||
if (dvarsmin) {
|
||||
dvarsmin += 1;
|
||||
do {
|
||||
@ -475,6 +477,7 @@ close_attvar_chain(CELL *dvarsmin, CELL *dvarsmax) {
|
||||
EXTERN inline
|
||||
Int Yap_unify(Term t0, Term t1)
|
||||
{
|
||||
CACHE_REGS
|
||||
tr_fr_ptr TR0 = TR;
|
||||
|
||||
if (Yap_IUnify(t0,t1)) {
|
||||
@ -490,6 +493,7 @@ EXTERN Int STD_PROTO(Yap_unify_constant,(Term,Term));
|
||||
EXTERN inline Int
|
||||
Yap_unify_constant(register Term a, register Term cons)
|
||||
{
|
||||
CACHE_REGS
|
||||
CELL *pt;
|
||||
deref_head(a,unify_cons_unk);
|
||||
unify_cons_nonvar:
|
||||
@ -547,6 +551,7 @@ Yap_unify_constant(register Term a, register Term cons)
|
||||
|
||||
static inline int
|
||||
do_cut(int i) {
|
||||
CACHE_REGS
|
||||
#ifdef CUT_C
|
||||
if (POP_CHOICE_POINT(B->cp_b)) {
|
||||
cut_c_pop();
|
||||
|
@ -39,9 +39,9 @@ struct cut_c_str{
|
||||
cut_c_str_ptr TOP = Yap_REGS.CUT_C_TOP; \
|
||||
CPredicate func = (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.f; \
|
||||
PredEntry *pred = (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.p; \
|
||||
Yap_StartSlots(); \
|
||||
Yap_StartSlots( PASS_REGS1 ); \
|
||||
YAP_ExecuteOnCut(pred,func); \
|
||||
Yap_CloseSlots(); \
|
||||
Yap_CloseSlots( PASS_REGS1 ); \
|
||||
cut_c_pop();
|
||||
|
||||
|
||||
|
3
H/eval.h
3
H/eval.h
@ -188,7 +188,8 @@ Yap_Eval(Term t)
|
||||
|
||||
inline static Term
|
||||
Yap_FoundArithError(Term t, Term inp)
|
||||
{
|
||||
{
|
||||
CACHE_REGS
|
||||
if (Yap_Error_TYPE) {
|
||||
Yap_Error(Yap_Error_TYPE, (inp ? inp : Yap_Error_Term), Yap_ErrorMessage);
|
||||
P = FAILCODE;
|
||||
|
22
H/heapgc.h
22
H/heapgc.h
@ -86,14 +86,22 @@ extern char *Yap_bp;
|
||||
|
||||
#define mcell(X) Yap_bp[(X)-(CELL *)Yap_GlobalBase]
|
||||
|
||||
#define MARKED_PTR(P) MARKED_PTR__(P PASS_REGS)
|
||||
#define UNMARKED_MARK(P, BP) UNMARKED_MARK__(P, BP PASS_REGS)
|
||||
#define MARK(P) MARK__(P PASS_REGS)
|
||||
#define UNMARK(P) UNMARK__(P PASS_REGS)
|
||||
#define RMARK(P) RMARK__(P PASS_REGS)
|
||||
#define RMARKED(P) RMARKED__(P PASS_REGS)
|
||||
#define UNRMARK(P) UNRMARK__(P PASS_REGS)
|
||||
|
||||
static inline Int
|
||||
MARKED_PTR(CELL* ptr)
|
||||
MARKED_PTR__(CELL* ptr USES_REGS)
|
||||
{
|
||||
return mcell(ptr) & MARK_BIT;
|
||||
}
|
||||
|
||||
static inline Int
|
||||
UNMARKED_MARK(CELL* ptr, char *bp)
|
||||
UNMARKED_MARK__(CELL* ptr, char *bp USES_REGS)
|
||||
{
|
||||
Int pos = ptr - (CELL *)Yap_GlobalBase;
|
||||
char t = bp[pos];
|
||||
@ -105,13 +113,13 @@ UNMARKED_MARK(CELL* ptr, char *bp)
|
||||
}
|
||||
|
||||
static inline void
|
||||
MARK(CELL* ptr)
|
||||
MARK__(CELL* ptr USES_REGS)
|
||||
{
|
||||
mcell(ptr) = mcell(ptr) | MARK_BIT;
|
||||
}
|
||||
|
||||
static inline void
|
||||
UNMARK(CELL* ptr)
|
||||
UNMARK__(CELL* ptr USES_REGS)
|
||||
{
|
||||
mcell(ptr) = mcell(ptr) & ~MARK_BIT;
|
||||
}
|
||||
@ -122,19 +130,19 @@ UNMARK(CELL* ptr)
|
||||
#define UNMARK_CELL(X) (X)
|
||||
|
||||
static inline void
|
||||
RMARK(CELL* ptr)
|
||||
RMARK__(CELL* ptr USES_REGS)
|
||||
{
|
||||
mcell(ptr) = mcell(ptr) | RMARK_BIT;
|
||||
}
|
||||
|
||||
static inline void
|
||||
UNRMARK(CELL* ptr)
|
||||
UNRMARK__(CELL* ptr USES_REGS)
|
||||
{
|
||||
mcell(ptr) = mcell(ptr) & ~RMARK_BIT;
|
||||
}
|
||||
|
||||
static inline int
|
||||
RMARKED(CELL* ptr)
|
||||
RMARKED__(CELL* ptr USES_REGS)
|
||||
{
|
||||
return mcell(ptr) & RMARK_BIT;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
|
||||
static void
|
||||
restore_opcodes(yamop *pc, yamop *max)
|
||||
restore_opcodes(yamop *pc, yamop *max USES_REGS)
|
||||
{
|
||||
yamop *opc = NULL;
|
||||
do {
|
||||
|
@ -20,8 +20,7 @@
|
||||
|
||||
|
||||
|
||||
static void RestoreWorker(int wid) {
|
||||
|
||||
static void RestoreWorker(int wid USES_REGS) {
|
||||
|
||||
|
||||
|
||||
|
210
H/rheap.h
210
H/rheap.h
@ -239,8 +239,16 @@ static char SccsId[] = "@(#)rheap.c 1.3 3/15/90";
|
||||
#define Atomics 0
|
||||
#define Funcs 1
|
||||
|
||||
#define ConstantTermAdjust(P) ConstantTermAdjust__(P PASS_REGS)
|
||||
#define DBGroundTermAdjust(P) DBGroundTermAdjust__(P PASS_REGS)
|
||||
#define AdjustDBTerm(P,A) AdjustDBTerm__(P,A PASS_REGS)
|
||||
#define AdjustSwitchTable(op, table, i) AdjustSwitchTable__(op, table, i PASS_REGS)
|
||||
#define RestoreOtaplInst(start, opc, pe) RestoreOtaplInst__(start, opc, pe PASS_REGS)
|
||||
#define RestoreDBErasedMarker() RestoreDBErasedMarker__( PASS_REGS1 )
|
||||
#define RestoreLogDBErasedMarker() RestoreLogDBErasedMarker__( PASS_REGS1 )
|
||||
#define RestoreForeignCode() RestoreForeignCode__( PASS_REGS1 )
|
||||
static Term
|
||||
ConstantTermAdjust (Term t)
|
||||
ConstantTermAdjust__ (Term t USES_REGS)
|
||||
{
|
||||
if (IsAtomTerm(t))
|
||||
return AtomTermAdjust(t);
|
||||
@ -248,7 +256,7 @@ ConstantTermAdjust (Term t)
|
||||
}
|
||||
|
||||
static Term
|
||||
DBGroundTermAdjust (Term t)
|
||||
DBGroundTermAdjust__ (Term t USES_REGS)
|
||||
{
|
||||
/* The term itself is restored by dbtermlist */
|
||||
if (IsPairTerm(t)) {
|
||||
@ -261,7 +269,7 @@ DBGroundTermAdjust (Term t)
|
||||
/* Now, everything on its place so you must adjust the pointers */
|
||||
|
||||
static void
|
||||
do_clean_susp_clauses(yamop *ipc) {
|
||||
do_clean_susp_clauses(yamop *ipc USES_REGS) {
|
||||
COUNT i;
|
||||
yamop **st = (yamop **)NEXTOP(ipc,sssllp);
|
||||
|
||||
@ -281,7 +289,7 @@ do_clean_susp_clauses(yamop *ipc) {
|
||||
}
|
||||
|
||||
static void
|
||||
AdjustSwitchTable(op_numbers op, yamop *table, COUNT i)
|
||||
AdjustSwitchTable__(op_numbers op, yamop *table, COUNT i USES_REGS)
|
||||
{
|
||||
CELL *startcode = (CELL *)table;
|
||||
/* in case the table is already gone */
|
||||
@ -303,7 +311,7 @@ AdjustSwitchTable(op_numbers op, yamop *table, COUNT i)
|
||||
oldcode[1] = (CELL)CodeAddrAdjust(oldjmp);
|
||||
oldcode += 2;
|
||||
}
|
||||
rehash(startcode, i, Funcs);
|
||||
rehash(startcode, i, Funcs PASS_REGS);
|
||||
}
|
||||
break;
|
||||
case _switch_on_cons:
|
||||
@ -324,7 +332,7 @@ AdjustSwitchTable(op_numbers op, yamop *table, COUNT i)
|
||||
oldcode += 2;
|
||||
}
|
||||
#if !USE_OFFSETS
|
||||
rehash(startcode, i, Atomics);
|
||||
rehash(startcode, i, Atomics PASS_REGS);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
@ -385,12 +393,12 @@ AdjustSwitchTable(op_numbers op, yamop *table, COUNT i)
|
||||
}
|
||||
}
|
||||
|
||||
STATIC_PROTO(void RestoreAtomList, (Atom));
|
||||
STATIC_PROTO(void RestoreAtom, (AtomEntry *));
|
||||
STATIC_PROTO(void RestoreHashPreds, (void));
|
||||
STATIC_PROTO(void RestoreAtomList, (Atom CACHE_TYPE));
|
||||
STATIC_PROTO(void RestoreAtom, (AtomEntry * CACHE_TYPE));
|
||||
STATIC_PROTO(void RestoreHashPreds, ( CACHE_TYPE1 ));
|
||||
|
||||
static void
|
||||
RestoreAtoms(void)
|
||||
RestoreAtoms( USES_REGS1 )
|
||||
{
|
||||
AtomHashEntry *HashPtr;
|
||||
register int i;
|
||||
@ -400,13 +408,13 @@ RestoreAtoms(void)
|
||||
HashPtr = HashChain;
|
||||
for (i = 0; i < AtomHashTableSize; ++i) {
|
||||
HashPtr->Entry = NoAGCAtomAdjust(HashPtr->Entry);
|
||||
RestoreAtomList(HashPtr->Entry);
|
||||
RestoreAtomList(HashPtr->Entry PASS_REGS);
|
||||
HashPtr++;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreWideAtoms(void)
|
||||
RestoreWideAtoms( USES_REGS1 )
|
||||
{
|
||||
AtomHashEntry *HashPtr;
|
||||
register int i;
|
||||
@ -416,25 +424,25 @@ RestoreWideAtoms(void)
|
||||
HashPtr = WideHashChain;
|
||||
for (i = 0; i < WideAtomHashTableSize; ++i) {
|
||||
HashPtr->Entry = AtomAdjust(HashPtr->Entry);
|
||||
RestoreAtomList(HashPtr->Entry);
|
||||
RestoreAtomList(HashPtr->Entry PASS_REGS);
|
||||
HashPtr++;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreInvisibleAtoms(void)
|
||||
RestoreInvisibleAtoms( USES_REGS1 )
|
||||
{
|
||||
INVISIBLECHAIN.Entry = AtomAdjust(INVISIBLECHAIN.Entry);
|
||||
RestoreAtomList(INVISIBLECHAIN.Entry);
|
||||
RestoreAtom(RepAtom(AtomFoundVar));
|
||||
RestoreAtom(RepAtom(AtomFreeTerm));
|
||||
RestoreAtomList(INVISIBLECHAIN.Entry PASS_REGS);
|
||||
RestoreAtom(RepAtom(AtomFoundVar) PASS_REGS);
|
||||
RestoreAtom(RepAtom(AtomFreeTerm) PASS_REGS);
|
||||
}
|
||||
|
||||
#include "rclause.h"
|
||||
|
||||
/* adjusts terms stored in the data base, when they have no variables */
|
||||
static Term
|
||||
AdjustDBTerm(Term trm, Term *p_base)
|
||||
AdjustDBTerm__(Term trm, Term *p_base USES_REGS)
|
||||
{
|
||||
if (IsVarTerm(trm))
|
||||
return CodeVarAdjust(trm);
|
||||
@ -488,7 +496,7 @@ AdjustDBTerm(Term trm, Term *p_base)
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreDBTerm(DBTerm *dbr, int attachments)
|
||||
RestoreDBTerm(DBTerm *dbr, int attachments USES_REGS)
|
||||
{
|
||||
if (attachments) {
|
||||
#ifdef COROUTINING
|
||||
@ -515,7 +523,7 @@ RestoreDBTerm(DBTerm *dbr, int attachments)
|
||||
|
||||
/* Restores a prolog clause, in its compiled form */
|
||||
static void
|
||||
RestoreStaticClause(StaticClause *cl)
|
||||
RestoreStaticClause(StaticClause *cl USES_REGS)
|
||||
/*
|
||||
* Cl points to the start of the code, IsolFlag tells if we have a single
|
||||
* clause for this predicate or not
|
||||
@ -529,12 +537,12 @@ RestoreStaticClause(StaticClause *cl)
|
||||
if (cl->ClNext) {
|
||||
cl->ClNext = PtoStCAdjust(cl->ClNext);
|
||||
}
|
||||
restore_opcodes(cl->ClCode, NULL);
|
||||
restore_opcodes(cl->ClCode, NULL PASS_REGS);
|
||||
}
|
||||
|
||||
/* Restores a prolog clause, in its compiled form */
|
||||
static void
|
||||
RestoreMegaClause(MegaClause *cl)
|
||||
RestoreMegaClause(MegaClause *cl USES_REGS)
|
||||
/*
|
||||
* Cl points to the start of the code, IsolFlag tells if we have a single
|
||||
* clause for this predicate or not
|
||||
@ -551,14 +559,14 @@ RestoreMegaClause(MegaClause *cl)
|
||||
|
||||
for (i = 0, ptr = cl->ClCode; i < ncls; i++) {
|
||||
yamop *nextptr = (yamop *)((char *)ptr + cl->ClItemSize);
|
||||
restore_opcodes(ptr, nextptr);
|
||||
restore_opcodes(ptr, nextptr PASS_REGS);
|
||||
ptr = nextptr;
|
||||
}
|
||||
}
|
||||
|
||||
/* Restores a prolog clause, in its compiled form */
|
||||
static void
|
||||
RestoreDynamicClause(DynamicClause *cl, PredEntry *pp)
|
||||
RestoreDynamicClause(DynamicClause *cl, PredEntry *pp USES_REGS)
|
||||
/*
|
||||
* Cl points to the start of the code, IsolFlag tells if we have a single
|
||||
* clause for this predicate or not
|
||||
@ -568,12 +576,12 @@ RestoreDynamicClause(DynamicClause *cl, PredEntry *pp)
|
||||
cl->ClPrevious = PtoOpAdjust(cl->ClPrevious);
|
||||
}
|
||||
INIT_LOCK(cl->ClLock);
|
||||
restore_opcodes(cl->ClCode, NULL);
|
||||
restore_opcodes(cl->ClCode, NULL PASS_REGS);
|
||||
}
|
||||
|
||||
/* Restores a prolog clause, in its compiled form */
|
||||
static void
|
||||
RestoreLUClause(LogUpdClause *cl, PredEntry *pp)
|
||||
RestoreLUClause(LogUpdClause *cl, PredEntry *pp USES_REGS)
|
||||
/*
|
||||
* Cl points to the start of the code, IsolFlag tells if we have a single
|
||||
* clause for this predicate or not
|
||||
@ -585,7 +593,7 @@ RestoreLUClause(LogUpdClause *cl, PredEntry *pp)
|
||||
}
|
||||
if (cl->ClSource) {
|
||||
cl->ClSource = DBTermAdjust(cl->ClSource);
|
||||
RestoreDBTerm(cl->ClSource, TRUE);
|
||||
RestoreDBTerm(cl->ClSource, TRUE PASS_REGS);
|
||||
}
|
||||
if (cl->ClPrev) {
|
||||
cl->ClPrev = PtoLUCAdjust(cl->ClPrev);
|
||||
@ -594,11 +602,11 @@ RestoreLUClause(LogUpdClause *cl, PredEntry *pp)
|
||||
cl->ClNext = PtoLUCAdjust(cl->ClNext);
|
||||
}
|
||||
cl->ClPred = PtoPredAdjust(cl->ClPred);
|
||||
restore_opcodes(cl->ClCode, NULL);
|
||||
restore_opcodes(cl->ClCode, NULL PASS_REGS);
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreDBTermEntry(struct dbterm_list *dbl) {
|
||||
RestoreDBTermEntry(struct dbterm_list *dbl USES_REGS) {
|
||||
DBTerm *dbt;
|
||||
|
||||
if (dbl->dbterms)
|
||||
@ -610,13 +618,13 @@ RestoreDBTermEntry(struct dbterm_list *dbl) {
|
||||
dbl->next_dbl = PtoDBTLAdjust(dbl->next_dbl);
|
||||
dbl->p = PredEntryAdjust(dbl->p);
|
||||
while (dbt) {
|
||||
RestoreDBTerm(dbt, FALSE);
|
||||
RestoreDBTerm(dbt, FALSE PASS_REGS);
|
||||
dbt = dbt->ag.NextDBT;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
CleanLUIndex(LogUpdIndex *idx, int recurse)
|
||||
CleanLUIndex(LogUpdIndex *idx, int recurse USES_REGS)
|
||||
{
|
||||
// INIT_LOCK(idx->ClLock);
|
||||
idx->ClPred = PtoPredAdjust(idx->ClPred);
|
||||
@ -628,30 +636,30 @@ CleanLUIndex(LogUpdIndex *idx, int recurse)
|
||||
if (idx->SiblingIndex) {
|
||||
idx->SiblingIndex = LUIndexAdjust(idx->SiblingIndex);
|
||||
if (recurse)
|
||||
CleanLUIndex(idx->SiblingIndex, TRUE);
|
||||
CleanLUIndex(idx->SiblingIndex, TRUE PASS_REGS);
|
||||
}
|
||||
if (idx->ChildIndex) {
|
||||
idx->ChildIndex = LUIndexAdjust(idx->ChildIndex);
|
||||
if (recurse)
|
||||
CleanLUIndex(idx->ChildIndex, TRUE);
|
||||
CleanLUIndex(idx->ChildIndex, TRUE PASS_REGS);
|
||||
}
|
||||
if (!(idx->ClFlags & SwitchTableMask)) {
|
||||
restore_opcodes(idx->ClCode, NULL);
|
||||
restore_opcodes(idx->ClCode, NULL PASS_REGS);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
CleanSIndex(StaticIndex *idx, int recurse)
|
||||
CleanSIndex(StaticIndex *idx, int recurse USES_REGS)
|
||||
{
|
||||
beginning:
|
||||
if (!(idx->ClFlags & SwitchTableMask)) {
|
||||
restore_opcodes(idx->ClCode, NULL);
|
||||
restore_opcodes(idx->ClCode, NULL PASS_REGS);
|
||||
}
|
||||
idx->ClPred = PtoPredAdjust(idx->ClPred);
|
||||
if (idx->ChildIndex) {
|
||||
idx->ChildIndex = SIndexAdjust(idx->ChildIndex);
|
||||
if (recurse)
|
||||
CleanSIndex(idx->ChildIndex, TRUE);
|
||||
CleanSIndex(idx->ChildIndex, TRUE PASS_REGS);
|
||||
}
|
||||
if (idx->SiblingIndex) {
|
||||
idx->SiblingIndex = SIndexAdjust(idx->SiblingIndex);
|
||||
@ -664,7 +672,7 @@ CleanSIndex(StaticIndex *idx, int recurse)
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreSWIAtoms(void)
|
||||
RestoreSWIAtoms( USES_REGS1 )
|
||||
{
|
||||
int i, j;
|
||||
for (i=0; i < N_SWI_ATOMS; i++) {
|
||||
@ -687,14 +695,14 @@ RestoreSWIBlobs(void)
|
||||
}
|
||||
|
||||
static void
|
||||
RestorePredHash(void)
|
||||
RestorePredHash( USES_REGS1 )
|
||||
{
|
||||
PredHash = PtoPtoPredAdjust(PredHash);
|
||||
if (PredHash == NULL) {
|
||||
Yap_Error(FATAL_ERROR,MkIntTerm(0),"restore should find predicate hash table");
|
||||
}
|
||||
REINIT_RWLOCK(PredHashRWLock);
|
||||
RestoreHashPreds(); /* does most of the work */
|
||||
RestoreHashPreds( PASS_REGS1 ); /* does most of the work */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -711,7 +719,7 @@ RestoreEnvInst(yamop start[2], yamop **instp, op_numbers opc, PredEntry *pred)
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreOtaplInst(yamop start[1], OPCODE opc, PredEntry *pe)
|
||||
RestoreOtaplInst__(yamop start[1], OPCODE opc, PredEntry *pe USES_REGS)
|
||||
{
|
||||
yamop *ipc = start;
|
||||
|
||||
@ -730,20 +738,20 @@ RestoreOtaplInst(yamop start[1], OPCODE opc, PredEntry *pe)
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreDBTermsList(void)
|
||||
RestoreDBTermsList( USES_REGS1 )
|
||||
{
|
||||
if (Yap_heap_regs->dbterms_list) {
|
||||
struct dbterm_list *dbl = PtoDBTLAdjust(Yap_heap_regs->dbterms_list);
|
||||
Yap_heap_regs->dbterms_list = dbl;
|
||||
while (dbl) {
|
||||
RestoreDBTermEntry(dbl);
|
||||
RestoreDBTermEntry(dbl PASS_REGS);
|
||||
dbl = dbl->next_dbl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreExpandList(void)
|
||||
RestoreExpandList( USES_REGS1 )
|
||||
{
|
||||
if (Yap_heap_regs->expand_clauses_first)
|
||||
Yap_heap_regs->expand_clauses_first = PtoOpAdjust(Yap_heap_regs->expand_clauses_first);
|
||||
@ -752,7 +760,7 @@ RestoreExpandList(void)
|
||||
{
|
||||
yamop *ptr = Yap_heap_regs->expand_clauses_first;
|
||||
while (ptr) {
|
||||
do_clean_susp_clauses(ptr);
|
||||
do_clean_susp_clauses(ptr PASS_REGS);
|
||||
ptr = ptr->u.sssllp.snext;
|
||||
}
|
||||
}
|
||||
@ -768,7 +776,7 @@ RestoreUdiControlBlocks(void)
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreIntKeys(void)
|
||||
RestoreIntKeys( USES_REGS1 )
|
||||
{
|
||||
if (Yap_heap_regs->IntKeys != NULL) {
|
||||
Yap_heap_regs->IntKeys = (Prop *)AddrAdjust((ADDR)(Yap_heap_regs->IntKeys));
|
||||
@ -777,7 +785,7 @@ RestoreIntKeys(void)
|
||||
for (i = 0; i < Yap_heap_regs->int_keys_size; i++) {
|
||||
if (Yap_heap_regs->IntKeys[i] != NIL) {
|
||||
Prop p0 = Yap_heap_regs->IntKeys[i] = PropAdjust(Yap_heap_regs->IntKeys[i]);
|
||||
RestoreEntries(RepProp(p0), TRUE);
|
||||
RestoreEntries(RepProp(p0), TRUE PASS_REGS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -785,7 +793,7 @@ RestoreIntKeys(void)
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreIntLUKeys(void)
|
||||
RestoreIntLUKeys( USES_REGS1 )
|
||||
{
|
||||
if (Yap_heap_regs->IntLUKeys != NULL) {
|
||||
Yap_heap_regs->IntLUKeys = (Prop *)AddrAdjust((ADDR)(Yap_heap_regs->IntLUKeys));
|
||||
@ -800,7 +808,7 @@ RestoreIntLUKeys(void)
|
||||
PredEntry *pe = RepPredProp(p0);
|
||||
pe->NextOfPE =
|
||||
PropAdjust(pe->NextOfPE);
|
||||
CleanCode(pe);
|
||||
CleanCode(pe PASS_REGS);
|
||||
p0 = RepProp(pe->NextOfPE);
|
||||
}
|
||||
}
|
||||
@ -810,7 +818,7 @@ RestoreIntLUKeys(void)
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreIntBBKeys(void)
|
||||
RestoreIntBBKeys( USES_REGS1 )
|
||||
{
|
||||
if (Yap_heap_regs->IntBBKeys != NULL) {
|
||||
Yap_heap_regs->IntBBKeys = (Prop *)AddrAdjust((ADDR)(Yap_heap_regs->IntBBKeys));
|
||||
@ -819,7 +827,7 @@ RestoreIntBBKeys(void)
|
||||
for (i = 0; i < Yap_heap_regs->int_bb_keys_size; i++) {
|
||||
if (Yap_heap_regs->IntBBKeys[i] != NIL) {
|
||||
Prop p0 = Yap_heap_regs->IntBBKeys[i] = PropAdjust(Yap_heap_regs->IntBBKeys[i]);
|
||||
RestoreEntries(RepProp(p0), TRUE);
|
||||
RestoreEntries(RepProp(p0), TRUE PASS_REGS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -827,7 +835,7 @@ RestoreIntBBKeys(void)
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreDBErasedMarker(void)
|
||||
RestoreDBErasedMarker__( USES_REGS1 )
|
||||
{
|
||||
Yap_heap_regs->db_erased_marker =
|
||||
DBRefAdjust(Yap_heap_regs->db_erased_marker);
|
||||
@ -839,7 +847,7 @@ RestoreDBErasedMarker(void)
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreLogDBErasedMarker(void)
|
||||
RestoreLogDBErasedMarker__( USES_REGS1 )
|
||||
{
|
||||
Yap_heap_regs->logdb_erased_marker =
|
||||
PtoLUCAdjust(Yap_heap_regs->logdb_erased_marker);
|
||||
@ -857,65 +865,65 @@ RestoreLogDBErasedMarker(void)
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreDeadStaticClauses(void)
|
||||
RestoreDeadStaticClauses( USES_REGS1 )
|
||||
{
|
||||
if (Yap_heap_regs->dead_static_clauses) {
|
||||
StaticClause *sc = PtoStCAdjust(Yap_heap_regs->dead_static_clauses);
|
||||
Yap_heap_regs->dead_static_clauses = sc;
|
||||
while (sc) {
|
||||
RestoreStaticClause(sc);
|
||||
RestoreStaticClause(sc PASS_REGS);
|
||||
sc = sc->ClNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreDeadMegaClauses(void)
|
||||
RestoreDeadMegaClauses( USES_REGS1 )
|
||||
{
|
||||
if (Yap_heap_regs->dead_mega_clauses) {
|
||||
MegaClause *mc = (MegaClause *)AddrAdjust((ADDR)(Yap_heap_regs->dead_mega_clauses));
|
||||
Yap_heap_regs->dead_mega_clauses = mc;
|
||||
while (mc) {
|
||||
RestoreMegaClause(mc);
|
||||
RestoreMegaClause(mc PASS_REGS);
|
||||
mc = mc->ClNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreDeadStaticIndices(void)
|
||||
RestoreDeadStaticIndices( USES_REGS1 )
|
||||
{
|
||||
if (Yap_heap_regs->dead_static_indices) {
|
||||
StaticIndex *si = (StaticIndex *)AddrAdjust((ADDR)(Yap_heap_regs->dead_static_indices));
|
||||
Yap_heap_regs->dead_static_indices = si;
|
||||
while (si) {
|
||||
CleanSIndex(si, FALSE);
|
||||
CleanSIndex(si, FALSE PASS_REGS);
|
||||
si = si->SiblingIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreDBErasedList(void)
|
||||
RestoreDBErasedList( USES_REGS1 )
|
||||
{
|
||||
if (Yap_heap_regs->db_erased_list) {
|
||||
LogUpdClause *lcl = Yap_heap_regs->db_erased_list =
|
||||
PtoLUCAdjust(Yap_heap_regs->db_erased_list);
|
||||
while (lcl) {
|
||||
RestoreLUClause(lcl, FALSE);
|
||||
RestoreLUClause(lcl, FALSE PASS_REGS);
|
||||
lcl = lcl->ClNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreDBErasedIList(void)
|
||||
RestoreDBErasedIList( USES_REGS1 )
|
||||
{
|
||||
if (Yap_heap_regs->db_erased_ilist) {
|
||||
LogUpdIndex *icl = Yap_heap_regs->db_erased_ilist =
|
||||
LUIndexAdjust(Yap_heap_regs->db_erased_ilist);
|
||||
while (icl) {
|
||||
CleanLUIndex(icl, FALSE);
|
||||
CleanLUIndex(icl, FALSE PASS_REGS);
|
||||
icl = icl->SiblingIndex;
|
||||
}
|
||||
}
|
||||
@ -929,18 +937,10 @@ RestoreStreams(void)
|
||||
static void
|
||||
RestoreAliases(void)
|
||||
{
|
||||
if (Yap_heap_regs->file_aliases != NULL) {
|
||||
int i;
|
||||
|
||||
Yap_heap_regs->file_aliases =
|
||||
(struct AliasDescS *)AddrAdjust((ADDR)Yap_heap_regs->file_aliases);
|
||||
for (i = 0; i < NOfFileAliases; i++)
|
||||
FileAliases[i].name = AtomAdjust(FileAliases[i].name);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreForeignCode(void)
|
||||
RestoreForeignCode__( USES_REGS1 )
|
||||
{
|
||||
ForeignObj *f_code;
|
||||
|
||||
@ -978,7 +978,7 @@ RestoreForeignCode(void)
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreYapRecords(void)
|
||||
RestoreYapRecords( USES_REGS1 )
|
||||
{
|
||||
struct record_list *ptr;
|
||||
|
||||
@ -988,16 +988,17 @@ RestoreYapRecords(void)
|
||||
ptr->next_rec = DBRecordAdjust(ptr->next_rec);
|
||||
ptr->prev_rec = DBRecordAdjust(ptr->prev_rec);
|
||||
ptr->dbrecord = DBTermAdjust(ptr->dbrecord);
|
||||
RestoreDBTerm(ptr->dbrecord, FALSE);
|
||||
RestoreDBTerm(ptr->dbrecord, FALSE PASS_REGS);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreBallTerm(int wid)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (BallTerm) {
|
||||
BallTerm = DBTermAdjust(BallTerm);
|
||||
RestoreDBTerm(BallTerm, TRUE);
|
||||
RestoreDBTerm(BallTerm, TRUE PASS_REGS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1007,18 +1008,19 @@ RestoreBallTerm(int wid)
|
||||
static void
|
||||
restore_codes(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
Yap_heap_regs->heap_top = AddrAdjust(OldHeapTop);
|
||||
#include "rhstruct.h"
|
||||
RestoreGlobal();
|
||||
#ifndef worker_id
|
||||
#define worker_id 0
|
||||
#endif
|
||||
RestoreWorker(worker_id);
|
||||
RestoreWorker(worker_id PASS_REGS);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
RestoreDBEntry(DBRef dbr)
|
||||
RestoreDBEntry(DBRef dbr USES_REGS)
|
||||
{
|
||||
#ifdef DEBUG_RESTORE
|
||||
fprintf(stderr, "Restoring at %x", dbr);
|
||||
@ -1033,7 +1035,7 @@ RestoreDBEntry(DBRef dbr)
|
||||
else
|
||||
fprintf(stderr, " a var\n");
|
||||
#endif
|
||||
RestoreDBTerm(&(dbr->DBT), TRUE);
|
||||
RestoreDBTerm(&(dbr->DBT), TRUE PASS_REGS);
|
||||
if (dbr->Parent) {
|
||||
dbr->Parent = (DBProp)AddrAdjust((ADDR)(dbr->Parent));
|
||||
}
|
||||
@ -1051,7 +1053,7 @@ RestoreDBEntry(DBRef dbr)
|
||||
|
||||
/* Restores a DB structure, as it was saved in the heap */
|
||||
static void
|
||||
RestoreDB(DBEntry *pp)
|
||||
RestoreDB(DBEntry *pp USES_REGS)
|
||||
{
|
||||
register DBRef dbr;
|
||||
|
||||
@ -1071,7 +1073,7 @@ RestoreDB(DBEntry *pp)
|
||||
dbr = pp->F0;
|
||||
/* While we have something in the data base, even if erased, restore it */
|
||||
while (dbr) {
|
||||
RestoreDBEntry(dbr);
|
||||
RestoreDBEntry(dbr PASS_REGS);
|
||||
if (dbr->n != NULL)
|
||||
dbr->n = DBRefAdjust(dbr->n);
|
||||
if (dbr->p != NULL)
|
||||
@ -1085,24 +1087,24 @@ RestoreDB(DBEntry *pp)
|
||||
* and ending with Last, First may be equal to Last
|
||||
*/
|
||||
static void
|
||||
CleanClauses(yamop *First, yamop *Last, PredEntry *pp)
|
||||
CleanClauses(yamop *First, yamop *Last, PredEntry *pp USES_REGS)
|
||||
{
|
||||
if (pp->PredFlags & LogUpdatePredFlag) {
|
||||
LogUpdClause *cl = ClauseCodeToLogUpdClause(First);
|
||||
|
||||
while (cl != NULL) {
|
||||
RestoreLUClause(cl, pp);
|
||||
RestoreLUClause(cl, pp PASS_REGS);
|
||||
cl = cl->ClNext;
|
||||
}
|
||||
} else if (pp->PredFlags & MegaClausePredFlag) {
|
||||
MegaClause *cl = ClauseCodeToMegaClause(First);
|
||||
|
||||
RestoreMegaClause(cl);
|
||||
RestoreMegaClause(cl PASS_REGS);
|
||||
} else if (pp->PredFlags & DynamicPredFlag) {
|
||||
yamop *cl = First;
|
||||
|
||||
do {
|
||||
RestoreDynamicClause(ClauseCodeToDynamicClause(cl), pp);
|
||||
RestoreDynamicClause(ClauseCodeToDynamicClause(cl), pp PASS_REGS);
|
||||
if (cl == Last) return;
|
||||
cl = NextDynamicClause(cl);
|
||||
} while (TRUE);
|
||||
@ -1110,7 +1112,7 @@ CleanClauses(yamop *First, yamop *Last, PredEntry *pp)
|
||||
StaticClause *cl = ClauseCodeToStaticClause(First);
|
||||
|
||||
do {
|
||||
RestoreStaticClause(cl);
|
||||
RestoreStaticClause(cl PASS_REGS);
|
||||
if (cl->ClCode == Last) return;
|
||||
cl = cl->ClNext;
|
||||
} while (TRUE);
|
||||
@ -1121,7 +1123,7 @@ CleanClauses(yamop *First, yamop *Last, PredEntry *pp)
|
||||
|
||||
/* Restores a DB structure, as it was saved in the heap */
|
||||
static void
|
||||
RestoreBB(BlackBoardEntry *pp, int int_key)
|
||||
RestoreBB(BlackBoardEntry *pp, int int_key USES_REGS)
|
||||
{
|
||||
Term t = pp->Element;
|
||||
if (t) {
|
||||
@ -1131,7 +1133,7 @@ RestoreBB(BlackBoardEntry *pp, int int_key)
|
||||
pp->Element = AtomTermAdjust(t);
|
||||
}
|
||||
} else {
|
||||
RestoreLUClause((LogUpdClause *)DBRefOfTerm(t),NULL);
|
||||
RestoreLUClause((LogUpdClause *)DBRefOfTerm(t),NULL PASS_REGS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1144,7 +1146,7 @@ RestoreBB(BlackBoardEntry *pp, int int_key)
|
||||
}
|
||||
|
||||
static void
|
||||
restore_static_array(StaticArrayEntry *ae)
|
||||
restore_static_array(StaticArrayEntry *ae USES_REGS)
|
||||
{
|
||||
Int sz = -ae->ArrayEArity;
|
||||
switch (ae->ArrayType) {
|
||||
@ -1251,7 +1253,7 @@ restore_static_array(StaticArrayEntry *ae)
|
||||
} else {
|
||||
DBTerm *db = (DBTerm *)RepAppl(reg);
|
||||
db = DBTermAdjust(db);
|
||||
RestoreDBTerm(db, TRUE);
|
||||
RestoreDBTerm(db, TRUE PASS_REGS);
|
||||
base->tstore = AbsAppl((CELL *)db);
|
||||
}
|
||||
}
|
||||
@ -1270,7 +1272,7 @@ restore_static_array(StaticArrayEntry *ae)
|
||||
base++;
|
||||
} else {
|
||||
*base++ = reg = DBTermAdjust(reg);
|
||||
RestoreDBTerm(reg, TRUE);
|
||||
RestoreDBTerm(reg, TRUE PASS_REGS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1284,7 +1286,7 @@ restore_static_array(StaticArrayEntry *ae)
|
||||
* because of the indexing code
|
||||
*/
|
||||
static void
|
||||
CleanCode(PredEntry *pp)
|
||||
CleanCode(PredEntry *pp USES_REGS)
|
||||
{
|
||||
CELL flag;
|
||||
|
||||
@ -1325,7 +1327,7 @@ CleanCode(PredEntry *pp)
|
||||
/* assembly */
|
||||
if (pp->CodeOfPred) {
|
||||
pp->CodeOfPred = PtoOpAdjust(pp->CodeOfPred);
|
||||
CleanClauses(pp->CodeOfPred, pp->CodeOfPred, pp);
|
||||
CleanClauses(pp->CodeOfPred, pp->CodeOfPred, pp PASS_REGS);
|
||||
}
|
||||
} else {
|
||||
yamop *FirstC, *LastC;
|
||||
@ -1347,21 +1349,21 @@ CleanCode(PredEntry *pp)
|
||||
#ifdef DEBUG_RESTORE2
|
||||
fprintf(stderr, "at %ux Correcting clauses from %p to %p\n", *(OPCODE *) FirstC, FirstC, LastC);
|
||||
#endif
|
||||
CleanClauses(FirstC, LastC, pp);
|
||||
CleanClauses(FirstC, LastC, pp PASS_REGS);
|
||||
if (flag & IndexedPredFlag) {
|
||||
#ifdef DEBUG_RESTORE2
|
||||
fprintf(stderr, "Correcting indexed code\n");
|
||||
#endif
|
||||
if (flag & LogUpdatePredFlag) {
|
||||
CleanLUIndex(ClauseCodeToLogUpdIndex(pp->cs.p_code.TrueCodeOfPred), TRUE);
|
||||
CleanLUIndex(ClauseCodeToLogUpdIndex(pp->cs.p_code.TrueCodeOfPred), TRUE PASS_REGS);
|
||||
} else {
|
||||
CleanSIndex(ClauseCodeToStaticIndex(pp->cs.p_code.TrueCodeOfPred), TRUE);
|
||||
CleanSIndex(ClauseCodeToStaticIndex(pp->cs.p_code.TrueCodeOfPred), TRUE PASS_REGS);
|
||||
}
|
||||
} else if (flag & DynamicPredFlag) {
|
||||
#ifdef DEBUG_RESTORE2
|
||||
fprintf(stderr, "Correcting dynamic code\n");
|
||||
#endif
|
||||
RestoreDynamicClause(ClauseCodeToDynamicClause(pp->cs.p_code.TrueCodeOfPred),pp);
|
||||
RestoreDynamicClause(ClauseCodeToDynamicClause(pp->cs.p_code.TrueCodeOfPred),pp PASS_REGS);
|
||||
}
|
||||
}
|
||||
/* we are pointing at ourselves */
|
||||
@ -1372,7 +1374,7 @@ CleanCode(PredEntry *pp)
|
||||
* if we find code or data bases
|
||||
*/
|
||||
static void
|
||||
RestoreEntries(PropEntry *pp, int int_key)
|
||||
RestoreEntries(PropEntry *pp, int int_key USES_REGS)
|
||||
{
|
||||
while (!EndOfPAEntr(pp)) {
|
||||
switch(pp->KindOfPE) {
|
||||
@ -1388,7 +1390,7 @@ RestoreEntries(PropEntry *pp, int int_key)
|
||||
PropAdjust(fe->PropsOfFE);
|
||||
if (!EndOfPAEntr(p0)) {
|
||||
/* at most one property */
|
||||
CleanCode(RepPredProp(p0));
|
||||
CleanCode(RepPredProp(p0) PASS_REGS);
|
||||
RepPredProp(p0)->NextOfPE =
|
||||
PropAdjust(RepPredProp(p0)->NextOfPE);
|
||||
p0 = RepPredProp(p0)->NextOfPE;
|
||||
@ -1422,7 +1424,7 @@ RestoreEntries(PropEntry *pp, int int_key)
|
||||
StaticArrayEntry *sae = (StaticArrayEntry *)ae;
|
||||
if (sae->NextAE)
|
||||
sae->NextAE = PtoArraySAdjust(sae->NextAE);
|
||||
restore_static_array(sae);
|
||||
restore_static_array(sae PASS_REGS);
|
||||
} else {
|
||||
if (ae->NextAE)
|
||||
ae->NextAE = PtoArrayEAdjust(ae->NextAE);
|
||||
@ -1452,7 +1454,7 @@ RestoreEntries(PropEntry *pp, int int_key)
|
||||
PredEntry *pe = (PredEntry *) pp;
|
||||
pe->NextOfPE =
|
||||
PropAdjust(pe->NextOfPE);
|
||||
CleanCode(pe);
|
||||
CleanCode(pe PASS_REGS);
|
||||
}
|
||||
break;
|
||||
case DBProperty:
|
||||
@ -1464,7 +1466,7 @@ RestoreEntries(PropEntry *pp, int int_key)
|
||||
DBEntry *de = (DBEntry *) pp;
|
||||
de->NextOfPE =
|
||||
PropAdjust(de->NextOfPE);
|
||||
RestoreDB(de);
|
||||
RestoreDB(de PASS_REGS);
|
||||
}
|
||||
break;
|
||||
case BBProperty:
|
||||
@ -1472,7 +1474,7 @@ RestoreEntries(PropEntry *pp, int int_key)
|
||||
BlackBoardEntry *bb = (BlackBoardEntry *) pp;
|
||||
bb->NextOfPE =
|
||||
PropAdjust(bb->NextOfPE);
|
||||
RestoreBB(bb, int_key);
|
||||
RestoreBB(bb, int_key PASS_REGS);
|
||||
}
|
||||
break;
|
||||
case GlobalProperty:
|
||||
@ -1563,7 +1565,7 @@ RestoreEntries(PropEntry *pp, int int_key)
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreAtom(AtomEntry *at)
|
||||
RestoreAtom(AtomEntry *at USES_REGS)
|
||||
{
|
||||
AtomEntry *nat;
|
||||
|
||||
@ -1575,7 +1577,7 @@ RestoreAtom(AtomEntry *at)
|
||||
else
|
||||
fprintf(errout, "Restoring %s\n", at->StrOfAE);
|
||||
#endif
|
||||
RestoreEntries(RepProp(at->PropsOfAE), FALSE);
|
||||
RestoreEntries(RepProp(at->PropsOfAE), FALSE PASS_REGS);
|
||||
/* cannot use AtomAdjust without breaking agc */
|
||||
nat = RepAtom(at->NextOfAE);
|
||||
if (nat)
|
||||
|
32
H/rhstruct.h
32
H/rhstruct.h
@ -74,9 +74,9 @@
|
||||
|
||||
|
||||
|
||||
RestoreInvisibleAtoms();
|
||||
RestoreWideAtoms();
|
||||
RestoreAtoms();
|
||||
RestoreInvisibleAtoms( PASS_REGS1 );
|
||||
RestoreWideAtoms( PASS_REGS1 );
|
||||
RestoreAtoms( PASS_REGS1 );
|
||||
|
||||
#include "ratoms.h"
|
||||
#ifdef EUROTRA
|
||||
@ -106,7 +106,7 @@
|
||||
|
||||
|
||||
|
||||
RestorePredHash();
|
||||
RestorePredHash( PASS_REGS1 );
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
|
||||
#endif
|
||||
@ -204,10 +204,10 @@
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
REINIT_LOCK(Yap_heap_regs->dbterms_list_lock);
|
||||
#endif
|
||||
RestoreDBTermsList();
|
||||
RestoreDBTermsList( PASS_REGS1 );
|
||||
|
||||
|
||||
RestoreExpandList();
|
||||
RestoreExpandList( PASS_REGS1 );
|
||||
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
REINIT_LOCK(Yap_heap_regs->expand_clauses_list_lock);
|
||||
@ -227,9 +227,9 @@
|
||||
|
||||
|
||||
|
||||
RestoreIntKeys();
|
||||
RestoreIntLUKeys();
|
||||
RestoreIntBBKeys();
|
||||
RestoreIntKeys( PASS_REGS1 );
|
||||
RestoreIntLUKeys( PASS_REGS1 );
|
||||
RestoreIntBBKeys( PASS_REGS1 );
|
||||
|
||||
|
||||
|
||||
@ -240,11 +240,11 @@
|
||||
RestoreDBErasedMarker();
|
||||
RestoreLogDBErasedMarker();
|
||||
|
||||
RestoreDeadStaticClauses();
|
||||
RestoreDeadMegaClauses();
|
||||
RestoreDeadStaticIndices();
|
||||
RestoreDBErasedList();
|
||||
RestoreDBErasedIList();
|
||||
RestoreDeadStaticClauses( PASS_REGS1 );
|
||||
RestoreDeadMegaClauses( PASS_REGS1 );
|
||||
RestoreDeadStaticIndices( PASS_REGS1 );
|
||||
RestoreDBErasedList( PASS_REGS1 );
|
||||
RestoreDBErasedIList( PASS_REGS1 );
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
REINIT_LOCK(Yap_heap_regs->dead_static_clauses_lock);
|
||||
REINIT_LOCK(Yap_heap_regs->dead_mega_clauses_lock);
|
||||
@ -294,9 +294,9 @@
|
||||
|
||||
|
||||
|
||||
RestoreYapRecords();
|
||||
RestoreYapRecords( PASS_REGS1 );
|
||||
|
||||
RestoreSWIAtoms();
|
||||
RestoreSWIAtoms( PASS_REGS1 );
|
||||
|
||||
|
||||
|
||||
|
483
H/sshift.h
483
H/sshift.h
File diff suppressed because it is too large
Load Diff
@ -144,25 +144,25 @@
|
||||
case _copy_idb_term:
|
||||
return found_idb_clause(pc, startp, endp);
|
||||
case _expand_index:
|
||||
return found_expand(pc, startp, endp);
|
||||
return found_expand(pc, startp, endp PASS_REGS);
|
||||
case _index_pred:
|
||||
return found_owner_op(pc, startp, endp);
|
||||
return found_owner_op(pc, startp, endp PASS_REGS);
|
||||
case _lock_pred:
|
||||
return found_owner_op(pc, startp, endp);
|
||||
return found_owner_op(pc, startp, endp PASS_REGS);
|
||||
case _op_fail:
|
||||
if (codeptr == FAILCODE)
|
||||
return found_fail(pc, startp, endp);
|
||||
return found_fail(pc, startp, endp PASS_REGS);
|
||||
pc = NEXTOP(pc,e);
|
||||
break;
|
||||
case _spy_pred:
|
||||
return found_owner_op(pc, startp, endp);
|
||||
return found_owner_op(pc, startp, endp PASS_REGS);
|
||||
case _trust_fail:
|
||||
if (codeptr == TRUSTFAILCODE)
|
||||
return found_fail(pc, startp, endp);
|
||||
return found_fail(pc, startp, endp PASS_REGS);
|
||||
pc = NEXTOP(pc,e);
|
||||
break;
|
||||
case _undef_p:
|
||||
return found_owner_op(pc, startp, endp);
|
||||
return found_owner_op(pc, startp, endp PASS_REGS);
|
||||
case _unify_idb_term:
|
||||
return found_idb_clause(pc, startp, endp);
|
||||
case _allocate:
|
||||
@ -195,7 +195,7 @@
|
||||
break;
|
||||
/* instructions type l */
|
||||
case _Ystop:
|
||||
return found_ystop(pc, clause_code, startp, endp, pp);
|
||||
return found_ystop(pc, clause_code, startp, endp, pp PASS_REGS);
|
||||
case _jump:
|
||||
case _jump_if_var:
|
||||
case _move_back:
|
||||
@ -402,7 +402,7 @@
|
||||
break;
|
||||
/* instructions type sssllp */
|
||||
case _expand_clauses:
|
||||
return found_expand_index(pc, startp, endp, codeptr);
|
||||
return found_expand_index(pc, startp, endp, codeptr PASS_REGS);
|
||||
pc = NEXTOP(pc,sssllp);
|
||||
break;
|
||||
/* instructions type x */
|
||||
|
@ -187,7 +187,7 @@ typedef struct TOKEN {
|
||||
|
||||
#define Ord(X) ((enum TokenKinds) (X))
|
||||
|
||||
#define NextToken GNextToken()
|
||||
#define NextToken GNextToken( PASS_REGS1 )
|
||||
|
||||
typedef struct VARSTRUCT {
|
||||
Term VarAdr;
|
||||
|
@ -51,7 +51,7 @@ myddas_init_initialize_myddas(void){
|
||||
MYDDAS_UTIL_CONNECTION
|
||||
myddas_init_initialize_connection(void *conn,void *enviromment,
|
||||
MYDDAS_UTIL_CONNECTION next){
|
||||
|
||||
CACHE_REGS
|
||||
MYDDAS_UTIL_CONNECTION new = NULL;
|
||||
MYDDAS_MALLOC(new,struct myddas_list_connection);
|
||||
|
||||
@ -86,7 +86,7 @@ myddas_init_initialize_connection(void *conn,void *enviromment,
|
||||
MYDDAS_UTIL_PREDICATE
|
||||
myddas_init_initialize_predicate(char *pred_name, int pred_arity,
|
||||
char *pred_module, MYDDAS_UTIL_PREDICATE next){
|
||||
|
||||
CACHE_REGS
|
||||
MYDDAS_UTIL_PREDICATE new = NULL;
|
||||
MYDDAS_MALLOC(new,struct myddas_list_preds);
|
||||
|
||||
|
@ -29,15 +29,15 @@
|
||||
|
||||
static Int null_id = 0;
|
||||
|
||||
STATIC_PROTO(Int c_db_odbc_connect,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_disconnect,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_number_of_fields,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_get_attributes_types,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_query,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_row,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_row_cut,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_get_fields_properties,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_number_of_fields_in_query,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_connect,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_odbc_disconnect,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_odbc_number_of_fields,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_odbc_get_attributes_types,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_odbc_query,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_odbc_row,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_odbc_row_cut,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_odbc_get_fields_properties,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_odbc_number_of_fields_in_query,( USES_REGS1 ));
|
||||
|
||||
static int
|
||||
odbc_error(SQLSMALLINT type, SQLHANDLE hdbc, char *msg, char *print)
|
||||
@ -321,7 +321,7 @@ static int SQLCOLATTRIBUTE( SQLHSTMT StatementHandle,
|
||||
|
||||
|
||||
static Int
|
||||
c_db_odbc_connect(void) {
|
||||
c_db_odbc_connect( USES_REGS1 ) {
|
||||
Term arg_driver = Deref(ARG1);
|
||||
Term arg_user = Deref(ARG2);
|
||||
Term arg_passwd = Deref(ARG3);
|
||||
@ -371,7 +371,7 @@ c_db_odbc_connect(void) {
|
||||
|
||||
/* db_query: SQLQuery x ResultSet x Arity x BindList x Connection */
|
||||
static Int
|
||||
c_db_odbc_query(void) {
|
||||
c_db_odbc_query( USES_REGS1 ) {
|
||||
Term arg_sql_query = Deref(ARG1);
|
||||
Term arg_result_set = Deref(ARG2);
|
||||
Term arg_arity = Deref(ARG3);
|
||||
@ -452,7 +452,7 @@ c_db_odbc_query(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
c_db_odbc_number_of_fields(void) {
|
||||
c_db_odbc_number_of_fields( USES_REGS1 ) {
|
||||
Term arg_relation = Deref(ARG1);
|
||||
Term arg_conn = Deref(ARG2);
|
||||
Term arg_fields = Deref(ARG3);
|
||||
@ -493,7 +493,7 @@ c_db_odbc_number_of_fields(void) {
|
||||
|
||||
/* db_get_attributes_types: RelName x Connection -> TypesList */
|
||||
static Int
|
||||
c_db_odbc_get_attributes_types(void) {
|
||||
c_db_odbc_get_attributes_types( USES_REGS1 ) {
|
||||
Term arg_relation = Deref(ARG1);
|
||||
Term arg_conn = Deref(ARG2);
|
||||
Term arg_types_list = Deref(ARG3);
|
||||
@ -554,7 +554,7 @@ c_db_odbc_get_attributes_types(void) {
|
||||
|
||||
/* db_disconnect */
|
||||
static Int
|
||||
c_db_odbc_disconnect(void) {
|
||||
c_db_odbc_disconnect( USES_REGS1 ) {
|
||||
Term arg_conn = Deref(ARG1);
|
||||
|
||||
SQLHDBC conn = (SQLHDBC) (IntegerOfTerm(arg_conn));
|
||||
@ -579,7 +579,7 @@ c_db_odbc_disconnect(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
c_db_odbc_row_cut(void) {
|
||||
c_db_odbc_row_cut( USES_REGS1 ) {
|
||||
|
||||
SQLHSTMT hstmt = (SQLHSTMT) IntegerOfTerm(EXTRA_CBACK_CUT_ARG(Term,1));
|
||||
|
||||
@ -593,7 +593,7 @@ c_db_odbc_row_cut(void) {
|
||||
|
||||
/* db_row: ResultSet x BindList x ListOfArgs -> */
|
||||
static Int
|
||||
c_db_odbc_row(void) {
|
||||
c_db_odbc_row( USES_REGS1 ) {
|
||||
Term arg_result_set = Deref(ARG1);
|
||||
Term arg_bind_list = Deref(ARG2);
|
||||
Term arg_list_args = Deref(ARG3);
|
||||
@ -674,7 +674,7 @@ c_db_odbc_row(void) {
|
||||
/* Mudar esta funcao de forma a nao fazer a consulta, pois
|
||||
no predicate db_sql_selet vai fazer duas vezes a mesma consutla*/
|
||||
static Int
|
||||
c_db_odbc_number_of_fields_in_query(void) {
|
||||
c_db_odbc_number_of_fields_in_query( USES_REGS1 ) {
|
||||
Term arg_query = Deref(ARG1);
|
||||
Term arg_conn = Deref(ARG2);
|
||||
Term arg_fields = Deref(ARG3);
|
||||
@ -714,7 +714,7 @@ c_db_odbc_number_of_fields_in_query(void) {
|
||||
}
|
||||
|
||||
static Int
|
||||
c_db_odbc_get_fields_properties(void) {
|
||||
c_db_odbc_get_fields_properties( USES_REGS1 ) {
|
||||
Term nome_relacao = Deref(ARG1);
|
||||
Term arg_conn = Deref(ARG2);
|
||||
Term fields_properties_list = Deref(ARG3);
|
||||
|
@ -27,24 +27,24 @@
|
||||
#include "myddas_statistics.h"
|
||||
#endif
|
||||
|
||||
STATIC_PROTO(Int c_db_initialize_myddas,(void));
|
||||
STATIC_PROTO(Int c_db_connection_type,(void));
|
||||
STATIC_PROTO(Int c_db_add_preds,(void));
|
||||
STATIC_PROTO(Int c_db_preds_conn_start ,(void));
|
||||
STATIC_PROTO(Int c_db_preds_conn_continue ,(void));
|
||||
STATIC_PROTO(Int c_db_connection_start ,(void));
|
||||
STATIC_PROTO(Int c_db_connection_continue ,(void));
|
||||
STATIC_PROTO(Int c_db_check_if_exists_pred,(void));
|
||||
STATIC_PROTO(Int c_db_delete_predicate,(void));
|
||||
STATIC_PROTO(Int c_db_multi_queries_number,(void));
|
||||
STATIC_PROTO(Int c_db_initialize_myddas,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_connection_type,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_add_preds,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_preds_conn_start ,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_preds_conn_continue ,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_connection_start ,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_connection_continue ,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_check_if_exists_pred,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_delete_predicate,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_multi_queries_number,( USES_REGS1 ));
|
||||
#ifdef MYDDAS_STATS
|
||||
STATIC_PROTO(Int c_db_stats,(void));
|
||||
STATIC_PROTO(Int c_db_stats_walltime,(void));
|
||||
STATIC_PROTO(Int c_db_stats_translate,(void));
|
||||
STATIC_PROTO(Int c_db_stats_time,(void));
|
||||
STATIC_PROTO(Int c_db_stats,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_stats_walltime,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_stats_translate,( USES_REGS1 ));
|
||||
STATIC_PROTO(Int c_db_stats_time,( USES_REGS1 ));
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
STATIC_PROTO(Int c_db_check,(void));
|
||||
STATIC_PROTO(Int c_db_check,( USES_REGS1 ));
|
||||
#endif
|
||||
|
||||
void Yap_InitMYDDAS_SharedPreds(void)
|
||||
@ -102,7 +102,7 @@ void Yap_InitBackMYDDAS_SharedPreds(void)
|
||||
|
||||
/* Initialize all of the MYDDAS global structures */
|
||||
static Int
|
||||
c_db_initialize_myddas(void){
|
||||
c_db_initialize_myddas( USES_REGS1 ){
|
||||
Yap_REGS.MYDDAS_GLOBAL_POINTER = myddas_init_initialize_myddas();
|
||||
#ifdef MYDDAS_STATS
|
||||
Yap_REGS.MYDDAS_GLOBAL_POINTER = myddas_stats_initialize_global_stats(Yap_REGS.MYDDAS_GLOBAL_POINTER);
|
||||
@ -117,7 +117,7 @@ c_db_initialize_myddas(void){
|
||||
NOTE: In order to use this predicate, the connection*/
|
||||
/* c_db_connection_type: +Connection * ?Type */
|
||||
static Int
|
||||
c_db_connection_type (void){
|
||||
c_db_connection_type ( USES_REGS1 ){
|
||||
Term arg_con = Deref(ARG1);
|
||||
Term arg_type = Deref(ARG2);
|
||||
|
||||
@ -136,7 +136,7 @@ c_db_connection_type (void){
|
||||
|
||||
/* db_add_preds: PredName * Arity * Module * Connection*/
|
||||
static Int
|
||||
c_db_add_preds (void){
|
||||
c_db_add_preds ( USES_REGS1 ){
|
||||
Term arg_nome = Deref(ARG1);
|
||||
Term arg_aridade = Deref(ARG2);
|
||||
Term arg_module = Deref(ARG3);
|
||||
@ -164,7 +164,7 @@ c_db_add_preds (void){
|
||||
|
||||
|
||||
static Int
|
||||
c_db_check_if_exists_pred (void){
|
||||
c_db_check_if_exists_pred ( USES_REGS1 ){
|
||||
Term arg_nome = Deref(ARG1);
|
||||
Term arg_aridade = Deref(ARG2);
|
||||
Term arg_module = Deref(ARG3);
|
||||
@ -182,7 +182,7 @@ c_db_check_if_exists_pred (void){
|
||||
|
||||
|
||||
static Int
|
||||
c_db_delete_predicate(void){
|
||||
c_db_delete_predicate( USES_REGS1 ){
|
||||
Term arg_module = Deref(ARG1);
|
||||
Term arg_name = Deref(ARG2);
|
||||
Term arg_arity = Deref(ARG3);
|
||||
@ -203,7 +203,7 @@ c_db_delete_predicate(void){
|
||||
|
||||
|
||||
static Int
|
||||
c_db_multi_queries_number(void){
|
||||
c_db_multi_queries_number( USES_REGS1 ){
|
||||
Term arg_conn = Deref(ARG1);
|
||||
Term arg_number = Deref(ARG2);
|
||||
|
||||
@ -228,18 +228,18 @@ c_db_multi_queries_number(void){
|
||||
}
|
||||
|
||||
static Int
|
||||
c_db_connection_start(void){
|
||||
c_db_connection_start( USES_REGS1 ){
|
||||
|
||||
MYDDAS_UTIL_CONNECTION node =
|
||||
Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
|
||||
EXTRA_CBACK_ARG(1,1)=(CELL) MkIntegerTerm((Int)node);
|
||||
|
||||
return (c_db_connection_continue());
|
||||
return (c_db_connection_continue( PASS_REGS1 ));
|
||||
}
|
||||
|
||||
static Int
|
||||
c_db_connection_continue(void){
|
||||
c_db_connection_continue( USES_REGS1 ){
|
||||
Term arg_conn = Deref(ARG1);
|
||||
|
||||
MYDDAS_UTIL_CONNECTION node;
|
||||
@ -261,7 +261,7 @@ c_db_connection_continue(void){
|
||||
|
||||
/* db_preds_conn : Connection(+) * Pred_name(-) * Pred_arity */
|
||||
static Int
|
||||
c_db_preds_conn_start (void){
|
||||
c_db_preds_conn_start ( USES_REGS1 ){
|
||||
Term arg_conn = Deref(ARG1);
|
||||
|
||||
Int *conn = (Int *) IntegerOfTerm(arg_conn);
|
||||
@ -278,12 +278,12 @@ c_db_preds_conn_start (void){
|
||||
void *pointer = myddas_util_get_list_pred(node);
|
||||
EXTRA_CBACK_ARG(4,1)=(CELL) MkIntegerTerm((Int)pointer);
|
||||
|
||||
return (c_db_preds_conn_continue());
|
||||
return (c_db_preds_conn_continue( PASS_REGS1 ));
|
||||
}
|
||||
|
||||
/* db_preds_conn : Connection(+) * Pred_name(-) * Pred_arity*/
|
||||
static Int
|
||||
c_db_preds_conn_continue (void){
|
||||
c_db_preds_conn_continue ( USES_REGS1 ){
|
||||
Term module = Deref(ARG2);
|
||||
Term name = Deref(ARG3);
|
||||
Term arity = Deref(ARG4);
|
||||
@ -317,7 +317,7 @@ c_db_preds_conn_continue (void){
|
||||
|
||||
#ifdef DEBUG
|
||||
static Int
|
||||
c_db_check(void){
|
||||
c_db_check( USES_REGS1 ){
|
||||
check_int();
|
||||
return TRUE;
|
||||
}
|
||||
@ -326,7 +326,7 @@ c_db_check(void){
|
||||
#ifdef MYDDAS_STATS
|
||||
|
||||
static Int
|
||||
c_db_stats_walltime(void){
|
||||
c_db_stats_walltime( USES_REGS1 ){
|
||||
Term arg_time = Deref(ARG1);
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -344,7 +344,7 @@ c_db_stats_walltime(void){
|
||||
}
|
||||
|
||||
static Int
|
||||
c_db_stats_translate(void){
|
||||
c_db_stats_translate( USES_REGS1 ){
|
||||
Term arg_start = Deref(ARG1);
|
||||
Term arg_end = Deref(ARG2);
|
||||
|
||||
@ -386,7 +386,7 @@ c_db_stats_translate(void){
|
||||
}
|
||||
|
||||
static Int
|
||||
c_db_stats_time(void){
|
||||
c_db_stats_time( USES_REGS1 ){
|
||||
Term arg_reference = Deref(ARG1);
|
||||
Term arg_time = Deref(ARG2);
|
||||
|
||||
@ -473,7 +473,7 @@ c_db_stats_time(void){
|
||||
|
||||
//Returns the stats of this module in a list
|
||||
static Int
|
||||
c_db_stats(void) {
|
||||
c_db_stats( USES_REGS1 ) {
|
||||
Term arg_conn = Deref(ARG1);
|
||||
Term arg_list = Deref(ARG2);
|
||||
|
||||
@ -655,6 +655,7 @@ c_db_stats(void) {
|
||||
/* from the mysql server */
|
||||
void Yap_MYDDAS_delete_all_myddas_structs(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
|
||||
/* NAO ESQUECER DE FAZER ISTO TB PARA O DB_CLOSE*/
|
||||
MYDDAS_GLOBAL global =
|
||||
|
@ -56,6 +56,7 @@ myddas_util_connection_type(void *con){
|
||||
MYDDAS_UTIL_PREDICATE
|
||||
myddas_util_search_predicate(char *pred_name, Int pred_arity,
|
||||
char *pred_module){
|
||||
CACHE_REGS
|
||||
MYDDAS_UTIL_PREDICATE pred=NULL;
|
||||
MYDDAS_UTIL_CONNECTION top = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
|
||||
@ -91,7 +92,7 @@ myddas_util_add_predicate(char *pred_name, Int pred_arity,
|
||||
|
||||
void
|
||||
myddas_util_delete_predicate(MYDDAS_UTIL_PREDICATE to_delete){
|
||||
|
||||
CACHE_REGS
|
||||
if (to_delete->next != NULL)
|
||||
to_delete->next->previous = to_delete->previous;
|
||||
if (to_delete->previous != NULL)
|
||||
@ -109,7 +110,7 @@ myddas_util_delete_predicate(MYDDAS_UTIL_PREDICATE to_delete){
|
||||
|
||||
void
|
||||
myddas_util_delete_connection(void *conn){
|
||||
|
||||
CACHE_REGS
|
||||
MYDDAS_UTIL_CONNECTION to_delete = myddas_util_search_connection(conn);
|
||||
|
||||
if (to_delete == NULL)
|
||||
@ -141,6 +142,7 @@ myddas_util_delete_connection(void *conn){
|
||||
|
||||
MYDDAS_UTIL_CONNECTION
|
||||
myddas_util_search_connection(void *conn){
|
||||
CACHE_REGS
|
||||
MYDDAS_UTIL_CONNECTION list = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
@ -157,7 +159,7 @@ myddas_util_search_connection(void *conn){
|
||||
|
||||
MYDDAS_UTIL_CONNECTION
|
||||
myddas_util_add_connection(void *conn, void *enviromment){
|
||||
|
||||
CACHE_REGS
|
||||
MYDDAS_UTIL_CONNECTION node=NULL;
|
||||
MYDDAS_UTIL_CONNECTION temp=NULL;
|
||||
|
||||
@ -184,6 +186,7 @@ myddas_util_add_connection(void *conn, void *enviromment){
|
||||
if there is any odbc connections left on the list*/
|
||||
SQLHENV
|
||||
myddas_util_get_odbc_enviromment(SQLHDBC connection){
|
||||
CACHE_REGS
|
||||
MYDDAS_UTIL_CONNECTION top = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
|
||||
for (;top != NULL;top=top->next)
|
||||
@ -238,6 +241,7 @@ myddas_util_find_predicate(char *pred_name, Int pred_arity,
|
||||
|
||||
static void
|
||||
myddas_util_delete_predicate_list(MYDDAS_UTIL_PREDICATE preds_list){
|
||||
CACHE_REGS
|
||||
MYDDAS_UTIL_PREDICATE to_delete = NULL;
|
||||
|
||||
for (;preds_list != NULL;)
|
||||
@ -321,7 +325,8 @@ myddas_util_table_write(MYSQL_RES *res_set){
|
||||
|
||||
//DELETE THIS WHEN DB_STATS IS COMPLETED
|
||||
MyddasInt
|
||||
get_myddas_top(){
|
||||
get_myddas_top( void ){
|
||||
CACHE_REGS
|
||||
if (Yap_REGS.MYDDAS_GLOBAL_POINTER == NULL)
|
||||
return 0;
|
||||
return (Int)Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
@ -357,7 +362,8 @@ myddas_util_get_list_pred(MYDDAS_UTIL_CONNECTION node){
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void check_int(){
|
||||
void check_int( void ){
|
||||
CACHE_REGS
|
||||
Int i;
|
||||
MYDDAS_UTIL_PREDICATE pred = NULL;
|
||||
MYDDAS_UTIL_CONNECTION top = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
|
@ -180,6 +180,7 @@ void Yap_init_global(int max_table_size, int n_workers, int sch_loop, int delay_
|
||||
|
||||
void Yap_init_local(void) {
|
||||
#ifdef YAPOR
|
||||
CACHE_REGS
|
||||
/* local data related to or-parallelism */
|
||||
LOCAL = REMOTE + worker_id;
|
||||
Set_LOCAL_top_cp((choiceptr) Yap_LocalBase);
|
||||
@ -209,6 +210,7 @@ void Yap_init_local(void) {
|
||||
|
||||
void make_root_frames(void) {
|
||||
#ifdef YAPOR
|
||||
CACHE_REGS
|
||||
/* root or frame */
|
||||
or_fr_ptr or_fr;
|
||||
|
||||
@ -248,6 +250,7 @@ void make_root_frames(void) {
|
||||
|
||||
#ifdef YAPOR
|
||||
void init_workers(void) {
|
||||
CACHE_REGS
|
||||
int proc;
|
||||
#ifdef THREADS
|
||||
return;
|
||||
|
@ -35,39 +35,39 @@
|
||||
#endif /* TABLING */
|
||||
|
||||
#ifdef TABLING
|
||||
static Int p_freeze_choice_point(void);
|
||||
static Int p_wake_choice_point(void);
|
||||
static Int p_reset_frozen_choice_points(void);
|
||||
static Int p_abolish_frozen_choice_points_until(void);
|
||||
static Int p_abolish_frozen_choice_points_all(void);
|
||||
static Int p_table(void);
|
||||
static Int p_tabling_mode(void);
|
||||
static Int p_abolish_table(void);
|
||||
static Int p_abolish_all_tables(void);
|
||||
static Int p_show_tabled_predicates(void);
|
||||
static Int p_show_table(void);
|
||||
static Int p_show_all_tables(void);
|
||||
static Int p_show_global_trie(void);
|
||||
static Int p_show_statistics_table(void);
|
||||
static Int p_show_statistics_tabling(void);
|
||||
static Int p_show_statistics_global_trie(void);
|
||||
static Int p_freeze_choice_point( USES_REGS1 );
|
||||
static Int p_wake_choice_point( USES_REGS1 );
|
||||
static Int p_reset_frozen_choice_points( USES_REGS1 );
|
||||
static Int p_abolish_frozen_choice_points_until( USES_REGS1 );
|
||||
static Int p_abolish_frozen_choice_points_all( USES_REGS1 );
|
||||
static Int p_table( USES_REGS1 );
|
||||
static Int p_tabling_mode( USES_REGS1 );
|
||||
static Int p_abolish_table( USES_REGS1 );
|
||||
static Int p_abolish_all_tables( USES_REGS1 );
|
||||
static Int p_show_tabled_predicates( USES_REGS1 );
|
||||
static Int p_show_table( USES_REGS1 );
|
||||
static Int p_show_all_tables( USES_REGS1 );
|
||||
static Int p_show_global_trie( USES_REGS1 );
|
||||
static Int p_show_statistics_table( USES_REGS1 );
|
||||
static Int p_show_statistics_tabling( USES_REGS1 );
|
||||
static Int p_show_statistics_global_trie( USES_REGS1 );
|
||||
#endif /* TABLING */
|
||||
static Int p_yapor_threads(void);
|
||||
static Int p_yapor_threads( USES_REGS1 );
|
||||
#ifdef YAPOR
|
||||
static Int p_worker(void);
|
||||
static Int p_yapor_on(void);
|
||||
static Int p_start_yapor(void);
|
||||
static Int p_default_sequential(void);
|
||||
static Int p_execution_mode(void);
|
||||
static Int p_performance(void);
|
||||
static Int p_parallel_new_answer(void);
|
||||
static Int p_parallel_yes_answer(void);
|
||||
static Int p_show_statistics_or(void);
|
||||
static Int p_worker( USES_REGS1 );
|
||||
static Int p_yapor_on( USES_REGS1 );
|
||||
static Int p_start_yapor( USES_REGS1 );
|
||||
static Int p_default_sequential( USES_REGS1 );
|
||||
static Int p_execution_mode( USES_REGS1 );
|
||||
static Int p_performance( USES_REGS1 );
|
||||
static Int p_parallel_new_answer( USES_REGS1 );
|
||||
static Int p_parallel_yes_answer( USES_REGS1 );
|
||||
static Int p_show_statistics_or( USES_REGS1 );
|
||||
#endif /* YAPOR */
|
||||
#if defined(YAPOR) && defined(TABLING)
|
||||
static Int p_show_statistics_opt(void);
|
||||
static Int p_show_statistics_opt( USES_REGS1 );
|
||||
#endif /* YAPOR && TABLING */
|
||||
static Int p_get_optyap_statistics(void);
|
||||
static Int p_get_optyap_statistics( USES_REGS1 );
|
||||
|
||||
#ifdef YAPOR
|
||||
static inline realtime current_time(void);
|
||||
@ -172,7 +172,7 @@ void finish_yapor(void) {
|
||||
***********************************/
|
||||
|
||||
#ifdef TABLING
|
||||
static Int p_freeze_choice_point(void) {
|
||||
static Int p_freeze_choice_point( USES_REGS1 ) {
|
||||
if (IsVarTerm(Deref(ARG1))) {
|
||||
Int offset = freeze_current_cp();
|
||||
return Yap_unify(ARG1, MkIntegerTerm(offset));
|
||||
@ -181,7 +181,7 @@ static Int p_freeze_choice_point(void) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_wake_choice_point(void) {
|
||||
static Int p_wake_choice_point( USES_REGS1 ) {
|
||||
Term term_offset = Deref(ARG1);
|
||||
if (IsIntegerTerm(term_offset))
|
||||
wake_frozen_cp(IntegerOfTerm(term_offset));
|
||||
@ -189,7 +189,7 @@ static Int p_wake_choice_point(void) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_abolish_frozen_choice_points_until(void) {
|
||||
static Int p_abolish_frozen_choice_points_until( USES_REGS1 ) {
|
||||
Term term_offset = Deref(ARG1);
|
||||
if (IsIntegerTerm(term_offset))
|
||||
abolish_frozen_cps_until(IntegerOfTerm(term_offset));
|
||||
@ -197,13 +197,13 @@ static Int p_abolish_frozen_choice_points_until(void) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_abolish_frozen_choice_points_all(void) {
|
||||
static Int p_abolish_frozen_choice_points_all( USES_REGS1 ) {
|
||||
abolish_frozen_cps_all();
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
static Int p_table(void) {
|
||||
static Int p_table( USES_REGS1 ) {
|
||||
Term mod, t;
|
||||
PredEntry *pe;
|
||||
Atom at;
|
||||
@ -233,7 +233,7 @@ static Int p_table(void) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_tabling_mode(void) {
|
||||
static Int p_tabling_mode( USES_REGS1 ) {
|
||||
Term mod, t, tvalue;
|
||||
tab_ent_ptr tab_ent;
|
||||
|
||||
@ -320,7 +320,7 @@ static Int p_tabling_mode(void) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_abolish_table(void) {
|
||||
static Int p_abolish_table( USES_REGS1 ) {
|
||||
Term mod, t;
|
||||
tab_ent_ptr tab_ent;
|
||||
sg_hash_ptr hash;
|
||||
@ -355,7 +355,7 @@ static Int p_abolish_table(void) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_abolish_all_tables(void) {
|
||||
static Int p_abolish_all_tables( USES_REGS1 ) {
|
||||
tab_ent_ptr tab_ent;
|
||||
sg_hash_ptr hash;
|
||||
sg_node_ptr sg_node;
|
||||
@ -385,7 +385,7 @@ static Int p_abolish_all_tables(void) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_show_tabled_predicates(void) {
|
||||
static Int p_show_tabled_predicates( USES_REGS1 ) {
|
||||
tab_ent_ptr tab_ent;
|
||||
|
||||
tab_ent = GLOBAL_root_tab_ent;
|
||||
@ -401,7 +401,7 @@ static Int p_show_tabled_predicates(void) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_show_table(void) {
|
||||
static Int p_show_table( USES_REGS1 ) {
|
||||
Term mod, t;
|
||||
tab_ent_ptr tab_ent;
|
||||
|
||||
@ -418,7 +418,7 @@ static Int p_show_table(void) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_show_all_tables(void) {
|
||||
static Int p_show_all_tables( USES_REGS1 ) {
|
||||
tab_ent_ptr tab_ent;
|
||||
|
||||
tab_ent = GLOBAL_root_tab_ent;
|
||||
@ -430,13 +430,13 @@ static Int p_show_all_tables(void) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_show_global_trie(void) {
|
||||
static Int p_show_global_trie( USES_REGS1 ) {
|
||||
show_global_trie(SHOW_MODE_STRUCTURE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
static Int p_show_statistics_table(void) {
|
||||
static Int p_show_statistics_table( USES_REGS1 ) {
|
||||
Term mod, t;
|
||||
tab_ent_ptr tab_ent;
|
||||
|
||||
@ -453,7 +453,7 @@ static Int p_show_statistics_table(void) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_show_statistics_tabling(void) {
|
||||
static Int p_show_statistics_tabling( USES_REGS1 ) {
|
||||
long total_bytes = 0, aux_bytes;
|
||||
|
||||
aux_bytes = 0;
|
||||
@ -489,7 +489,7 @@ static Int p_show_statistics_tabling(void) {
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static Int p_show_statistics_global_trie(void) {
|
||||
static Int p_show_statistics_global_trie( USES_REGS1 ) {
|
||||
show_global_trie(SHOW_MODE_STATISTICS);
|
||||
return (TRUE);
|
||||
}
|
||||
@ -500,7 +500,7 @@ static Int p_show_statistics_global_trie(void) {
|
||||
** YapOr C Predicates **
|
||||
*********************************/
|
||||
|
||||
static Int p_yapor_threads(void) {
|
||||
static Int p_yapor_threads( USES_REGS1 ) {
|
||||
#if defined(YAPOR) && defined(THREADS)
|
||||
return Yap_unify(MkIntegerTerm(number_workers),ARG1);
|
||||
#else
|
||||
@ -510,19 +510,19 @@ static Int p_yapor_threads(void) {
|
||||
|
||||
|
||||
#ifdef YAPOR
|
||||
static Int p_worker(void) {
|
||||
static Int p_worker( USES_REGS1 ) {
|
||||
CurrentModule = USER_MODULE;
|
||||
P = GETWORK_FIRST_TIME;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static Int p_yapor_on(void) {
|
||||
static Int p_yapor_on( USES_REGS1 ) {
|
||||
return (PARALLEL_EXECUTION_MODE);
|
||||
}
|
||||
|
||||
|
||||
static Int p_start_yapor(void) {
|
||||
static Int p_start_yapor( USES_REGS1 ) {
|
||||
#ifdef TIMESTAMP_CHECK
|
||||
GLOBAL_timestamp = 0;
|
||||
#endif /* TIMESTAMP_CHECK */
|
||||
@ -542,7 +542,7 @@ static Int p_start_yapor(void) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_default_sequential(void) {
|
||||
static Int p_default_sequential( USES_REGS1 ) {
|
||||
Term t;
|
||||
t = Deref(ARG1);
|
||||
if (IsVarTerm(t)) {
|
||||
@ -570,7 +570,7 @@ static Int p_default_sequential(void) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_execution_mode(void) {
|
||||
static Int p_execution_mode( USES_REGS1 ) {
|
||||
Term t;
|
||||
t = Deref(ARG1);
|
||||
if (IsVarTerm(t)) {
|
||||
@ -598,7 +598,7 @@ static Int p_execution_mode(void) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_performance(void) {
|
||||
static Int p_performance( USES_REGS1 ) {
|
||||
Term t;
|
||||
realtime one_worker_execution_time = 0;
|
||||
int i;
|
||||
@ -672,7 +672,7 @@ static Int p_performance(void) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_parallel_new_answer(void) {
|
||||
static Int p_parallel_new_answer( USES_REGS1 ) {
|
||||
or_fr_ptr leftmost_or_fr;
|
||||
|
||||
length_answer = 0;
|
||||
@ -693,13 +693,13 @@ static Int p_parallel_new_answer(void) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_parallel_yes_answer(void) {
|
||||
static Int p_parallel_yes_answer( USES_REGS1 ) {
|
||||
GLOBAL_answers = YES_ANSWER;
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
static Int p_show_statistics_or(void) {
|
||||
static Int p_show_statistics_or( USES_REGS1 ) {
|
||||
long total_bytes = 0, aux_bytes;
|
||||
|
||||
aux_bytes = 0;
|
||||
@ -733,7 +733,7 @@ static Int p_show_statistics_or(void) {
|
||||
**********************************/
|
||||
|
||||
#if defined(YAPOR) && defined(TABLING)
|
||||
static Int p_show_statistics_opt(void) {
|
||||
static Int p_show_statistics_opt( USES_REGS1 ) {
|
||||
long total_bytes = 0, aux_bytes;
|
||||
|
||||
aux_bytes = 0;
|
||||
@ -783,7 +783,7 @@ static Int p_show_statistics_opt(void) {
|
||||
#endif /* YAPOR && TABLING */
|
||||
|
||||
|
||||
static Int p_get_optyap_statistics(void) {
|
||||
static Int p_get_optyap_statistics( USES_REGS1 ) {
|
||||
Term tbytes, tstructs;
|
||||
Int value, bytes = -1, structs = -1;
|
||||
|
||||
@ -928,6 +928,7 @@ static inline int parallel_new_answer_putchar(int sno, int ch) {
|
||||
|
||||
|
||||
static inline void show_answers(void) {
|
||||
CACHE_REGS
|
||||
int i;
|
||||
if (OrFr_qg_solutions(LOCAL_top_or_fr)) {
|
||||
qg_ans_fr_ptr aux_answer1, aux_answer2;
|
||||
|
@ -23,18 +23,21 @@ typedef unsigned long bitmap;
|
||||
static inline choiceptr
|
||||
offset_to_cptr(Int node)
|
||||
{
|
||||
CACHE_REGS
|
||||
return (choiceptr)(LCL0+node);
|
||||
}
|
||||
|
||||
static inline Int
|
||||
cptr_to_offset(choiceptr node)
|
||||
{
|
||||
CACHE_REGS
|
||||
return (Int)((CELL *)node-LCL0);
|
||||
}
|
||||
|
||||
static inline choiceptr
|
||||
offset_to_cptr_with_null(Int node)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (node == 0L) return NULL;
|
||||
return (choiceptr)(LCL0+node);
|
||||
}
|
||||
@ -42,6 +45,7 @@ offset_to_cptr_with_null(Int node)
|
||||
static inline Int
|
||||
cptr_to_offset_with_null(choiceptr node)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (node == NULL) return 0L;
|
||||
return (Int)((CELL *)node-LCL0);
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
** -------------------------- */
|
||||
|
||||
void prune_shared_branch(choiceptr prune_cp) {
|
||||
CACHE_REGS
|
||||
int i, ltt, depth;
|
||||
bitmap members;
|
||||
choiceptr leftmost_cp;
|
||||
|
@ -284,6 +284,7 @@ void PUT_OUT_REQUESTABLE(int p) {
|
||||
|
||||
static inline
|
||||
void SCH_update_local_or_tops(void) {
|
||||
CACHE_REGS
|
||||
Set_LOCAL_top_cp(Get_LOCAL_top_cp()->cp_b);
|
||||
LOCAL_top_or_fr = Get_LOCAL_top_cp()->cp_or_fr;
|
||||
return;
|
||||
@ -292,6 +293,7 @@ void SCH_update_local_or_tops(void) {
|
||||
|
||||
static inline
|
||||
void SCH_refuse_share_request_if_any(void) {
|
||||
CACHE_REGS
|
||||
if (SCH_any_share_request) {
|
||||
REMOTE_reply_signal(LOCAL_share_request) = no_sharing;
|
||||
LOCAL_share_request = MAX_WORKERS;
|
||||
@ -303,6 +305,7 @@ void SCH_refuse_share_request_if_any(void) {
|
||||
|
||||
static inline
|
||||
void SCH_set_load(choiceptr current_cp) {
|
||||
CACHE_REGS
|
||||
Int lub; /* local untried branches */
|
||||
choiceptr previous_cp = current_cp->cp_b;
|
||||
|
||||
@ -326,6 +329,7 @@ void SCH_set_load(choiceptr current_cp) {
|
||||
|
||||
static inline
|
||||
void SCH_new_alternative(yamop *curpc, yamop *new) {
|
||||
CACHE_REGS
|
||||
OrFr_alternative(LOCAL_top_or_fr) = new;
|
||||
BRANCH(worker_id, OrFr_depth(LOCAL_top_or_fr)) = YAMOP_OR_ARG(curpc);
|
||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
@ -351,6 +355,7 @@ void CUT_send_prune_request(int worker, choiceptr prune_cp) {
|
||||
|
||||
static inline
|
||||
void CUT_reset_prune_request(void) {
|
||||
CACHE_REGS
|
||||
LOCK_WORKER(worker_id);
|
||||
if (Get_LOCAL_prune_request() && EQUAL_OR_YOUNGER_CP(Get_LOCAL_prune_request(), Get_LOCAL_top_cp()))
|
||||
Set_LOCAL_prune_request(NULL);
|
||||
@ -366,6 +371,7 @@ void CUT_reset_prune_request(void) {
|
||||
|
||||
static inline
|
||||
int CUT_last_worker_left_pending_prune(or_fr_ptr or_frame) {
|
||||
CACHE_REGS
|
||||
int i, depth, ltt;
|
||||
bitmap members;
|
||||
|
||||
@ -383,6 +389,7 @@ int CUT_last_worker_left_pending_prune(or_fr_ptr or_frame) {
|
||||
|
||||
static inline
|
||||
or_fr_ptr CUT_leftmost_or_frame(void) {
|
||||
CACHE_REGS
|
||||
int i, depth, ltt;
|
||||
bitmap members;
|
||||
or_fr_ptr leftmost_or_fr, or_fr, nearest_or_fr;
|
||||
@ -496,6 +503,7 @@ or_fr_ptr CUT_leftmost_until(or_fr_ptr start_or_fr, int until_depth) {
|
||||
|
||||
static inline
|
||||
void CUT_store_answer(or_fr_ptr or_frame, qg_ans_fr_ptr new_answer) {
|
||||
CACHE_REGS
|
||||
int ltt;
|
||||
qg_sol_fr_ptr *solution_ptr;
|
||||
|
||||
@ -522,6 +530,7 @@ void CUT_store_answer(or_fr_ptr or_frame, qg_ans_fr_ptr new_answer) {
|
||||
|
||||
static inline
|
||||
void CUT_store_answers(or_fr_ptr or_frame, qg_sol_fr_ptr new_solution) {
|
||||
CACHE_REGS
|
||||
int ltt;
|
||||
qg_sol_fr_ptr *solution_ptr;
|
||||
|
||||
|
@ -52,6 +52,7 @@ STD_PROTO(static inline void move_up_to_prune_request, (void));
|
||||
|
||||
static inline
|
||||
void PUT_NO_WORK_IN_UPPER_NODES(void) {
|
||||
CACHE_REGS
|
||||
or_fr_ptr current_node, nearest_livenode;
|
||||
current_node = LOCAL_top_or_fr;
|
||||
while ((nearest_livenode = OrFr_nearest_livenode(current_node))) {
|
||||
@ -100,6 +101,7 @@ void PUT_OUT_ROOT_NODE(int worker_num) {
|
||||
|
||||
static inline
|
||||
void move_up_to_prune_request(void) {
|
||||
CACHE_REGS
|
||||
YAPOR_ERROR_CHECKING(move_up_to_prune_request, EQUAL_OR_YOUNGER_CP(Get_LOCAL_prune_request(), Get_LOCAL_top_cp()));
|
||||
|
||||
do {
|
||||
@ -140,6 +142,7 @@ void move_up_to_prune_request(void) {
|
||||
** -------------------------- */
|
||||
|
||||
int get_work(void) {
|
||||
CACHE_REGS
|
||||
int counter;
|
||||
bitmap stable_busy;
|
||||
yamop *alt_with_work;
|
||||
@ -265,6 +268,7 @@ int get_work(void) {
|
||||
|
||||
static
|
||||
int move_up_one_node(or_fr_ptr nearest_livenode) {
|
||||
CACHE_REGS
|
||||
YAPOR_ERROR_CHECKING(move_up_one_node, Get_LOCAL_prune_request() && EQUAL_OR_YOUNGER_CP(Get_LOCAL_prune_request(), Get_LOCAL_top_cp()));
|
||||
|
||||
LOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
@ -519,6 +523,7 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
|
||||
|
||||
static
|
||||
int get_work_below(void){
|
||||
CACHE_REGS
|
||||
int i, worker_p, big_load;
|
||||
bitmap busy_below, idle_below;
|
||||
|
||||
@ -548,6 +553,7 @@ int get_work_below(void){
|
||||
|
||||
static
|
||||
int get_work_above(void){
|
||||
CACHE_REGS
|
||||
int i, worker_p, big_load;
|
||||
bitmap visible_busy_above, visible_idle_above;
|
||||
|
||||
@ -601,6 +607,7 @@ int get_work_above(void){
|
||||
|
||||
static
|
||||
int find_a_better_position(void){
|
||||
CACHE_REGS
|
||||
int i;
|
||||
bitmap busy_above, idle_above;
|
||||
BITMAP_difference(busy_above, GLOBAL_bm_present_workers, OrFr_members(LOCAL_top_or_fr));
|
||||
@ -630,6 +637,7 @@ int find_a_better_position(void){
|
||||
|
||||
static
|
||||
int search_for_hidden_shared_work(bitmap stable_busy){
|
||||
CACHE_REGS
|
||||
int i;
|
||||
bitmap invisible_work, idle_below;
|
||||
BITMAP_intersection(invisible_work, stable_busy, GLOBAL_bm_requestable_workers);
|
||||
|
@ -56,6 +56,7 @@ static void share_private_nodes(int worker_q);
|
||||
** -------------------------- */
|
||||
|
||||
void make_root_choice_point(void) {
|
||||
CACHE_REGS
|
||||
if (worker_id == 0) {
|
||||
SetOrFr_node(GLOBAL_root_or_fr, B);
|
||||
Set_LOCAL_top_cp(B);
|
||||
@ -96,6 +97,7 @@ void make_root_choice_point(void) {
|
||||
|
||||
|
||||
void free_root_choice_point(void) {
|
||||
CACHE_REGS
|
||||
B = Get_LOCAL_top_cp()->cp_b;
|
||||
#ifdef TABLING
|
||||
Set_LOCAL_top_cp_on_stack((choiceptr) Yap_LocalBase);
|
||||
@ -107,7 +109,8 @@ void free_root_choice_point(void) {
|
||||
}
|
||||
|
||||
|
||||
int p_share_work(void) {
|
||||
int p_share_work() {
|
||||
CACHE_REGS
|
||||
int worker_q = LOCAL_share_request;
|
||||
|
||||
if (! BITMAP_member(OrFr_members(REMOTE_top_or_fr(worker_q)), worker_id) ||
|
||||
@ -140,6 +143,7 @@ int p_share_work(void) {
|
||||
}
|
||||
|
||||
int q_share_work(int worker_p) {
|
||||
CACHE_REGS
|
||||
LOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
if (Get_REMOTE_prune_request(worker_p)) {
|
||||
/* worker p with prune request */
|
||||
@ -200,6 +204,7 @@ int q_share_work(int worker_p) {
|
||||
|
||||
static
|
||||
void share_private_nodes(int worker_q) {
|
||||
CACHE_REGS
|
||||
choiceptr sharing_node = B;
|
||||
|
||||
|
||||
|
@ -104,6 +104,7 @@ static void complete_suspension_branch(susp_fr_ptr susp_fr, choiceptr top_cp, or
|
||||
*******************************/
|
||||
|
||||
void private_completion(sg_fr_ptr sg_fr) {
|
||||
CACHE_REGS
|
||||
/* complete subgoals */
|
||||
#ifdef LIMIT_TABLING
|
||||
sg_fr_ptr aux_sg_fr;
|
||||
@ -142,6 +143,7 @@ void private_completion(sg_fr_ptr sg_fr) {
|
||||
|
||||
#ifdef YAPOR
|
||||
void public_completion(void) {
|
||||
CACHE_REGS
|
||||
dep_fr_ptr chain_dep_fr, next_dep_fr;
|
||||
or_fr_ptr chain_or_fr, top_or_fr, next_or_fr;
|
||||
susp_fr_ptr susp_fr, next_susp_fr;
|
||||
@ -265,6 +267,7 @@ void public_completion(void) {
|
||||
|
||||
|
||||
void complete_suspension_frames(or_fr_ptr or_fr) {
|
||||
CACHE_REGS
|
||||
dep_fr_ptr chain_dep_fr;
|
||||
or_fr_ptr chain_or_fr;
|
||||
susp_fr_ptr susp_fr;
|
||||
@ -318,6 +321,7 @@ void complete_suspension_frames(or_fr_ptr or_fr) {
|
||||
|
||||
|
||||
void suspend_branch(void) {
|
||||
CACHE_REGS
|
||||
or_fr_ptr or_frame;
|
||||
|
||||
/* suspension only occurs in shared nodes that **
|
||||
@ -394,6 +398,7 @@ void suspend_branch(void) {
|
||||
|
||||
|
||||
void resume_suspension_frame(susp_fr_ptr resume_fr, or_fr_ptr top_or_fr) {
|
||||
CACHE_REGS
|
||||
or_fr_ptr or_frame;
|
||||
sg_fr_ptr sg_frame;
|
||||
|
||||
|
@ -427,6 +427,7 @@ static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames(tg_sol_fr_ptr, int);
|
||||
******************************/
|
||||
|
||||
static inline Int freeze_current_cp(void) {
|
||||
CACHE_REGS
|
||||
choiceptr freeze_cp = B;
|
||||
|
||||
B_FZ = freeze_cp;
|
||||
@ -439,6 +440,7 @@ static inline Int freeze_current_cp(void) {
|
||||
|
||||
|
||||
static inline void wake_frozen_cp(Int frozen_offset) {
|
||||
CACHE_REGS
|
||||
choiceptr frozen_cp = (choiceptr)(Yap_LocalBase - frozen_offset);
|
||||
|
||||
restore_bindings(TR, frozen_cp->cp_tr);
|
||||
@ -450,6 +452,7 @@ static inline void wake_frozen_cp(Int frozen_offset) {
|
||||
|
||||
|
||||
static inline void abolish_frozen_cps_until(Int frozen_offset) {
|
||||
CACHE_REGS
|
||||
choiceptr frozen_cp = (choiceptr)(Yap_LocalBase - frozen_offset);
|
||||
|
||||
B_FZ = frozen_cp;
|
||||
@ -460,6 +463,7 @@ static inline void abolish_frozen_cps_until(Int frozen_offset) {
|
||||
|
||||
|
||||
static inline void abolish_frozen_cps_all(void) {
|
||||
CACHE_REGS
|
||||
B_FZ = (choiceptr) Yap_LocalBase;
|
||||
H_FZ = (CELL *) Yap_GlobalBase;
|
||||
TR_FZ = (tr_fr_ptr) Yap_TrailBase;
|
||||
@ -468,6 +472,7 @@ static inline void abolish_frozen_cps_all(void) {
|
||||
|
||||
|
||||
static inline void adjust_freeze_registers(void) {
|
||||
CACHE_REGS
|
||||
B_FZ = DepFr_cons_cp(LOCAL_top_dep_fr);
|
||||
H_FZ = B_FZ->cp_h;
|
||||
TR_FZ = B_FZ->cp_tr;
|
||||
@ -484,6 +489,7 @@ static inline void mark_as_completed(sg_fr_ptr sg_fr) {
|
||||
|
||||
|
||||
static inline void unbind_variables(tr_fr_ptr unbind_tr, tr_fr_ptr end_tr) {
|
||||
CACHE_REGS
|
||||
TABLING_ERROR_CHECKING(unbind_variables, unbind_tr < end_tr);
|
||||
/* unbind loop */
|
||||
while (unbind_tr != end_tr) {
|
||||
@ -514,6 +520,7 @@ static inline void unbind_variables(tr_fr_ptr unbind_tr, tr_fr_ptr end_tr) {
|
||||
|
||||
|
||||
static inline void rebind_variables(tr_fr_ptr rebind_tr, tr_fr_ptr end_tr) {
|
||||
CACHE_REGS
|
||||
TABLING_ERROR_CHECKING(rebind_variables, rebind_tr < end_tr);
|
||||
/* rebind loop */
|
||||
Yap_NEW_MAHASH((ma_h_inner_struct *)H);
|
||||
@ -547,6 +554,7 @@ static inline void rebind_variables(tr_fr_ptr rebind_tr, tr_fr_ptr end_tr) {
|
||||
|
||||
|
||||
static inline void restore_bindings(tr_fr_ptr unbind_tr, tr_fr_ptr rebind_tr) {
|
||||
CACHE_REGS
|
||||
CELL ref;
|
||||
tr_fr_ptr end_tr;
|
||||
|
||||
@ -620,6 +628,7 @@ static inline void restore_bindings(tr_fr_ptr unbind_tr, tr_fr_ptr rebind_tr) {
|
||||
|
||||
|
||||
static inline CELL *expand_auxiliary_stack(CELL *stack) {
|
||||
CACHE_REGS
|
||||
void *old_top = Yap_TrailTop;
|
||||
INFORMATION_MESSAGE("Expanding trail in 64 Kbytes");
|
||||
if (! Yap_growtrail(K64, TRUE)) { /* TRUE means 'contiguous_only' */
|
||||
@ -635,6 +644,7 @@ static inline CELL *expand_auxiliary_stack(CELL *stack) {
|
||||
|
||||
|
||||
static inline void abolish_incomplete_subgoals(choiceptr prune_cp) {
|
||||
CACHE_REGS
|
||||
#ifdef YAPOR
|
||||
if (EQUAL_OR_YOUNGER_CP(GetOrFr_node(LOCAL_top_susp_or_fr), prune_cp))
|
||||
pruning_over_tabling_data_structures();
|
||||
@ -708,6 +718,7 @@ static inline void pruning_over_tabling_data_structures(void) {
|
||||
|
||||
|
||||
static inline void collect_suspension_frames(or_fr_ptr or_fr) {
|
||||
CACHE_REGS
|
||||
int depth;
|
||||
or_fr_ptr *susp_ptr;
|
||||
|
||||
|
@ -221,6 +221,7 @@ static inline CELL *exec_substitution_loop(gt_node_ptr current_node, CELL **stac
|
||||
Yap_TrailTop --> | | <-- stack_terms_base (TRIE_COMPACT_PAIRS)
|
||||
-----------
|
||||
************************************************************************/
|
||||
CACHE_REGS
|
||||
CELL *stack_vars = *stack_vars_ptr;
|
||||
CELL *stack_terms_limit = (CELL *) TR;
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
@ -973,6 +974,7 @@ static inline void traverse_update_arity(char *str, int *str_index_ptr, int *ari
|
||||
*******************************/
|
||||
|
||||
sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
|
||||
CACHE_REGS
|
||||
CELL *stack_vars;
|
||||
int i, subs_arity, pred_arity;
|
||||
tab_ent_ptr tab_ent;
|
||||
@ -1035,6 +1037,7 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
|
||||
|
||||
ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
||||
#define subs_arity *subs_ptr
|
||||
CACHE_REGS
|
||||
CELL *stack_vars;
|
||||
int i, vars_arity;
|
||||
ans_node_ptr current_ans_node;
|
||||
@ -1067,6 +1070,7 @@ ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
||||
|
||||
|
||||
void load_answer(ans_node_ptr current_ans_node, CELL *subs_ptr) {
|
||||
CACHE_REGS
|
||||
#define subs_arity *subs_ptr
|
||||
CELL *stack_terms;
|
||||
int i;
|
||||
@ -1089,6 +1093,7 @@ void load_answer(ans_node_ptr current_ans_node, CELL *subs_ptr) {
|
||||
|
||||
|
||||
CELL *exec_substitution(gt_node_ptr current_node, CELL *aux_stack) {
|
||||
CACHE_REGS
|
||||
#define subs_arity *subs_ptr
|
||||
CELL *stack_terms, *subs_ptr;
|
||||
Term t;
|
||||
|
@ -829,6 +829,7 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
|
||||
Yap_TrailTop --> | |
|
||||
-----------
|
||||
************************************************************************/
|
||||
CACHE_REGS
|
||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||
gt_node_ptr current_node = GLOBAL_root_gt;
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||
@ -1032,6 +1033,7 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
|
||||
Yap_TrailTop --> | |
|
||||
-----------
|
||||
************************************************************************/
|
||||
CACHE_REGS
|
||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||
gt_node_ptr current_node = GLOBAL_root_gt;
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||
@ -1243,6 +1245,7 @@ static inline CELL *load_answer_loop(ans_node_ptr current_node) {
|
||||
Yap_TrailTop --> | | <-- stack_terms_base (TRIE_COMPACT_PAIRS)
|
||||
-----------
|
||||
************************************************************************/
|
||||
CACHE_REGS
|
||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||
int vars_arity = *vars_arity_ptr;
|
||||
#else
|
||||
|
@ -34,7 +34,8 @@ static PL_blob_t unregistered_blob_atom =
|
||||
PL_EXPORT(int)
|
||||
PL_is_blob(term_t t, PL_blob_t **type)
|
||||
{
|
||||
Term yt = Yap_GetFromSlot(t);
|
||||
CACHE_REGS
|
||||
Term yt = Yap_GetFromSlot(t PASS_REGS);
|
||||
Atom a;
|
||||
BlobPropEntry *b;
|
||||
|
||||
@ -88,6 +89,7 @@ lookupBlob(void *blob, size_t len, PL_blob_t *type)
|
||||
PL_EXPORT(int)
|
||||
PL_unify_blob(term_t t, void *blob, size_t len, PL_blob_t *type)
|
||||
{
|
||||
CACHE_REGS
|
||||
AtomEntry *ae;
|
||||
|
||||
if (!blob)
|
||||
@ -96,7 +98,7 @@ PL_unify_blob(term_t t, void *blob, size_t len, PL_blob_t *type)
|
||||
if (!ae) {
|
||||
return FALSE;
|
||||
}
|
||||
return Yap_unify(Yap_GetFromSlot(t), MkAtomTerm(AbsAtom(ae)));
|
||||
return Yap_unify(Yap_GetFromSlot(t PASS_REGS), MkAtomTerm(AbsAtom(ae)));
|
||||
}
|
||||
|
||||
PL_EXPORT(int)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -98,6 +98,7 @@ SWIAtomToAtom(atom_t at)
|
||||
static inline Term
|
||||
SWIModuleToModule(module_t m)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (m)
|
||||
return (CELL)m;
|
||||
if (CurrentModule)
|
||||
|
@ -145,7 +145,7 @@ gen_hstruct(Inp,Out) :-
|
||||
Out = "#include \"ratoms.h\"".
|
||||
gen_hstruct(Inp,Out) :-
|
||||
Inp = "START_WORKER_LOCAL", !,
|
||||
Out = "static void RestoreWorker(int wid) {",
|
||||
Out = "static void RestoreWorker(int wid USES_REGS) {",
|
||||
assert(globals(worker_init)).
|
||||
gen_hstruct(Inp,Out) :-
|
||||
Inp = "END_WORKER_LOCAL", !,
|
||||
|
@ -77,7 +77,7 @@ header(W) :-
|
||||
header_rclause(W) :-
|
||||
format(W,'~n /* This file was generated automatically by \"yap -L misc/buildops\"~n please do not update */~n~n
|
||||
static void
|
||||
restore_opcodes(yamop *pc, yamop *max)
|
||||
restore_opcodes(yamop *pc, yamop *max USES_REGS)
|
||||
{
|
||||
yamop *opc = NULL;
|
||||
do {
|
||||
@ -369,11 +369,11 @@ output_walk(C,"e",[Op|Ops]) :-
|
||||
special_walk_op(Op), !, % Nstop and friends
|
||||
output_ewalks(C,[Op|Ops]).
|
||||
output_walk(C,"sssllp",[Op|Ops]) :-
|
||||
format(C,' return found_expand_index(pc, startp, endp, codeptr);~n',[]),
|
||||
format(C,' return found_expand_index(pc, startp, endp, codeptr PASS_REGS);~n',[]),
|
||||
output_ewalks(C,[Op|Ops]).
|
||||
output_walk(C,"l",[Op|_]) :-
|
||||
special_walk_op(Op), !, % IDB
|
||||
format(C,' return found_ystop(pc, clause_code, startp, endp, pp);~n',[]).
|
||||
format(C,' return found_ystop(pc, clause_code, startp, endp, pp PASS_REGS);~n',[]).
|
||||
output_walk(C,T,_) :-
|
||||
format(C,' pc = NEXTOP(pc,~s);
|
||||
break;~n',[T]).
|
||||
@ -391,29 +391,29 @@ output_ewalks(C,["copy_idb_term"|Ops]) :-
|
||||
format(C,' return found_idb_clause(pc, startp, endp);~n',[]),
|
||||
output_ewalks(C,Ops).
|
||||
output_ewalks(C,["undef_p"|Ops]) :-
|
||||
format(C,' return found_owner_op(pc, startp, endp);~n',[]),
|
||||
format(C,' return found_owner_op(pc, startp, endp PASS_REGS);~n',[]),
|
||||
output_ewalks(C,Ops).
|
||||
output_ewalks(C,["spy_pred"|Ops]) :-
|
||||
format(C,' return found_owner_op(pc, startp, endp);~n',[]),
|
||||
format(C,' return found_owner_op(pc, startp, endp PASS_REGS);~n',[]),
|
||||
output_ewalks(C,Ops).
|
||||
output_ewalks(C,["expand_index"|Ops]) :-
|
||||
format(C,' return found_expand(pc, startp, endp);~n',[]),
|
||||
format(C,' return found_expand(pc, startp, endp PASS_REGS);~n',[]),
|
||||
output_ewalks(C,Ops).
|
||||
output_ewalks(C,["index_pred"|Ops]) :-
|
||||
format(C,' return found_owner_op(pc, startp, endp);~n',[]),
|
||||
format(C,' return found_owner_op(pc, startp, endp PASS_REGS);~n',[]),
|
||||
output_ewalks(C,Ops).
|
||||
output_ewalks(C,["lock_pred"|Ops]) :-
|
||||
format(C,' return found_owner_op(pc, startp, endp);~n',[]),
|
||||
format(C,' return found_owner_op(pc, startp, endp PASS_REGS);~n',[]),
|
||||
output_ewalks(C,Ops).
|
||||
output_ewalks(C,["op_fail"|Ops]) :-
|
||||
format(C,' if (codeptr == FAILCODE)
|
||||
return found_fail(pc, startp, endp);~n',[]),
|
||||
return found_fail(pc, startp, endp PASS_REGS);~n',[]),
|
||||
format(C,' pc = NEXTOP(pc,~s);
|
||||
break;~n',["e"]),
|
||||
output_ewalks(C,Ops).
|
||||
output_ewalks(C,["trust_fail"|Ops]) :-
|
||||
format(C,' if (codeptr == TRUSTFAILCODE)
|
||||
return found_fail(pc, startp, endp);~n',[]),
|
||||
return found_fail(pc, startp, endp PASS_REGS);~n',[]),
|
||||
format(C,' pc = NEXTOP(pc,~s);
|
||||
break;~n',["e"]),
|
||||
output_ewalks(C,Ops).
|
||||
|
@ -251,22 +251,22 @@ extern PL_local_data_t lds;
|
||||
|
||||
#define GLOBAL_LD (PL_local_data_p)
|
||||
|
||||
#undef LD
|
||||
|
||||
#if !defined(O_PLMT) && !defined(YAPOR)
|
||||
#define LOCAL_LD (PL_local_data_p)
|
||||
#define LOCAL_LD (GLOBAL_LD)
|
||||
#define LD (GLOBAL_LD)
|
||||
#define ARG1_LD void
|
||||
#define ARG_LD
|
||||
#define GET_LD
|
||||
#define PRED_LD
|
||||
#define PASS_LD
|
||||
#define PASS_LD1
|
||||
|
||||
#else
|
||||
|
||||
#define LOCAL_LD (__PL_ld)
|
||||
#define LD LOCAL_LD
|
||||
|
||||
#define GET_LD PL_local_data_t *__PL_ld = GLOBAL_LD;
|
||||
#define GET_LD CACHE_REGS PL_local_data_t *__PL_ld = GLOBAL_LD;
|
||||
#define ARG1_LD PL_local_data_t *__PL_ld
|
||||
|
||||
#define ARG_LD , ARG1_LD
|
||||
|
@ -33,6 +33,7 @@
|
||||
/* vsc: needs defining before getting rid of YAP locks */
|
||||
static inline int
|
||||
do_startCritical(void) {
|
||||
CACHE_REGS
|
||||
YAPEnterCriticalSection();
|
||||
return 1;
|
||||
}
|
||||
|
@ -833,7 +833,8 @@ PL_dispatch(int fd, int wait)
|
||||
YAP: YAP_Atom YAP_AtomOfTerm(Term) */
|
||||
int PL_get_atom__LD(term_t ts, atom_t *a ARG_LD)
|
||||
{
|
||||
YAP_Term t = Yap_GetFromSlot(ts);
|
||||
CACHE_REGS
|
||||
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
|
||||
if ( !IsAtomTerm(t))
|
||||
return 0;
|
||||
*a = YAP_SWIAtomFromAtom(AtomOfTerm(t));
|
||||
@ -842,33 +843,38 @@ int PL_get_atom__LD(term_t ts, atom_t *a ARG_LD)
|
||||
|
||||
void PL_put_term__LD(term_t d, term_t s ARG_LD)
|
||||
{
|
||||
Yap_PutInSlot(d,Yap_GetFromSlot(s));
|
||||
CACHE_REGS
|
||||
Yap_PutInSlot(d,Yap_GetFromSlot(s PASS_REGS) PASS_REGS);
|
||||
}
|
||||
|
||||
term_t PL_new_term_ref__LD(ARG1_LD)
|
||||
{
|
||||
term_t to = Yap_NewSlots(1);
|
||||
CACHE_REGS
|
||||
term_t to = Yap_NewSlots(1 PASS_REGS);
|
||||
return to;
|
||||
}
|
||||
|
||||
int PL_is_variable__LD(term_t ts ARG_LD)
|
||||
{
|
||||
YAP_Term t = Yap_GetFromSlot(ts);
|
||||
CACHE_REGS
|
||||
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
|
||||
return YAP_IsVarTerm(t);
|
||||
}
|
||||
|
||||
int PL_unify_atom__LD(term_t t, atom_t at ARG_LD)
|
||||
{
|
||||
CACHE_REGS
|
||||
YAP_Term cterm = MkAtomTerm(YAP_AtomFromSWIAtom(at));
|
||||
return YAP_Unify(Yap_GetFromSlot(t),cterm);
|
||||
return YAP_Unify(Yap_GetFromSlot(t PASS_REGS),cterm);
|
||||
}
|
||||
|
||||
/* SWI: int PL_unify_integer(term_t ?t, long n)
|
||||
YAP long int unify(YAP_Term* a, Term* b) */
|
||||
int PL_unify_integer__LD(term_t t, long n ARG_LD)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term iterm = MkIntegerTerm(n);
|
||||
return Yap_unify(Yap_GetFromSlot(t),iterm);
|
||||
return Yap_unify(Yap_GetFromSlot(t PASS_REGS),iterm);
|
||||
}
|
||||
|
||||
extern int Yap_getInputStream(term_t t, IOSTREAM **s);
|
||||
|
@ -238,6 +238,7 @@ true :- true.
|
||||
% then we can execute the programs.
|
||||
'$startup_goals' :-
|
||||
recorded('$startup_goal',G,_),
|
||||
writeln(G),
|
||||
'$current_module'(Module),
|
||||
'$system_catch'('$query'(once(G), []),Module,Error,user:'$Error'(Error)),
|
||||
fail.
|
||||
|
Reference in New Issue
Block a user