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 IN_ABSMI_C 1
|
||||||
|
#define HAS_CACHE_REGS 1
|
||||||
|
|
||||||
#include "absmi.h"
|
#include "absmi.h"
|
||||||
#include "heapgc.h"
|
#include "heapgc.h"
|
||||||
@ -542,6 +543,7 @@ creep_allowed(PredEntry *p, PredEntry *p0)
|
|||||||
static Term
|
static Term
|
||||||
push_live_regs(yamop *pco)
|
push_live_regs(yamop *pco)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
CELL *lab = (CELL *)(pco->u.l.l);
|
CELL *lab = (CELL *)(pco->u.l.l);
|
||||||
CELL max = lab[0];
|
CELL max = lab[0];
|
||||||
CELL curr = lab[1];
|
CELL curr = lab[1];
|
||||||
@ -610,6 +612,7 @@ char *Yap_op_names[_std_top + 1] =
|
|||||||
Int
|
Int
|
||||||
Yap_absmi(int inp)
|
Yap_absmi(int inp)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
#if BP_FREE
|
#if BP_FREE
|
||||||
/* some function might be using bp for an internal variable, it is the
|
/* some function might be using bp for an internal variable, it is the
|
||||||
callee's responsability to save it */
|
callee's responsability to save it */
|
||||||
@ -688,7 +691,11 @@ Yap_absmi(int inp)
|
|||||||
#if PUSH_REGS
|
#if PUSH_REGS
|
||||||
old_regs = &Yap_REGS;
|
old_regs = &Yap_REGS;
|
||||||
init_absmi_regs(&absmi_regs);
|
init_absmi_regs(&absmi_regs);
|
||||||
|
#if THREADS
|
||||||
|
regcache = Yap_regp
|
||||||
|
#else
|
||||||
Yap_regp = &absmi_regs;
|
Yap_regp = &absmi_regs;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
CACHE_A1();
|
CACHE_A1();
|
||||||
PREG=bpEntry->CodeOfPred;
|
PREG=bpEntry->CodeOfPred;
|
||||||
@ -719,6 +726,7 @@ Yap_absmi(int inp)
|
|||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
pthread_setspecific(Yap_yaamregs_key, (const void *)&absmi_regs);
|
pthread_setspecific(Yap_yaamregs_key, (const void *)&absmi_regs);
|
||||||
MY_ThreadHandle.current_yaam_regs = &absmi_regs;
|
MY_ThreadHandle.current_yaam_regs = &absmi_regs;
|
||||||
|
regcache = &absmi_regs;
|
||||||
#else
|
#else
|
||||||
Yap_regp = &absmi_regs;
|
Yap_regp = &absmi_regs;
|
||||||
#endif
|
#endif
|
||||||
@ -7480,7 +7488,7 @@ Yap_absmi(int inp)
|
|||||||
CPredicate f = PREG->u.Osbpp.p->cs.f_code;
|
CPredicate f = PREG->u.Osbpp.p->cs.f_code;
|
||||||
PREG = NEXTOP(PREG, Osbpp);
|
PREG = NEXTOP(PREG, Osbpp);
|
||||||
saveregs();
|
saveregs();
|
||||||
d0 = (f)();
|
d0 = (f)(PASS_REGS1);
|
||||||
setregs();
|
setregs();
|
||||||
#ifdef SHADOW_S
|
#ifdef SHADOW_S
|
||||||
SREG = Yap_REGS.S_;
|
SREG = Yap_REGS.S_;
|
||||||
@ -7548,7 +7556,7 @@ Yap_absmi(int inp)
|
|||||||
CPredicate f = PREG->u.pp.p->cs.f_code;
|
CPredicate f = PREG->u.pp.p->cs.f_code;
|
||||||
yamop *oldPREG = PREG;
|
yamop *oldPREG = PREG;
|
||||||
saveregs();
|
saveregs();
|
||||||
d0 = (f)();
|
d0 = (f)(PASS_REGS1);
|
||||||
setregs();
|
setregs();
|
||||||
#ifdef SHADOW_S
|
#ifdef SHADOW_S
|
||||||
SREG = Yap_REGS.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 */
|
/* make sure that we can still have access to our old PREG after calling user defined goals and backtracking or failing */
|
||||||
yamop *savedP;
|
yamop *savedP;
|
||||||
|
|
||||||
Yap_StartSlots();
|
Yap_StartSlots( PASS_REGS1 );
|
||||||
Yap_PrologMode = UserCCallMode;
|
Yap_PrologMode = UserCCallMode;
|
||||||
{
|
{
|
||||||
PredEntry *p = PREG->u.Osbpp.p;
|
PredEntry *p = PREG->u.Osbpp.p;
|
||||||
@ -7619,7 +7627,7 @@ Yap_absmi(int inp)
|
|||||||
|
|
||||||
SREG = (CELL *) YAP_Execute(p, p->cs.f_code);
|
SREG = (CELL *) YAP_Execute(p, p->cs.f_code);
|
||||||
}
|
}
|
||||||
Yap_CloseSlots();
|
Yap_CloseSlots( PASS_REGS1 );
|
||||||
setregs();
|
setregs();
|
||||||
Yap_PrologMode = UserMode;
|
Yap_PrologMode = UserMode;
|
||||||
restore_machine_regs();
|
restore_machine_regs();
|
||||||
@ -7673,7 +7681,7 @@ Yap_absmi(int inp)
|
|||||||
{
|
{
|
||||||
CPredicate f = PREG->u.slp.p->cs.f_code;
|
CPredicate f = PREG->u.slp.p->cs.f_code;
|
||||||
saveregs();
|
saveregs();
|
||||||
SREG = (CELL *)((f)());
|
SREG = (CELL *)((f)(PASS_REGS1));
|
||||||
setregs();
|
setregs();
|
||||||
}
|
}
|
||||||
if (!SREG) {
|
if (!SREG) {
|
||||||
@ -7711,7 +7719,7 @@ Yap_absmi(int inp)
|
|||||||
{
|
{
|
||||||
CPredicate f = (CPredicate)(PREG->u.OtapFs.f);
|
CPredicate f = (CPredicate)(PREG->u.OtapFs.f);
|
||||||
saveregs();
|
saveregs();
|
||||||
SREG = (CELL *) ((f) ());
|
SREG = (CELL *) ((f) (PASS_REGS1));
|
||||||
/* This last instruction changes B B*/
|
/* This last instruction changes B B*/
|
||||||
#ifdef CUT_C
|
#ifdef CUT_C
|
||||||
while (POP_CHOICE_POINT(B)){
|
while (POP_CHOICE_POINT(B)){
|
||||||
@ -7792,7 +7800,7 @@ Yap_absmi(int inp)
|
|||||||
Yap_PrologMode = UserCCallMode;
|
Yap_PrologMode = UserCCallMode;
|
||||||
ASP = YREG;
|
ASP = YREG;
|
||||||
/* for slots to work */
|
/* for slots to work */
|
||||||
Yap_StartSlots();
|
Yap_StartSlots( PASS_REGS1 );
|
||||||
saveregs();
|
saveregs();
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
SREG = (CELL *) YAP_ExecuteFirst(PREG->u.OtapFs.p, (CPredicate)(PREG->u.OtapFs.f));
|
SREG = (CELL *) YAP_ExecuteFirst(PREG->u.OtapFs.p, (CPredicate)(PREG->u.OtapFs.f));
|
||||||
@ -7800,7 +7808,7 @@ Yap_absmi(int inp)
|
|||||||
restore_machine_regs();
|
restore_machine_regs();
|
||||||
setregs();
|
setregs();
|
||||||
Yap_PrologMode = UserMode;
|
Yap_PrologMode = UserMode;
|
||||||
Yap_CloseSlots();
|
Yap_CloseSlots( PASS_REGS1 );
|
||||||
if (!SREG) {
|
if (!SREG) {
|
||||||
FAIL();
|
FAIL();
|
||||||
}
|
}
|
||||||
@ -7835,7 +7843,7 @@ Yap_absmi(int inp)
|
|||||||
Yap_PrologMode = UserCCallMode;
|
Yap_PrologMode = UserCCallMode;
|
||||||
SET_ASP(YREG, E_CB*sizeof(CELL));
|
SET_ASP(YREG, E_CB*sizeof(CELL));
|
||||||
/* for slots to work */
|
/* for slots to work */
|
||||||
Yap_StartSlots();
|
Yap_StartSlots( PASS_REGS1 );
|
||||||
saveregs();
|
saveregs();
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
SREG = (CELL *) YAP_ExecuteNext(PREG->u.OtapFs.p, (CPredicate)(PREG->u.OtapFs.f));
|
SREG = (CELL *) YAP_ExecuteNext(PREG->u.OtapFs.p, (CPredicate)(PREG->u.OtapFs.f));
|
||||||
@ -7843,7 +7851,7 @@ Yap_absmi(int inp)
|
|||||||
restore_machine_regs();
|
restore_machine_regs();
|
||||||
setregs();
|
setregs();
|
||||||
Yap_PrologMode = UserMode;
|
Yap_PrologMode = UserMode;
|
||||||
Yap_CloseSlots();
|
Yap_CloseSlots( PASS_REGS1 );
|
||||||
if (!SREG) {
|
if (!SREG) {
|
||||||
#ifdef CUT_C
|
#ifdef CUT_C
|
||||||
/* Removes the cut functions from the stack
|
/* Removes the cut functions from the stack
|
||||||
@ -7959,7 +7967,7 @@ Yap_absmi(int inp)
|
|||||||
BOp(thread_local, e);
|
BOp(thread_local, e);
|
||||||
{
|
{
|
||||||
PredEntry *ap = PredFromDefCode(PREG);
|
PredEntry *ap = PredFromDefCode(PREG);
|
||||||
ap = Yap_GetThreadPred(ap);
|
ap = Yap_GetThreadPred(ap PASS_REGS);
|
||||||
PREG = ap->CodeOfPred;
|
PREG = ap->CodeOfPred;
|
||||||
/* for profiler */
|
/* for profiler */
|
||||||
save_pc();
|
save_pc();
|
||||||
|
37
C/adtdefs.c
37
C/adtdefs.c
@ -489,7 +489,7 @@ Yap_HasOp(Atom a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
OpEntry *
|
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 */
|
{ /* look property list of atom a for kind */
|
||||||
AtomEntry *ae = RepAtom(a);
|
AtomEntry *ae = RepAtom(a);
|
||||||
PropEntry *pp;
|
PropEntry *pp;
|
||||||
@ -546,7 +546,7 @@ GetPredPropByAtomHavingLock(AtomEntry* ae, Term cur_mod)
|
|||||||
#if THREADS
|
#if THREADS
|
||||||
/* Thread Local Predicates */
|
/* Thread Local Predicates */
|
||||||
if (pe->PredFlags & ThreadLocalPredFlag) {
|
if (pe->PredFlags & ThreadLocalPredFlag) {
|
||||||
return AbsPredProp(Yap_GetThreadPred(pe));
|
return AbsPredProp(Yap_GetThreadPred(pe INIT_REGS));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -582,7 +582,7 @@ GetPredPropByAtomHavingLockInThisModule(AtomEntry* ae, Term cur_mod)
|
|||||||
#if THREADS
|
#if THREADS
|
||||||
/* Thread Local Predicates */
|
/* Thread Local Predicates */
|
||||||
if (pe->PredFlags & ThreadLocalPredFlag) {
|
if (pe->PredFlags & ThreadLocalPredFlag) {
|
||||||
return AbsPredProp(Yap_GetThreadPred(pe));
|
return AbsPredProp(Yap_GetThreadPred(pe INIT_REGS));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return(p0);
|
return(p0);
|
||||||
@ -808,7 +808,7 @@ Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod)
|
|||||||
|
|
||||||
#if THREADS
|
#if THREADS
|
||||||
Prop
|
Prop
|
||||||
Yap_NewThreadPred(PredEntry *ap)
|
Yap_NewThreadPred(PredEntry *ap USES_REGS)
|
||||||
{
|
{
|
||||||
PredEntry *p = (PredEntry *) Yap_AllocAtomSpace(sizeof(*p));
|
PredEntry *p = (PredEntry *) Yap_AllocAtomSpace(sizeof(*p));
|
||||||
|
|
||||||
@ -1121,6 +1121,7 @@ Yap_PutValue(Atom a, Term v)
|
|||||||
Term
|
Term
|
||||||
Yap_StringToList(char *s)
|
Yap_StringToList(char *s)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
register Term t;
|
register Term t;
|
||||||
register unsigned char *cp = (unsigned char *)s + strlen(s);
|
register unsigned char *cp = (unsigned char *)s + strlen(s);
|
||||||
|
|
||||||
@ -1134,6 +1135,7 @@ Yap_StringToList(char *s)
|
|||||||
Term
|
Term
|
||||||
Yap_NStringToList(char *s, size_t len)
|
Yap_NStringToList(char *s, size_t len)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term t;
|
Term t;
|
||||||
unsigned char *cp = (unsigned char *)s + len;
|
unsigned char *cp = (unsigned char *)s + len;
|
||||||
|
|
||||||
@ -1147,6 +1149,7 @@ Yap_NStringToList(char *s, size_t len)
|
|||||||
Term
|
Term
|
||||||
Yap_WideStringToList(wchar_t *s)
|
Yap_WideStringToList(wchar_t *s)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term t;
|
Term t;
|
||||||
wchar_t *cp = s + wcslen(s);
|
wchar_t *cp = s + wcslen(s);
|
||||||
|
|
||||||
@ -1160,6 +1163,7 @@ Yap_WideStringToList(wchar_t *s)
|
|||||||
Term
|
Term
|
||||||
Yap_NWideStringToList(wchar_t *s, size_t len)
|
Yap_NWideStringToList(wchar_t *s, size_t len)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term t;
|
Term t;
|
||||||
wchar_t *cp = s + len;
|
wchar_t *cp = s + len;
|
||||||
|
|
||||||
@ -1171,7 +1175,7 @@ Yap_NWideStringToList(wchar_t *s, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Term
|
Term
|
||||||
Yap_StringToDiffList(char *s, Term t)
|
Yap_StringToDiffList(char *s, Term t USES_REGS)
|
||||||
{
|
{
|
||||||
register unsigned char *cp = (unsigned char *)s + strlen(s);
|
register unsigned char *cp = (unsigned char *)s + strlen(s);
|
||||||
|
|
||||||
@ -1187,6 +1191,7 @@ Yap_StringToDiffList(char *s, Term t)
|
|||||||
Term
|
Term
|
||||||
Yap_NStringToDiffList(char *s, Term t, size_t len)
|
Yap_NStringToDiffList(char *s, Term t, size_t len)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
register unsigned char *cp = (unsigned char *)s + len;
|
register unsigned char *cp = (unsigned char *)s + len;
|
||||||
|
|
||||||
t = Yap_Globalise(t);
|
t = Yap_Globalise(t);
|
||||||
@ -1199,6 +1204,7 @@ Yap_NStringToDiffList(char *s, Term t, size_t len)
|
|||||||
Term
|
Term
|
||||||
Yap_WideStringToDiffList(wchar_t *s, Term t)
|
Yap_WideStringToDiffList(wchar_t *s, Term t)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
wchar_t *cp = s + wcslen(s);
|
wchar_t *cp = s + wcslen(s);
|
||||||
|
|
||||||
t = Yap_Globalise(t);
|
t = Yap_Globalise(t);
|
||||||
@ -1211,6 +1217,7 @@ Yap_WideStringToDiffList(wchar_t *s, Term t)
|
|||||||
Term
|
Term
|
||||||
Yap_NWideStringToDiffList(wchar_t *s, Term t, size_t len)
|
Yap_NWideStringToDiffList(wchar_t *s, Term t, size_t len)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
wchar_t *cp = s + len;
|
wchar_t *cp = s + len;
|
||||||
|
|
||||||
t = Yap_Globalise(t);
|
t = Yap_Globalise(t);
|
||||||
@ -1223,6 +1230,7 @@ Yap_NWideStringToDiffList(wchar_t *s, Term t, size_t len)
|
|||||||
Term
|
Term
|
||||||
Yap_StringToListOfAtoms(char *s)
|
Yap_StringToListOfAtoms(char *s)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
register Term t;
|
register Term t;
|
||||||
char so[2];
|
char so[2];
|
||||||
register unsigned char *cp = (unsigned char *)s + strlen(s);
|
register unsigned char *cp = (unsigned char *)s + strlen(s);
|
||||||
@ -1239,6 +1247,7 @@ Yap_StringToListOfAtoms(char *s)
|
|||||||
Term
|
Term
|
||||||
Yap_NStringToListOfAtoms(char *s, size_t len)
|
Yap_NStringToListOfAtoms(char *s, size_t len)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
register Term t;
|
register Term t;
|
||||||
char so[2];
|
char so[2];
|
||||||
register unsigned char *cp = (unsigned char *)s + len;
|
register unsigned char *cp = (unsigned char *)s + len;
|
||||||
@ -1255,6 +1264,7 @@ Yap_NStringToListOfAtoms(char *s, size_t len)
|
|||||||
Term
|
Term
|
||||||
Yap_WideStringToListOfAtoms(wchar_t *s)
|
Yap_WideStringToListOfAtoms(wchar_t *s)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
register Term t;
|
register Term t;
|
||||||
wchar_t so[2];
|
wchar_t so[2];
|
||||||
wchar_t *cp = s + wcslen(s);
|
wchar_t *cp = s + wcslen(s);
|
||||||
@ -1271,6 +1281,7 @@ Yap_WideStringToListOfAtoms(wchar_t *s)
|
|||||||
Term
|
Term
|
||||||
Yap_NWideStringToListOfAtoms(wchar_t *s, size_t len)
|
Yap_NWideStringToListOfAtoms(wchar_t *s, size_t len)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
register Term t;
|
register Term t;
|
||||||
wchar_t so[2];
|
wchar_t so[2];
|
||||||
wchar_t *cp = s + len;
|
wchar_t *cp = s + len;
|
||||||
@ -1287,6 +1298,7 @@ Yap_NWideStringToListOfAtoms(wchar_t *s, size_t len)
|
|||||||
Term
|
Term
|
||||||
Yap_NWideStringToDiffListOfAtoms(wchar_t *s, Term t0, size_t len)
|
Yap_NWideStringToDiffListOfAtoms(wchar_t *s, Term t0, size_t len)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
register Term t;
|
register Term t;
|
||||||
wchar_t so[2];
|
wchar_t so[2];
|
||||||
wchar_t *cp = s + len;
|
wchar_t *cp = s + len;
|
||||||
@ -1303,6 +1315,7 @@ Yap_NWideStringToDiffListOfAtoms(wchar_t *s, Term t0, size_t len)
|
|||||||
Term
|
Term
|
||||||
Yap_ArrayToList(register Term *tp, int nof)
|
Yap_ArrayToList(register Term *tp, int nof)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
register Term *pt = tp + nof;
|
register Term *pt = tp + nof;
|
||||||
register Term t;
|
register Term t;
|
||||||
|
|
||||||
@ -1379,7 +1392,7 @@ ArgsOfSFTerm(Term t)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Int
|
Int
|
||||||
Yap_NewSlots(int n)
|
Yap_NewSlots(int n USES_REGS)
|
||||||
{
|
{
|
||||||
Int old_slots = IntOfTerm(ASP[0]), oldn = n;
|
Int old_slots = IntOfTerm(ASP[0]), oldn = n;
|
||||||
while (n > 0) {
|
while (n > 0) {
|
||||||
@ -1393,7 +1406,7 @@ Yap_NewSlots(int n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Int
|
Int
|
||||||
Yap_InitSlot(Term t)
|
Yap_InitSlot(Term t USES_REGS)
|
||||||
{
|
{
|
||||||
Int old_slots = IntOfTerm(ASP[0]);
|
Int old_slots = IntOfTerm(ASP[0]);
|
||||||
*ASP = t;
|
*ASP = t;
|
||||||
@ -1404,7 +1417,7 @@ Yap_InitSlot(Term t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Yap_RecoverSlots(int n)
|
Yap_RecoverSlots(int n USES_REGS)
|
||||||
{
|
{
|
||||||
Int old_slots = IntOfTerm(ASP[0]);
|
Int old_slots = IntOfTerm(ASP[0]);
|
||||||
if (old_slots - n < 0) {
|
if (old_slots - n < 0) {
|
||||||
@ -1417,25 +1430,25 @@ Yap_RecoverSlots(int n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Term
|
Term
|
||||||
Yap_GetFromSlot(Int slot)
|
Yap_GetFromSlot(Int slot USES_REGS)
|
||||||
{
|
{
|
||||||
return(Deref(LCL0[slot]));
|
return(Deref(LCL0[slot]));
|
||||||
}
|
}
|
||||||
|
|
||||||
Term
|
Term
|
||||||
Yap_GetPtrFromSlot(Int slot)
|
Yap_GetPtrFromSlot(Int slot USES_REGS)
|
||||||
{
|
{
|
||||||
return(LCL0[slot]);
|
return(LCL0[slot]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Term *
|
Term *
|
||||||
Yap_AddressFromSlot(Int slot)
|
Yap_AddressFromSlot(Int slot USES_REGS)
|
||||||
{
|
{
|
||||||
return(LCL0+slot);
|
return(LCL0+slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Yap_PutInSlot(Int slot, Term t)
|
Yap_PutInSlot(Int slot, Term t USES_REGS)
|
||||||
{
|
{
|
||||||
LCL0[slot] = t;
|
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
|
#define errout Yap_stderr
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC_PROTO(void RestoreEntries, (PropEntry *, int));
|
STATIC_PROTO(void RestoreEntries, (PropEntry *, int USES_REGS));
|
||||||
STATIC_PROTO(void CleanCode, (PredEntry *));
|
STATIC_PROTO(void CleanCode, (PredEntry * USES_REGS));
|
||||||
|
|
||||||
static int agc_calls;
|
static int agc_calls;
|
||||||
|
|
||||||
@ -112,8 +112,6 @@ AtomAdjust(Atom a)
|
|||||||
return(a);
|
return(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Term AdjustDBTerm(Term, Term *);
|
|
||||||
|
|
||||||
#define IsOldCode(P) FALSE
|
#define IsOldCode(P) FALSE
|
||||||
#define IsOldCodeCellPtr(P) FALSE
|
#define IsOldCodeCellPtr(P) FALSE
|
||||||
#define IsOldDelay(P) FALSE
|
#define IsOldDelay(P) FALSE
|
||||||
@ -201,10 +199,8 @@ static Term AdjustDBTerm(Term, Term *);
|
|||||||
|
|
||||||
#include "rheap.h"
|
#include "rheap.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreHashPreds(void)
|
RestoreHashPreds( USES_REGS1 )
|
||||||
{
|
{
|
||||||
UInt i;
|
UInt i;
|
||||||
|
|
||||||
@ -219,14 +215,14 @@ RestoreHashPreds(void)
|
|||||||
if (p->NextOfPE)
|
if (p->NextOfPE)
|
||||||
p->NextOfPE = PropAdjust(p->NextOfPE);
|
p->NextOfPE = PropAdjust(p->NextOfPE);
|
||||||
nextp = p->NextOfPE;
|
nextp = p->NextOfPE;
|
||||||
CleanCode(p);
|
CleanCode(p PASS_REGS);
|
||||||
p = RepPredProp(nextp);
|
p = RepPredProp(nextp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void init_reg_copies(void)
|
static void init_reg_copies(USES_REGS1)
|
||||||
{
|
{
|
||||||
OldASP = ASP;
|
OldASP = ASP;
|
||||||
OldLCL0 = LCL0;
|
OldLCL0 = LCL0;
|
||||||
@ -242,7 +238,7 @@ static void init_reg_copies(void)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreAtomList(Atom atm)
|
RestoreAtomList(Atom atm USES_REGS)
|
||||||
{
|
{
|
||||||
AtomEntry *at;
|
AtomEntry *at;
|
||||||
|
|
||||||
@ -250,7 +246,7 @@ RestoreAtomList(Atom atm)
|
|||||||
if (EndOfPAEntr(at))
|
if (EndOfPAEntr(at))
|
||||||
return;
|
return;
|
||||||
do {
|
do {
|
||||||
RestoreAtom(atm);
|
RestoreAtom(atm PASS_REGS);
|
||||||
atm = CleanAtomMarkedBit(at->NextOfAE);
|
atm = CleanAtomMarkedBit(at->NextOfAE);
|
||||||
at = RepAtom(atm);
|
at = RepAtom(atm);
|
||||||
} while (!EndOfPAEntr(at));
|
} while (!EndOfPAEntr(at));
|
||||||
@ -259,7 +255,7 @@ RestoreAtomList(Atom atm)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mark_trail(void)
|
mark_trail(USES_REGS1)
|
||||||
{
|
{
|
||||||
register tr_fr_ptr pt;
|
register tr_fr_ptr pt;
|
||||||
|
|
||||||
@ -279,7 +275,7 @@ mark_trail(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mark_registers(void)
|
mark_registers(USES_REGS1)
|
||||||
{
|
{
|
||||||
CELL *pt;
|
CELL *pt;
|
||||||
|
|
||||||
@ -297,7 +293,7 @@ mark_registers(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mark_local(void)
|
mark_local(USES_REGS1)
|
||||||
{
|
{
|
||||||
CELL *pt;
|
CELL *pt;
|
||||||
|
|
||||||
@ -355,7 +351,7 @@ mark_global_cell(CELL *pt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mark_global(void)
|
mark_global(USES_REGS1)
|
||||||
{
|
{
|
||||||
CELL *pt;
|
CELL *pt;
|
||||||
|
|
||||||
@ -370,12 +366,12 @@ mark_global(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mark_stacks(void)
|
mark_stacks(USES_REGS1)
|
||||||
{
|
{
|
||||||
mark_registers();
|
mark_registers(PASS_REGS1);
|
||||||
mark_trail();
|
mark_trail(PASS_REGS1);
|
||||||
mark_local();
|
mark_local(PASS_REGS1);
|
||||||
mark_global();
|
mark_global(PASS_REGS1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -433,7 +429,7 @@ clean_atoms(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
atom_gc(void)
|
atom_gc(USES_REGS1)
|
||||||
{
|
{
|
||||||
int gc_verbose = Yap_is_gc_verbose();
|
int gc_verbose = Yap_is_gc_verbose();
|
||||||
int gc_trace = 0;
|
int gc_trace = 0;
|
||||||
@ -457,8 +453,8 @@ atom_gc(void)
|
|||||||
time_start = Yap_cputime();
|
time_start = Yap_cputime();
|
||||||
/* get the number of active registers */
|
/* get the number of active registers */
|
||||||
YAPEnterCriticalSection();
|
YAPEnterCriticalSection();
|
||||||
init_reg_copies();
|
init_reg_copies(PASS_REGS1);
|
||||||
mark_stacks();
|
mark_stacks(PASS_REGS1);
|
||||||
restore_codes();
|
restore_codes();
|
||||||
clean_atoms();
|
clean_atoms();
|
||||||
AGcLastCall = NOfAtoms;
|
AGcLastCall = NOfAtoms;
|
||||||
@ -477,22 +473,22 @@ atom_gc(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Yap_atom_gc(void)
|
Yap_atom_gc(USES_REGS1)
|
||||||
{
|
{
|
||||||
atom_gc();
|
atom_gc(PASS_REGS1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_atom_gc(void)
|
p_atom_gc(USES_REGS1)
|
||||||
{
|
{
|
||||||
#ifndef FIXED_STACKS
|
#ifndef FIXED_STACKS
|
||||||
atom_gc();
|
atom_gc(PASS_REGS1);
|
||||||
#endif /* FIXED_STACKS */
|
#endif /* FIXED_STACKS */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_inform_agc(void)
|
p_inform_agc(USES_REGS1)
|
||||||
{
|
{
|
||||||
Term tn = MkIntegerTerm(tot_agc_time);
|
Term tn = MkIntegerTerm(tot_agc_time);
|
||||||
Term tt = MkIntegerTerm(agc_calls);
|
Term tt = MkIntegerTerm(agc_calls);
|
||||||
@ -505,7 +501,7 @@ p_inform_agc(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_agc_threshold(void)
|
p_agc_threshold(USES_REGS1)
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
|
@ -240,6 +240,7 @@ Yap_FreeAtomSpace(char *p)
|
|||||||
ADDR
|
ADDR
|
||||||
Yap_InitPreAllocCodeSpace(void)
|
Yap_InitPreAllocCodeSpace(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
char *ptr;
|
char *ptr;
|
||||||
UInt sz = ScratchPad.msz;
|
UInt sz = ScratchPad.msz;
|
||||||
if (ScratchPad.ptr == NULL) {
|
if (ScratchPad.ptr == NULL) {
|
||||||
@ -287,6 +288,7 @@ Yap_InitPreAllocCodeSpace(void)
|
|||||||
ADDR
|
ADDR
|
||||||
Yap_ExpandPreAllocCodeSpace(UInt sz0, void *cip, int safe)
|
Yap_ExpandPreAllocCodeSpace(UInt sz0, void *cip, int safe)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
char *ptr;
|
char *ptr;
|
||||||
UInt sz = ScratchPad.msz;
|
UInt sz = ScratchPad.msz;
|
||||||
if (sz0 < SCRATCH_INC_SIZE)
|
if (sz0 < SCRATCH_INC_SIZE)
|
||||||
@ -331,6 +333,7 @@ struct various_codes *Yap_heap_regs;
|
|||||||
static void
|
static void
|
||||||
InitHeap(void)
|
InitHeap(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Yap_heap_regs = (struct various_codes *)calloc(1, sizeof(struct various_codes));
|
Yap_heap_regs = (struct various_codes *)calloc(1, sizeof(struct various_codes));
|
||||||
#if defined(YAPOR) || defined(TABLING)
|
#if defined(YAPOR) || defined(TABLING)
|
||||||
LOCAL = REMOTE; /* point to the first area */
|
LOCAL = REMOTE; /* point to the first area */
|
||||||
@ -348,6 +351,7 @@ Yap_InitHeap(void *heap_addr)
|
|||||||
static void
|
static void
|
||||||
InitExStacks(int Trail, int Stack)
|
InitExStacks(int Trail, int Stack)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
UInt pm, sa;
|
UInt pm, sa;
|
||||||
|
|
||||||
/* sanity checking for data areas */
|
/* sanity checking for data areas */
|
||||||
@ -421,6 +425,7 @@ Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack)
|
|||||||
int
|
int
|
||||||
Yap_ExtendWorkSpace(Int s)
|
Yap_ExtendWorkSpace(Int s)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
void *basebp = (void *)Yap_GlobalBase, *nbp;
|
void *basebp = (void *)Yap_GlobalBase, *nbp;
|
||||||
UInt s0 = (char *)Yap_TrailTop-(char *)Yap_GlobalBase;
|
UInt s0 = (char *)Yap_TrailTop-(char *)Yap_GlobalBase;
|
||||||
nbp = realloc(basebp, s+s0);
|
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_try, (op_numbers, CELL, CELL, yamop *, int, struct intermediates *));
|
||||||
STATIC_PROTO(yamop *a_either, (op_numbers, CELL, CELL, yamop *, int, struct intermediates *));
|
STATIC_PROTO(yamop *a_either, (op_numbers, CELL, CELL, yamop *, int, struct intermediates *));
|
||||||
#endif /* YAPOR */
|
#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(yamop *a_bfunc, (CELL, clause_info *, yamop *, int, struct intermediates *));
|
||||||
STATIC_PROTO(
|
STATIC_PROTO(
|
||||||
COUNT compile_cmp_flags, (char *));
|
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_ucons, (int *, compiler_vm_op, yamop *, int, struct intermediates *));
|
||||||
STATIC_PROTO(yamop *a_uvar, (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 *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
|
#ifdef DEBUG_OPCODES
|
||||||
STATIC_PROTO(void DumpOpCodes, (void));
|
STATIC_PROTO(void DumpOpCodes, (void));
|
||||||
#endif
|
#endif
|
||||||
@ -2193,7 +2193,7 @@ a_either(op_numbers opcode, CELL opr, CELL lab, yamop *code_p, int pass_no, stru
|
|||||||
}
|
}
|
||||||
|
|
||||||
static yamop *
|
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
|
#ifdef YAPOR
|
||||||
return a_try(opcode, cpc->rnd1, IPredArity, cpc->rnd2 >> 1, cpc->rnd2 & 1, code_p, pass_no, cip);
|
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 */
|
#endif /* YAPOR */
|
||||||
|
|
||||||
static yamop *
|
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
|
#ifdef YAPOR
|
||||||
#define MAX_DISJ_BRANCHES 256
|
#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);
|
code_p = a_n(_table_new_answer, (int) cip->cpc->rnd2, code_p, pass_no);
|
||||||
break;
|
break;
|
||||||
case table_try_single_op:
|
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;
|
break;
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
#ifdef TABLING_INNER_CUTS
|
#ifdef TABLING_INNER_CUTS
|
||||||
@ -3451,10 +3451,10 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
|||||||
}
|
}
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
if (tabled)
|
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
|
else
|
||||||
#endif
|
#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;
|
break;
|
||||||
case retry_op:
|
case retry_op:
|
||||||
if (log_update) {
|
if (log_update) {
|
||||||
@ -3462,10 +3462,10 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
|||||||
}
|
}
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
if (tabled)
|
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
|
else
|
||||||
#endif
|
#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;
|
break;
|
||||||
case trust_op:
|
case trust_op:
|
||||||
if (log_update) {
|
if (log_update) {
|
||||||
@ -3473,10 +3473,10 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
|||||||
}
|
}
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
if (tabled)
|
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
|
else
|
||||||
#endif
|
#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;
|
break;
|
||||||
case try_in_op:
|
case try_in_op:
|
||||||
code_p = a_il(cip->cpc->rnd1, _try_in, code_p, pass_no, cip);
|
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 *
|
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;
|
CELL *h0 = H;
|
||||||
DBTerm *x;
|
DBTerm *x;
|
||||||
@ -3848,6 +3848,7 @@ init_dbterms_list(yamop *code_p, PredEntry *ap)
|
|||||||
yamop *
|
yamop *
|
||||||
Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates *cip, UInt max_label)
|
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
|
* the assembly proccess is done in two passes: 1 - a first pass
|
||||||
* computes labels offsets and total code size 2 - the second 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;
|
cip->label_offset = (Int *)cip->freep;
|
||||||
#endif
|
#endif
|
||||||
cip->code_addr = NULL;
|
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) {
|
if (clause_has_dbterm) {
|
||||||
cip->dbterml = init_dbterms_list(code_p, ap);
|
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;
|
LogUpdClause *cl;
|
||||||
UInt osize;
|
UInt osize;
|
||||||
|
|
||||||
if(!(x = fetch_clause_space(&t,size,cip,&osize))){
|
if(!(x = fetch_clause_space(&t, size, cip, &osize PASS_REGS))){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
cl = (LogUpdClause *)((CODEADDR)x-(UInt)size);
|
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;
|
DBTerm *x;
|
||||||
StaticClause *cl;
|
StaticClause *cl;
|
||||||
UInt osize;
|
UInt osize;
|
||||||
if(!(x = fetch_clause_space(&t,size,cip,&osize))) {
|
if(!(x = fetch_clause_space(&t, size, cip, &osize PASS_REGS))) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
cl = (StaticClause *)((CODEADDR)x-(UInt)size);
|
cl = (StaticClause *)((CODEADDR)x-(UInt)size);
|
||||||
cip->code_addr = (yamop *)cl;
|
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 */
|
/* make sure we copy after second pass */
|
||||||
cl->usc.ClSource = x;
|
cl->usc.ClSource = x;
|
||||||
cl->ClSize = osize;
|
cl->ClSize = osize;
|
||||||
@ -3946,7 +3947,7 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
|||||||
Yap_IndexSpace_Tree += size;
|
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;
|
ProfEnd=code_p;
|
||||||
#ifdef LOW_PROF
|
#ifdef LOW_PROF
|
||||||
if (ProfilerOn &&
|
if (ProfilerOn &&
|
||||||
|
@ -56,6 +56,7 @@ static char SccsId[] = "%W% %G%";
|
|||||||
|
|
||||||
static Term
|
static Term
|
||||||
eval0(Int fi) {
|
eval0(Int fi) {
|
||||||
|
CACHE_REGS
|
||||||
arith0_op fop = fi;
|
arith0_op fop = fi;
|
||||||
switch (fop) {
|
switch (fop) {
|
||||||
case op_pi:
|
case op_pi:
|
||||||
|
@ -745,7 +745,7 @@ static InitUnEntry InitUnTab[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_unary_is(void)
|
p_unary_is( USES_REGS1 )
|
||||||
{ /* X is Y */
|
{ /* X is Y */
|
||||||
Term t = Deref(ARG2);
|
Term t = Deref(ARG2);
|
||||||
Term top;
|
Term top;
|
||||||
@ -790,7 +790,7 @@ p_unary_is(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_unary_op_as_integer(void)
|
p_unary_op_as_integer( USES_REGS1 )
|
||||||
{ /* X is Y */
|
{ /* X is Y */
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
|
38
C/arith2.c
38
C/arith2.c
@ -1050,7 +1050,7 @@ static InitBinEntry InitBinTab[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_binary_is(void)
|
p_binary_is( USES_REGS1 )
|
||||||
{ /* X is Y */
|
{ /* X is Y */
|
||||||
Term t = Deref(ARG2);
|
Term t = Deref(ARG2);
|
||||||
Term t1, t2;
|
Term t1, t2;
|
||||||
@ -1099,7 +1099,7 @@ p_binary_is(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
do_arith23(arith2_op op)
|
do_arith23(arith2_op op USES_REGS)
|
||||||
{ /* X is Y */
|
{ /* X is Y */
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Int out;
|
Int out;
|
||||||
@ -1121,55 +1121,55 @@ do_arith23(arith2_op op)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
export_p_plus(void)
|
export_p_plus( USES_REGS1 )
|
||||||
{ /* X is Y */
|
{ /* X is Y */
|
||||||
return do_arith23(op_plus);
|
return do_arith23(op_plus PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
export_p_minus(void)
|
export_p_minus( USES_REGS1 )
|
||||||
{ /* X is Y */
|
{ /* X is Y */
|
||||||
return do_arith23(op_minus);
|
return do_arith23(op_minus PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
export_p_times(void)
|
export_p_times( USES_REGS1 )
|
||||||
{ /* X is Y */
|
{ /* X is Y */
|
||||||
return do_arith23(op_times);
|
return do_arith23(op_times PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
export_p_div(void)
|
export_p_div( USES_REGS1 )
|
||||||
{ /* X is Y */
|
{ /* X is Y */
|
||||||
return do_arith23(op_div);
|
return do_arith23(op_div PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
export_p_and(void)
|
export_p_and( USES_REGS1 )
|
||||||
{ /* X is Y */
|
{ /* X is Y */
|
||||||
return do_arith23(op_and);
|
return do_arith23(op_and PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
export_p_or(void)
|
export_p_or( USES_REGS1 )
|
||||||
{ /* X is Y */
|
{ /* X is Y */
|
||||||
return do_arith23(op_or);
|
return do_arith23(op_or PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
export_p_slr(void)
|
export_p_slr( USES_REGS1 )
|
||||||
{ /* X is Y */
|
{ /* X is Y */
|
||||||
return do_arith23(op_slr);
|
return do_arith23(op_slr PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
export_p_sll(void)
|
export_p_sll( USES_REGS1 )
|
||||||
{ /* X is Y */
|
{ /* X is Y */
|
||||||
return do_arith23(op_sll);
|
return do_arith23(op_sll PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_binary_op_as_integer(void)
|
p_binary_op_as_integer( USES_REGS1 )
|
||||||
{ /* X is Y */
|
{ /* X is Y */
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
|
332
C/arrays.c
332
C/arrays.c
@ -34,9 +34,9 @@ extern int errno;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC_PROTO(Int p_compile_array_refs, (void));
|
STATIC_PROTO(Int p_compile_array_refs, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_array_refs_compiled, (void));
|
STATIC_PROTO(Int p_array_refs_compiled, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_sync_mmapped_arrays, (void));
|
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(Int p_create_array, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(void InitNamedArray, (ArrayEntry *, Int));
|
STATIC_PROTO(Int p_create_mmapped_array, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(void CreateNamedArray, (PropEntry *, Int, AtomEntry *));
|
STATIC_PROTO(Int p_array_references, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(void ResizeStaticArray, (StaticArrayEntry *, Int));
|
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
|
#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
|
#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
|
static Term
|
||||||
GetTermFromArray(DBTerm *ref)
|
GetTermFromArray(DBTerm *ref USES_REGS)
|
||||||
{
|
{
|
||||||
if (ref != NULL) {
|
if (ref != NULL) {
|
||||||
Term TRef;
|
Term TRef;
|
||||||
@ -171,7 +260,7 @@ GetTermFromArray(DBTerm *ref)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
GetNBTerm(live_term *ar, Int indx)
|
GetNBTerm(live_term *ar, Int indx USES_REGS)
|
||||||
{
|
{
|
||||||
/* The object is now in use */
|
/* The object is now in use */
|
||||||
Term livet = ar[indx].tlive;
|
Term livet = ar[indx].tlive;
|
||||||
@ -196,7 +285,7 @@ GetNBTerm(live_term *ar, Int indx)
|
|||||||
livet = termt;
|
livet = termt;
|
||||||
} else {
|
} else {
|
||||||
DBTerm *ref = (DBTerm *)RepAppl(termt);
|
DBTerm *ref = (DBTerm *)RepAppl(termt);
|
||||||
if ((livet = GetTermFromArray(ref)) == TermNil) {
|
if ((livet = GetTermFromArray(ref PASS_REGS)) == TermNil) {
|
||||||
return TermNil;
|
return TermNil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,7 +295,7 @@ GetNBTerm(live_term *ar, Int indx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
AccessNamedArray(Atom a, Int indx)
|
AccessNamedArray(Atom a, Int indx USES_REGS)
|
||||||
{
|
{
|
||||||
AtomEntry *ae = RepAtom(a);
|
AtomEntry *ae = RepAtom(a);
|
||||||
ArrayEntry *pp;
|
ArrayEntry *pp;
|
||||||
@ -332,7 +421,7 @@ AccessNamedArray(Atom a, Int indx)
|
|||||||
case array_of_nb_terms:
|
case array_of_nb_terms:
|
||||||
{
|
{
|
||||||
/* The object is now in use */
|
/* 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);
|
READ_UNLOCK(ptr->ArRWLock);
|
||||||
return out;
|
return out;
|
||||||
@ -343,7 +432,7 @@ AccessNamedArray(Atom a, Int indx)
|
|||||||
DBTerm *ref = ptr->ValueOfVE.terms[indx];
|
DBTerm *ref = ptr->ValueOfVE.terms[indx];
|
||||||
|
|
||||||
READ_UNLOCK(ptr->ArRWLock);
|
READ_UNLOCK(ptr->ArRWLock);
|
||||||
return GetTermFromArray(ref);
|
return GetTermFromArray(ref PASS_REGS);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
READ_UNLOCK(ptr->ArRWLock);
|
READ_UNLOCK(ptr->ArRWLock);
|
||||||
@ -359,7 +448,7 @@ AccessNamedArray(Atom a, Int indx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_access_array(void)
|
p_access_array( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Term ti = Deref(ARG2);
|
Term ti = Deref(ARG2);
|
||||||
@ -389,7 +478,7 @@ p_access_array(void)
|
|||||||
}
|
}
|
||||||
tf = (RepAppl(t))[indx + 1];
|
tf = (RepAppl(t))[indx + 1];
|
||||||
} else if (IsAtomTerm(t)) {
|
} else if (IsAtomTerm(t)) {
|
||||||
tf = AccessNamedArray(AtomOfTerm(t), indx);
|
tf = AccessNamedArray(AtomOfTerm(t), indx PASS_REGS);
|
||||||
if (tf == MkAtomTerm(AtomFoundVar)) {
|
if (tf == MkAtomTerm(AtomFoundVar)) {
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
@ -405,7 +494,7 @@ p_access_array(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_array_arg(void)
|
p_array_arg( USES_REGS1 )
|
||||||
{
|
{
|
||||||
register Term ti = Deref(ARG3), t;
|
register Term ti = Deref(ARG3), t;
|
||||||
register Int indx;
|
register Int indx;
|
||||||
@ -430,7 +519,7 @@ p_array_arg(void)
|
|||||||
return (Yap_unify(((RepAppl(t))[indx + 1]), ARG1));
|
return (Yap_unify(((RepAppl(t))[indx + 1]), ARG1));
|
||||||
}
|
}
|
||||||
else if (IsAtomTerm(t)) {
|
else if (IsAtomTerm(t)) {
|
||||||
Term tf = AccessNamedArray(AtomOfTerm(t), indx);
|
Term tf = AccessNamedArray(AtomOfTerm(t), indx PASS_REGS);
|
||||||
if (tf == MkAtomTerm(AtomFoundVar)) {
|
if (tf == MkAtomTerm(AtomFoundVar)) {
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
@ -447,7 +536,7 @@ p_array_arg(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
InitNamedArray(ArrayEntry * p, Int dim)
|
InitNamedArray(ArrayEntry * p, Int dim USES_REGS)
|
||||||
{
|
{
|
||||||
Term *tp;
|
Term *tp;
|
||||||
|
|
||||||
@ -470,7 +559,7 @@ InitNamedArray(ArrayEntry * p, Int dim)
|
|||||||
|
|
||||||
/* we assume the atom ae is already locked */
|
/* we assume the atom ae is already locked */
|
||||||
static void
|
static void
|
||||||
CreateNamedArray(PropEntry * pp, Int dim, AtomEntry *ae)
|
CreateNamedArray(PropEntry * pp, Int dim, AtomEntry *ae USES_REGS)
|
||||||
{
|
{
|
||||||
ArrayEntry *p;
|
ArrayEntry *p;
|
||||||
|
|
||||||
@ -484,12 +573,12 @@ CreateNamedArray(PropEntry * pp, Int dim, AtomEntry *ae)
|
|||||||
#endif
|
#endif
|
||||||
p->NextAE = DynamicArrays;
|
p->NextAE = DynamicArrays;
|
||||||
DynamicArrays = p;
|
DynamicArrays = p;
|
||||||
InitNamedArray(p, dim);
|
InitNamedArray(p, dim PASS_REGS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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;
|
Int asize = 0;
|
||||||
switch (atype) {
|
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 */
|
/* ae and p are assumed to be locked, if they exist */
|
||||||
static StaticArrayEntry *
|
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)) {
|
if (EndOfPAEntr(p)) {
|
||||||
while ((p = (StaticArrayEntry *) Yap_AllocAtomSpace(sizeof(*p))) == NULL) {
|
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) {
|
if (start_addr == NULL) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
AllocateStaticArraySpace(p, type, dim);
|
AllocateStaticArraySpace(p, type, dim PASS_REGS);
|
||||||
if (p->ValueOfVE.ints == NULL) {
|
if (p->ValueOfVE.ints == NULL) {
|
||||||
WRITE_UNLOCK(p->ArRWLock);
|
WRITE_UNLOCK(p->ArRWLock);
|
||||||
return p;
|
return p;
|
||||||
@ -602,7 +691,7 @@ CreateStaticArray(AtomEntry *ae, Int dim, static_array_types type, CODEADDR star
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ResizeStaticArray(StaticArrayEntry *pp, Int dim)
|
ResizeStaticArray(StaticArrayEntry *pp, Int dim USES_REGS)
|
||||||
{
|
{
|
||||||
statarray_elements old_v = pp->ValueOfVE;
|
statarray_elements old_v = pp->ValueOfVE;
|
||||||
static_array_types type = pp->ArrayType;
|
static_array_types type = pp->ArrayType;
|
||||||
@ -618,12 +707,12 @@ ResizeStaticArray(StaticArrayEntry *pp, Int dim)
|
|||||||
#if HAVE_MMAP
|
#if HAVE_MMAP
|
||||||
if (pp->ValueOfVE.chars < (char *)Yap_HeapBase ||
|
if (pp->ValueOfVE.chars < (char *)Yap_HeapBase ||
|
||||||
pp->ValueOfVE.chars > (char *)HeapTop) {
|
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);
|
WRITE_UNLOCK(pp->ArRWLock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
AllocateStaticArraySpace(pp, type, dim);
|
AllocateStaticArraySpace(pp, type, dim PASS_REGS);
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case array_of_ints:
|
case array_of_ints:
|
||||||
for (i = 0; i <mindim; i++)
|
for (i = 0; i <mindim; i++)
|
||||||
@ -779,7 +868,7 @@ ClearStaticArray(StaticArrayEntry *pp)
|
|||||||
|
|
||||||
/* create an array (?Name, + Size) */
|
/* create an array (?Name, + Size) */
|
||||||
static Int
|
static Int
|
||||||
p_create_array(void)
|
p_create_array( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term ti;
|
Term ti;
|
||||||
Term t;
|
Term t;
|
||||||
@ -852,7 +941,7 @@ p_create_array(void)
|
|||||||
} else
|
} else
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
CreateNamedArray(pp, size, ae);
|
CreateNamedArray(pp, size, ae PASS_REGS);
|
||||||
WRITE_UNLOCK(ae->ARWLock);
|
WRITE_UNLOCK(ae->ARWLock);
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
} else {
|
} else {
|
||||||
@ -874,7 +963,7 @@ p_create_array(void)
|
|||||||
} else
|
} else
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
InitNamedArray(app, size);
|
InitNamedArray(app, size PASS_REGS);
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -884,7 +973,7 @@ p_create_array(void)
|
|||||||
|
|
||||||
/* create an array (+Name, + Size, +Props) */
|
/* create an array (+Name, + Size, +Props) */
|
||||||
static Int
|
static Int
|
||||||
p_create_static_array(void)
|
p_create_static_array( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term ti = Deref(ARG2);
|
Term ti = Deref(ARG2);
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
@ -955,7 +1044,7 @@ p_create_static_array(void)
|
|||||||
|
|
||||||
app = (ArrayEntry *) pp;
|
app = (ArrayEntry *) pp;
|
||||||
if (EndOfPAEntr(pp) || pp->ValueOfVE.ints == NULL) {
|
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) {
|
if (pp == NULL || pp->ValueOfVE.ints == NULL) {
|
||||||
WRITE_UNLOCK(ae->ARWLock);
|
WRITE_UNLOCK(ae->ARWLock);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -964,7 +1053,7 @@ p_create_static_array(void)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (ArrayIsDynamic(app)) {
|
} else if (ArrayIsDynamic(app)) {
|
||||||
if (IsVarTerm(app->ValueOfVE) && IsUnboundVar(&app->ValueOfVE)) {
|
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);
|
WRITE_UNLOCK(ae->ARWLock);
|
||||||
if (pp == NULL) {
|
if (pp == NULL) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -992,7 +1081,7 @@ p_create_static_array(void)
|
|||||||
|
|
||||||
/* has a static array associated (+Name) */
|
/* has a static array associated (+Name) */
|
||||||
static Int
|
static Int
|
||||||
p_static_array_properties(void)
|
p_static_array_properties( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
@ -1046,7 +1135,7 @@ p_static_array_properties(void)
|
|||||||
/* resize a static array (+Name, + Size, +Props) */
|
/* resize a static array (+Name, + Size, +Props) */
|
||||||
/* does not work for mmap arrays yet */
|
/* does not work for mmap arrays yet */
|
||||||
static Int
|
static Int
|
||||||
p_resize_static_array(void)
|
p_resize_static_array( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term ti = Deref(ARG3);
|
Term ti = Deref(ARG3);
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
@ -1082,7 +1171,7 @@ p_resize_static_array(void)
|
|||||||
return(FALSE);
|
return(FALSE);
|
||||||
} else {
|
} else {
|
||||||
Int osize = - pp->ArrayEArity;
|
Int osize = - pp->ArrayEArity;
|
||||||
ResizeStaticArray(pp, size);
|
ResizeStaticArray(pp, size PASS_REGS);
|
||||||
return(Yap_unify(ARG2,MkIntegerTerm(osize)));
|
return(Yap_unify(ARG2,MkIntegerTerm(osize)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1094,7 +1183,7 @@ p_resize_static_array(void)
|
|||||||
/* resize a static array (+Name, + Size, +Props) */
|
/* resize a static array (+Name, + Size, +Props) */
|
||||||
/* does not work for mmap arrays yet */
|
/* does not work for mmap arrays yet */
|
||||||
static Int
|
static Int
|
||||||
p_clear_static_array(void)
|
p_clear_static_array( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
@ -1124,7 +1213,7 @@ p_clear_static_array(void)
|
|||||||
|
|
||||||
/* Close a named array (+Name) */
|
/* Close a named array (+Name) */
|
||||||
static Int
|
static Int
|
||||||
p_close_static_array(void)
|
p_close_static_array( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/* does not work for mmap arrays yet */
|
/* does not work for mmap arrays yet */
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
@ -1151,7 +1240,7 @@ p_close_static_array(void)
|
|||||||
#if HAVE_MMAP
|
#if HAVE_MMAP
|
||||||
if (ptr->ValueOfVE.chars < (char *)Yap_HeapBase ||
|
if (ptr->ValueOfVE.chars < (char *)Yap_HeapBase ||
|
||||||
ptr->ValueOfVE.chars > (char *)HeapTop) {
|
ptr->ValueOfVE.chars > (char *)HeapTop) {
|
||||||
return(CloseMmappedArray(ptr, (void *)ptr->ValueOfVE.chars));
|
return(CloseMmappedArray(ptr, (void *)ptr->ValueOfVE.chars PASS_REGS));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Yap_FreeAtomSpace((char *)(ptr->ValueOfVE.ints));
|
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) */
|
/* create an array (+Name, + Size, +Props) */
|
||||||
static Int
|
static Int
|
||||||
p_create_mmapped_array(void)
|
p_create_mmapped_array( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#ifdef HAVE_MMAP
|
#ifdef HAVE_MMAP
|
||||||
Term ti = Deref(ARG2);
|
Term ti = Deref(ARG2);
|
||||||
@ -1382,7 +1370,7 @@ p_create_mmapped_array(void)
|
|||||||
} else {
|
} else {
|
||||||
WRITE_LOCK(pp->ArRWLock);
|
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 = (mmap_array_block *)Yap_AllocAtomSpace(sizeof(mmap_array_block));
|
||||||
ptr->name = AbsAtom(ae);
|
ptr->name = AbsAtom(ae);
|
||||||
ptr->size = total_size;
|
ptr->size = total_size;
|
||||||
@ -1414,7 +1402,7 @@ static void
|
|||||||
replace_array_references_complex(register CELL *pt0,
|
replace_array_references_complex(register CELL *pt0,
|
||||||
register CELL *pt0_end,
|
register CELL *pt0_end,
|
||||||
register CELL *ptn,
|
register CELL *ptn,
|
||||||
Term Var)
|
Term Var USES_REGS)
|
||||||
{
|
{
|
||||||
|
|
||||||
register CELL **to_visit = (CELL **) Yap_PreAllocCodeSpace();
|
register CELL **to_visit = (CELL **) Yap_PreAllocCodeSpace();
|
||||||
@ -1524,7 +1512,7 @@ loop:
|
|||||||
* variables.
|
* variables.
|
||||||
*/
|
*/
|
||||||
static Term
|
static Term
|
||||||
replace_array_references(Term t0)
|
replace_array_references(Term t0 USES_REGS)
|
||||||
{
|
{
|
||||||
Term t;
|
Term t;
|
||||||
|
|
||||||
@ -1540,8 +1528,8 @@ replace_array_references(Term t0)
|
|||||||
|
|
||||||
H += 2;
|
H += 2;
|
||||||
replace_array_references_complex(RepPair(t) - 1, RepPair(t) + 1, h0,
|
replace_array_references_complex(RepPair(t) - 1, RepPair(t) + 1, h0,
|
||||||
VList);
|
VList PASS_REGS);
|
||||||
return (MkPairTerm(AbsPair(h0), VList));
|
return MkPairTerm(AbsPair(h0), VList);
|
||||||
} else {
|
} else {
|
||||||
Term VList = MkVarTerm();
|
Term VList = MkVarTerm();
|
||||||
CELL *h0 = H;
|
CELL *h0 = H;
|
||||||
@ -1551,15 +1539,15 @@ replace_array_references(Term t0)
|
|||||||
H += ArityOfFunctor(f);
|
H += ArityOfFunctor(f);
|
||||||
replace_array_references_complex(RepAppl(t),
|
replace_array_references_complex(RepAppl(t),
|
||||||
RepAppl(t) + ArityOfFunctor(FunctorOfTerm(t)), h0 + 1,
|
RepAppl(t) + ArityOfFunctor(FunctorOfTerm(t)), h0 + 1,
|
||||||
VList);
|
VList PASS_REGS);
|
||||||
return (MkPairTerm(AbsAppl(h0), VList));
|
return (MkPairTerm(AbsAppl(h0), VList));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
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 t1 = HeadOfTerm(t);
|
||||||
Term t2 = TailOfTerm(t);
|
Term t2 = TailOfTerm(t);
|
||||||
|
|
||||||
@ -1567,7 +1555,7 @@ p_array_references(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_assign_static(void)
|
p_assign_static( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1, t2, t3;
|
Term t1, t2, t3;
|
||||||
StaticArrayEntry *ptr;
|
StaticArrayEntry *ptr;
|
||||||
@ -1899,7 +1887,7 @@ p_assign_static(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_assign_dynamic(void)
|
p_assign_dynamic( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1, t2, t3;
|
Term t1, t2, t3;
|
||||||
StaticArrayEntry *ptr;
|
StaticArrayEntry *ptr;
|
||||||
@ -2039,7 +2027,7 @@ p_assign_dynamic(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_add_to_array_element(void)
|
p_add_to_array_element( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1, t2, t3;
|
Term t1, t2, t3;
|
||||||
StaticArrayEntry *ptr;
|
StaticArrayEntry *ptr;
|
||||||
@ -2234,20 +2222,20 @@ p_add_to_array_element(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_compile_array_refs(void)
|
p_compile_array_refs( USES_REGS1 )
|
||||||
{
|
{
|
||||||
compile_arrays = TRUE;
|
compile_arrays = TRUE;
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_array_refs_compiled(void)
|
p_array_refs_compiled( USES_REGS1 )
|
||||||
{
|
{
|
||||||
return compile_arrays;
|
return compile_arrays;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_sync_mmapped_arrays(void)
|
p_sync_mmapped_arrays( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#ifdef HAVE_MMAP
|
#ifdef HAVE_MMAP
|
||||||
mmap_array_block *ptr = mmap_arrays;
|
mmap_array_block *ptr = mmap_arrays;
|
||||||
@ -2260,7 +2248,7 @@ p_sync_mmapped_arrays(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_static_array_to_term(void)
|
p_static_array_to_term( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
@ -2378,7 +2366,7 @@ p_static_array_to_term(void)
|
|||||||
/* The object is now in use */
|
/* The object is now in use */
|
||||||
DBTerm *ref = pp->ValueOfVE.terms[indx];
|
DBTerm *ref = pp->ValueOfVE.terms[indx];
|
||||||
|
|
||||||
Term TRef = GetTermFromArray(ref);
|
Term TRef = GetTermFromArray(ref PASS_REGS);
|
||||||
|
|
||||||
if (P == FAILCODE) {
|
if (P == FAILCODE) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -2394,7 +2382,7 @@ p_static_array_to_term(void)
|
|||||||
H += dim;
|
H += dim;
|
||||||
for (indx=0; indx < dim; indx++) {
|
for (indx=0; indx < dim; indx++) {
|
||||||
/* The object is now in use */
|
/* 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) {
|
if (P == FAILCODE) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -2423,7 +2411,7 @@ p_static_array_to_term(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_static_array_location(void)
|
p_static_array_location( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Int *ptr;
|
Int *ptr;
|
||||||
@ -2452,7 +2440,7 @@ p_static_array_location(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Yap_InitArrayPreds(void)
|
Yap_InitArrayPreds( void )
|
||||||
{
|
{
|
||||||
Yap_InitCPred("$create_array", 2, p_create_array, SyncPredFlag|HiddenPredFlag);
|
Yap_InitCPred("$create_array", 2, p_create_array, SyncPredFlag|HiddenPredFlag);
|
||||||
Yap_InitCPred("$array_references", 3, p_array_references, SafePredFlag|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
|
#define TermVoidAtt TermFoundVar
|
||||||
|
|
||||||
static CELL *
|
static CELL *
|
||||||
AddToQueue(attvar_record *attv)
|
AddToQueue(attvar_record *attv USES_REGS)
|
||||||
{
|
{
|
||||||
Term t[2];
|
Term t[2];
|
||||||
Term WGs, ng;
|
Term WGs, ng;
|
||||||
@ -53,14 +53,14 @@ AddToQueue(attvar_record *attv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
AddFailToQueue(void)
|
AddFailToQueue( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term WGs;
|
Term WGs;
|
||||||
|
|
||||||
/* follow the chain */
|
/* follow the chain */
|
||||||
WGs = Yap_ReadTimedVar(WokenGoals);
|
WGs = Yap_ReadTimedVar(WokenGoals);
|
||||||
|
|
||||||
Yap_UpdateTimedVar(WokenGoals, MkPairTerm(MkAtomTerm(AtomFail),WGs));
|
Yap_UpdateTimedVar(WokenGoals, MkPairTerm(MkAtomTerm(AtomFail), WGs));
|
||||||
if ((Term)WGs == TermNil) {
|
if ((Term)WGs == TermNil) {
|
||||||
/* from now on, we have to start waking up goals */
|
/* from now on, we have to start waking up goals */
|
||||||
Yap_signal(YAP_WAKEUP_SIGNAL);
|
Yap_signal(YAP_WAKEUP_SIGNAL);
|
||||||
@ -68,7 +68,7 @@ AddFailToQueue(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static attvar_record *
|
static attvar_record *
|
||||||
BuildNewAttVar(void)
|
BuildNewAttVar( USES_REGS1 )
|
||||||
{
|
{
|
||||||
attvar_record *newv;
|
attvar_record *newv;
|
||||||
|
|
||||||
@ -83,14 +83,14 @@ BuildNewAttVar(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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 *attv = RepAttVar(orig);
|
||||||
register attvar_record *newv;
|
register attvar_record *newv;
|
||||||
struct cp_frame *to_visit = *to_visit_ptr;
|
struct cp_frame *to_visit = *to_visit_ptr;
|
||||||
CELL *vt;
|
CELL *vt;
|
||||||
|
|
||||||
if (!(newv = BuildNewAttVar()))
|
if (!(newv = BuildNewAttVar( PASS_REGS1 )))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
vt = &(attv->Atts);
|
vt = &(attv->Atts);
|
||||||
to_visit->start_cp = vt-1;
|
to_visit->start_cp = vt-1;
|
||||||
@ -118,9 +118,9 @@ AttVarToTerm(CELL *orig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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)
|
if (!attv)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
Bind(&attv->Atts, attvar);
|
Bind(&attv->Atts, attvar);
|
||||||
@ -129,7 +129,7 @@ TermToAttVar(Term attvar, Term to)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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 */
|
/* 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)) {
|
if (!IsVarTerm(susp2->Value) || !IsUnboundVar(&susp2->Value)) {
|
||||||
/* oops, our goal is on the queue to be woken */
|
/* oops, our goal is on the queue to be woken */
|
||||||
if (!Yap_unify(susp2->Value, (CELL)pt1)) {
|
if (!Yap_unify(susp2->Value, (CELL)pt1)) {
|
||||||
AddFailToQueue();
|
AddFailToQueue( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Bind_Global(&(susp2->Value), (CELL)pt1);
|
Bind_Global(&(susp2->Value), (CELL)pt1);
|
||||||
AddToQueue(susp2);
|
AddToQueue(susp2 PASS_REGS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -167,11 +167,11 @@ WakeAttVar(CELL* pt1, CELL reg2)
|
|||||||
if (!IsVarTerm(attv->Value) || !IsUnboundVar(&attv->Value)) {
|
if (!IsVarTerm(attv->Value) || !IsUnboundVar(&attv->Value)) {
|
||||||
/* oops, our goal is on the queue to be woken */
|
/* oops, our goal is on the queue to be woken */
|
||||||
if (!Yap_unify(attv->Value, reg2)) {
|
if (!Yap_unify(attv->Value, reg2)) {
|
||||||
AddFailToQueue();
|
AddFailToQueue( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bind_ptr = AddToQueue(attv);
|
bind_ptr = AddToQueue(attv PASS_REGS);
|
||||||
if (IsNonVarTerm(reg2)) {
|
if (IsNonVarTerm(reg2)) {
|
||||||
if (IsPairTerm(reg2) && RepPair(reg2) == myH)
|
if (IsPairTerm(reg2) && RepPair(reg2) == myH)
|
||||||
reg2 = AbsPair(H);
|
reg2 = AbsPair(H);
|
||||||
@ -184,10 +184,11 @@ WakeAttVar(CELL* pt1, CELL reg2)
|
|||||||
|
|
||||||
void
|
void
|
||||||
Yap_WakeUp(CELL *pt0) {
|
Yap_WakeUp(CELL *pt0) {
|
||||||
|
CACHE_REGS
|
||||||
CELL d0 = *pt0;
|
CELL d0 = *pt0;
|
||||||
RESET_VARIABLE(pt0);
|
RESET_VARIABLE(pt0);
|
||||||
TR--;
|
TR--;
|
||||||
WakeAttVar(pt0, d0);
|
WakeAttVar(pt0, d0 PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -198,7 +199,7 @@ mark_attvar(CELL *orig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
BuildAttTerm(Functor mfun, UInt ar)
|
BuildAttTerm(Functor mfun, UInt ar USES_REGS)
|
||||||
{
|
{
|
||||||
CELL *h0 = H;
|
CELL *h0 = H;
|
||||||
UInt i;
|
UInt i;
|
||||||
@ -240,7 +241,7 @@ SearchAttsForModuleName(Term start, Atom mname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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;
|
CELL *newp = RepAppl(t)+2;
|
||||||
UInt i, ar = ArityOfFunctor((Functor)newp[-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
|
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;
|
UInt ar = ArityOfFunctor(FunctorOfTerm(oatt)), i;
|
||||||
CELL *oldp = RepAppl(oatt)+1;
|
CELL *oldp = RepAppl(oatt)+1;
|
||||||
@ -326,18 +327,18 @@ ReplaceAtts(attvar_record *attv, Term oatt, Term att)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
DelAllAtts(attvar_record *attv)
|
DelAllAtts(attvar_record *attv USES_REGS)
|
||||||
{
|
{
|
||||||
MaBind(&(attv->Done), attv->Value);
|
MaBind(&(attv->Done), attv->Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
DelAtts(attvar_record *attv, Term oatt)
|
DelAtts(attvar_record *attv, Term oatt USES_REGS)
|
||||||
{
|
{
|
||||||
Term t = ArgOfTerm(1,oatt);
|
Term t = ArgOfTerm(1,oatt);
|
||||||
if (attv->Atts == oatt) {
|
if (attv->Atts == oatt) {
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
DelAllAtts(attv);
|
DelAllAtts(attv PASS_REGS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (RepAppl(attv->Atts) >= HB)
|
if (RepAppl(attv->Atts) >= HB)
|
||||||
@ -359,7 +360,7 @@ DelAtts(attvar_record *attv, Term oatt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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) {
|
if (IsVarTerm(att) && (CELL *)att > H && (CELL *)att < LCL0) {
|
||||||
/* globalise locals */
|
/* globalise locals */
|
||||||
@ -371,7 +372,7 @@ PutAtt(Int pos, Term atts, Term att)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
BindAttVar(attvar_record *attv) {
|
BindAttVar(attvar_record *attv USES_REGS) {
|
||||||
if (IsVarTerm(attv->Done) && IsUnboundVar(&attv->Done)) {
|
if (IsVarTerm(attv->Done) && IsUnboundVar(&attv->Done)) {
|
||||||
/* make sure we are not trying to bind a variable against itself */
|
/* make sure we are not trying to bind a variable against itself */
|
||||||
if (!IsVarTerm(attv->Value)) {
|
if (!IsVarTerm(attv->Value)) {
|
||||||
@ -414,7 +415,7 @@ GetAllAtts(attvar_record *attv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_put_att(void) {
|
p_put_att( USES_REGS1 ) {
|
||||||
/* receive a variable in ARG1 */
|
/* receive a variable in ARG1 */
|
||||||
Term inp = Deref(ARG1);
|
Term inp = Deref(ARG1);
|
||||||
/* if this is unbound, ok */
|
/* if this is unbound, ok */
|
||||||
@ -429,7 +430,7 @@ p_put_att(void) {
|
|||||||
if (IsAttachedTerm(inp)) {
|
if (IsAttachedTerm(inp)) {
|
||||||
attv = RepAttVar(VarOfTerm(inp));
|
attv = RepAttVar(VarOfTerm(inp));
|
||||||
} else {
|
} else {
|
||||||
while (!(attv = BuildNewAttVar())) {
|
while (!(attv = BuildNewAttVar( PASS_REGS1 ))) {
|
||||||
Yap_Error_Size = sizeof(attvar_record);
|
Yap_Error_Size = sizeof(attvar_record);
|
||||||
if (!Yap_gcl(Yap_Error_Size, 5, ENV, gc_P(P,CP))) {
|
if (!Yap_gcl(Yap_Error_Size, 5, ENV, gc_P(P,CP))) {
|
||||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
@ -441,16 +442,16 @@ p_put_att(void) {
|
|||||||
}
|
}
|
||||||
mfun= Yap_MkFunctor(modname,ar);
|
mfun= Yap_MkFunctor(modname,ar);
|
||||||
if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts,mfun))) {
|
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))) {
|
if (!Yap_gcl(Yap_Error_Size, 5, ENV, gc_P(P,CP))) {
|
||||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Yap_unify(ARG1, AbsAttVar(attv));
|
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;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
Yap_Error(REPRESENTATION_ERROR_VARIABLE,inp,"first argument of put_attributes/2");
|
Yap_Error(REPRESENTATION_ERROR_VARIABLE,inp,"first argument of put_attributes/2");
|
||||||
@ -459,7 +460,7 @@ p_put_att(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_put_att_term(void) {
|
p_put_att_term( USES_REGS1 ) {
|
||||||
/* receive a variable in ARG1 */
|
/* receive a variable in ARG1 */
|
||||||
Term inp = Deref(ARG1);
|
Term inp = Deref(ARG1);
|
||||||
/* if this is unbound, ok */
|
/* if this is unbound, ok */
|
||||||
@ -470,7 +471,7 @@ p_put_att_term(void) {
|
|||||||
if (IsAttachedTerm(inp)) {
|
if (IsAttachedTerm(inp)) {
|
||||||
attv = RepAttVar(VarOfTerm(inp));
|
attv = RepAttVar(VarOfTerm(inp));
|
||||||
} else {
|
} else {
|
||||||
while (!(attv = BuildNewAttVar())) {
|
while (!(attv = BuildNewAttVar( PASS_REGS1 ))) {
|
||||||
Yap_Error_Size = sizeof(attvar_record);
|
Yap_Error_Size = sizeof(attvar_record);
|
||||||
if (!Yap_gcl(Yap_Error_Size, 5, ENV, gc_P(P,CP))) {
|
if (!Yap_gcl(Yap_Error_Size, 5, ENV, gc_P(P,CP))) {
|
||||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
@ -494,7 +495,7 @@ p_put_att_term(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_rm_att(void) {
|
p_rm_att( USES_REGS1 ) {
|
||||||
/* receive a variable in ARG1 */
|
/* receive a variable in ARG1 */
|
||||||
Term inp = Deref(ARG1);
|
Term inp = Deref(ARG1);
|
||||||
/* if this is unbound, ok */
|
/* if this is unbound, ok */
|
||||||
@ -509,7 +510,7 @@ p_rm_att(void) {
|
|||||||
if (IsAttachedTerm(inp)) {
|
if (IsAttachedTerm(inp)) {
|
||||||
attv = RepAttVar(VarOfTerm(inp));
|
attv = RepAttVar(VarOfTerm(inp));
|
||||||
} else {
|
} else {
|
||||||
while (!(attv = BuildNewAttVar())) {
|
while (!(attv = BuildNewAttVar( PASS_REGS1 ))) {
|
||||||
Yap_Error_Size = sizeof(attvar_record);
|
Yap_Error_Size = sizeof(attvar_record);
|
||||||
if (!Yap_gcl(Yap_Error_Size, 5, ENV, gc_P(P,CP))) {
|
if (!Yap_gcl(Yap_Error_Size, 5, ENV, gc_P(P,CP))) {
|
||||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
@ -522,15 +523,15 @@ p_rm_att(void) {
|
|||||||
}
|
}
|
||||||
mfun= Yap_MkFunctor(modname,ar);
|
mfun= Yap_MkFunctor(modname,ar);
|
||||||
if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts,mfun))) {
|
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))) {
|
if (!Yap_gcl(Yap_Error_Size, 4, ENV, gc_P(P,CP))) {
|
||||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AddNewModule(attv,tatts,new, FALSE);
|
AddNewModule(attv,tatts,new, FALSE PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
PutAtt(IntegerOfTerm(Deref(ARG4)), tatts, TermVoidAtt);
|
PutAtt(IntegerOfTerm(Deref(ARG4)), tatts, TermVoidAtt PASS_REGS);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
@ -540,7 +541,7 @@ p_rm_att(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_put_atts(void) {
|
p_put_atts( USES_REGS1 ) {
|
||||||
/* receive a variable in ARG1 */
|
/* receive a variable in ARG1 */
|
||||||
Term inp = Deref(ARG1);
|
Term inp = Deref(ARG1);
|
||||||
|
|
||||||
@ -556,7 +557,7 @@ p_put_atts(void) {
|
|||||||
if (IsAttachedTerm(inp)) {
|
if (IsAttachedTerm(inp)) {
|
||||||
attv = RepAttVar(VarOfTerm(inp));
|
attv = RepAttVar(VarOfTerm(inp));
|
||||||
} else {
|
} else {
|
||||||
while (!(attv = BuildNewAttVar())) {
|
while (!(attv = BuildNewAttVar( PASS_REGS1 ))) {
|
||||||
Yap_Error_Size = sizeof(attvar_record);
|
Yap_Error_Size = sizeof(attvar_record);
|
||||||
if (!Yap_gcl(Yap_Error_Size, 2, ENV, gc_P(P,CP))) {
|
if (!Yap_gcl(Yap_Error_Size, 2, ENV, gc_P(P,CP))) {
|
||||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
@ -577,9 +578,9 @@ p_put_atts(void) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (IsVarTerm(otatts = SearchAttsForModule(attv->Atts,mfun))) {
|
if (IsVarTerm(otatts = SearchAttsForModule(attv->Atts,mfun))) {
|
||||||
AddNewModule(attv,tatts,new,FALSE);
|
AddNewModule(attv, tatts, new, FALSE PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
ReplaceAtts(attv, otatts, tatts);
|
ReplaceAtts(attv, otatts, tatts PASS_REGS);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
@ -589,7 +590,7 @@ p_put_atts(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_del_atts(void) {
|
p_del_atts( USES_REGS1 ) {
|
||||||
/* receive a variable in ARG1 */
|
/* receive a variable in ARG1 */
|
||||||
Term inp = Deref(ARG1);
|
Term inp = Deref(ARG1);
|
||||||
Term otatts;
|
Term otatts;
|
||||||
@ -608,7 +609,7 @@ p_del_atts(void) {
|
|||||||
if (IsVarTerm(otatts = SearchAttsForModule(attv->Atts,mfun))) {
|
if (IsVarTerm(otatts = SearchAttsForModule(attv->Atts,mfun))) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
DelAtts(attv, otatts);
|
DelAtts(attv, otatts PASS_REGS);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
@ -617,7 +618,7 @@ p_del_atts(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_del_all_atts(void) {
|
p_del_all_atts( USES_REGS1 ) {
|
||||||
/* receive a variable in ARG1 */
|
/* receive a variable in ARG1 */
|
||||||
Term inp = Deref(ARG1);
|
Term inp = Deref(ARG1);
|
||||||
|
|
||||||
@ -626,13 +627,13 @@ p_del_all_atts(void) {
|
|||||||
attvar_record *attv;
|
attvar_record *attv;
|
||||||
|
|
||||||
attv = RepAttVar(VarOfTerm(inp));
|
attv = RepAttVar(VarOfTerm(inp));
|
||||||
DelAllAtts(attv);
|
DelAllAtts(attv PASS_REGS);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_get_att(void) {
|
p_get_att( USES_REGS1 ) {
|
||||||
/* receive a variable in ARG1 */
|
/* receive a variable in ARG1 */
|
||||||
Term inp = Deref(ARG1);
|
Term inp = Deref(ARG1);
|
||||||
/* if this is unbound, ok */
|
/* if this is unbound, ok */
|
||||||
@ -660,7 +661,7 @@ p_get_att(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_free_att(void) {
|
p_free_att( USES_REGS1 ) {
|
||||||
/* receive a variable in ARG1 */
|
/* receive a variable in ARG1 */
|
||||||
Term inp = Deref(ARG1);
|
Term inp = Deref(ARG1);
|
||||||
/* if this is unbound, ok */
|
/* if this is unbound, ok */
|
||||||
@ -687,7 +688,7 @@ p_free_att(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_get_atts(void) {
|
p_get_atts( USES_REGS1 ) {
|
||||||
/* receive a variable in ARG1 */
|
/* receive a variable in ARG1 */
|
||||||
Term inp = Deref(ARG1);
|
Term inp = Deref(ARG1);
|
||||||
/* if this is unbound, ok */
|
/* if this is unbound, ok */
|
||||||
@ -727,7 +728,7 @@ p_get_atts(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_has_atts(void) {
|
p_has_atts( USES_REGS1 ) {
|
||||||
/* receive a variable in ARG1 */
|
/* receive a variable in ARG1 */
|
||||||
Term inp = Deref(ARG1);
|
Term inp = Deref(ARG1);
|
||||||
/* if this is unbound, ok */
|
/* if this is unbound, ok */
|
||||||
@ -751,14 +752,14 @@ p_has_atts(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_bind_attvar(void) {
|
p_bind_attvar( USES_REGS1 ) {
|
||||||
/* receive a variable in ARG1 */
|
/* receive a variable in ARG1 */
|
||||||
Term inp = Deref(ARG1);
|
Term inp = Deref(ARG1);
|
||||||
/* if this is unbound, ok */
|
/* if this is unbound, ok */
|
||||||
if (IsVarTerm(inp)) {
|
if (IsVarTerm(inp)) {
|
||||||
if (IsAttachedTerm(inp)) {
|
if (IsAttachedTerm(inp)) {
|
||||||
attvar_record *attv = RepAttVar(VarOfTerm(inp));
|
attvar_record *attv = RepAttVar(VarOfTerm(inp));
|
||||||
return(BindAttVar(attv));
|
return(BindAttVar(attv PASS_REGS));
|
||||||
}
|
}
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
} else {
|
} else {
|
||||||
@ -768,7 +769,7 @@ p_bind_attvar(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_unbind_attvar(void) {
|
p_unbind_attvar( USES_REGS1 ) {
|
||||||
/* receive a variable in ARG1 */
|
/* receive a variable in ARG1 */
|
||||||
Term inp = Deref(ARG1);
|
Term inp = Deref(ARG1);
|
||||||
/* if this is unbound, ok */
|
/* if this is unbound, ok */
|
||||||
@ -785,7 +786,7 @@ p_unbind_attvar(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_get_all_atts(void) {
|
p_get_all_atts( USES_REGS1 ) {
|
||||||
/* receive a variable in ARG1 */
|
/* receive a variable in ARG1 */
|
||||||
Term inp = Deref(ARG1);
|
Term inp = Deref(ARG1);
|
||||||
/* if this is unbound, ok */
|
/* if this is unbound, ok */
|
||||||
@ -815,7 +816,7 @@ ActiveAtt(Term tatt, UInt ar)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_modules_with_atts(void) {
|
p_modules_with_atts( USES_REGS1 ) {
|
||||||
/* receive a variable in ARG1 */
|
/* receive a variable in ARG1 */
|
||||||
Term inp = Deref(ARG1);
|
Term inp = Deref(ARG1);
|
||||||
/* if this is unbound, ok */
|
/* if this is unbound, ok */
|
||||||
@ -850,7 +851,7 @@ p_modules_with_atts(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_swi_all_atts(void) {
|
p_swi_all_atts( USES_REGS1 ) {
|
||||||
/* receive a variable in ARG1 */
|
/* receive a variable in ARG1 */
|
||||||
Term inp = Deref(ARG1);
|
Term inp = Deref(ARG1);
|
||||||
Functor attf = FunctorAtt1;
|
Functor attf = FunctorAtt1;
|
||||||
@ -895,7 +896,7 @@ p_swi_all_atts(void) {
|
|||||||
|
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
AllAttVars(void) {
|
AllAttVars( USES_REGS1 ) {
|
||||||
CELL *pt = H0;
|
CELL *pt = H0;
|
||||||
CELL *myH = H;
|
CELL *myH = H;
|
||||||
|
|
||||||
@ -948,12 +949,12 @@ AllAttVars(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_all_attvars(void)
|
p_all_attvars( USES_REGS1 )
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
Term out;
|
Term out;
|
||||||
|
|
||||||
if (!(out = AllAttVars())) {
|
if (!(out = AllAttVars( PASS_REGS1 ))) {
|
||||||
if (!Yap_gcl(Yap_Error_Size, 1, ENV, gc_P(P,CP))) {
|
if (!Yap_gcl(Yap_Error_Size, 1, ENV, gc_P(P,CP))) {
|
||||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -965,7 +966,7 @@ p_all_attvars(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_is_attvar(void)
|
p_is_attvar( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
return(IsVarTerm(t) &&
|
return(IsVarTerm(t) &&
|
||||||
@ -974,7 +975,7 @@ p_is_attvar(void)
|
|||||||
|
|
||||||
/* check if we are not redoing effort */
|
/* check if we are not redoing effort */
|
||||||
static Int
|
static Int
|
||||||
p_attvar_bound(void)
|
p_attvar_bound( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
return
|
return
|
||||||
@ -984,19 +985,19 @@ p_attvar_bound(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_void_term(void)
|
p_void_term( USES_REGS1 )
|
||||||
{
|
{
|
||||||
return Yap_unify(ARG1,TermVoidAtt);
|
return Yap_unify(ARG1,TermVoidAtt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_free_term(void)
|
p_free_term( USES_REGS1 )
|
||||||
{
|
{
|
||||||
return Yap_unify(ARG1,TermFreeTerm);
|
return Yap_unify(ARG1,TermFreeTerm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_fast_unify(void)
|
p_fast_unify( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Case we want to unify two variables, but we do not
|
Case we want to unify two variables, but we do not
|
||||||
@ -1021,27 +1022,28 @@ p_fast_unify(void)
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_all_attvars(void)
|
p_all_attvars( USES_REGS1 )
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_is_attvar(void)
|
p_is_attvar( USES_REGS1 )
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_attvar_bound(void)
|
p_attvar_bound( USES_REGS1 )
|
||||||
{
|
{
|
||||||
b return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* COROUTINING */
|
#endif /* COROUTINING */
|
||||||
|
|
||||||
void Yap_InitAttVarPreds(void)
|
void Yap_InitAttVarPreds(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term OldCurrentModule = CurrentModule;
|
Term OldCurrentModule = CurrentModule;
|
||||||
CurrentModule = ATTRIBUTES_MODULE;
|
CurrentModule = ATTRIBUTES_MODULE;
|
||||||
#ifdef COROUTINING
|
#ifdef COROUTINING
|
||||||
|
31
C/bb.c
31
C/bb.c
@ -25,7 +25,7 @@ static char SccsId[] = "%W% %G%";
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static BBProp
|
static BBProp
|
||||||
PutBBProp(AtomEntry *ae, Term mod) /* get BBentry for at; */
|
PutBBProp(AtomEntry *ae, Term mod USES_REGS) /* get BBentry for at; */
|
||||||
{
|
{
|
||||||
Prop p0;
|
Prop p0;
|
||||||
BBProp p;
|
BBProp p;
|
||||||
@ -56,7 +56,7 @@ PutBBProp(AtomEntry *ae, Term mod) /* get BBentry for at; */
|
|||||||
}
|
}
|
||||||
|
|
||||||
static BBProp
|
static BBProp
|
||||||
PutIntBBProp(Int key, Term mod) /* get BBentry for at; */
|
PutIntBBProp(Int key, Term mod USES_REGS) /* get BBentry for at; */
|
||||||
{
|
{
|
||||||
Prop p0;
|
Prop p0;
|
||||||
BBProp p;
|
BBProp p;
|
||||||
@ -147,6 +147,7 @@ GetIntBBProp(Int key, Term mod) /* get BBentry for at; */
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
resize_bb_int_keys(UInt new_size) {
|
resize_bb_int_keys(UInt new_size) {
|
||||||
|
CACHE_REGS
|
||||||
Prop *new;
|
Prop *new;
|
||||||
UInt i;
|
UInt i;
|
||||||
|
|
||||||
@ -186,7 +187,7 @@ resize_bb_int_keys(UInt new_size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static BBProp
|
static BBProp
|
||||||
AddBBProp(Term t1, char *msg, Term mod)
|
AddBBProp(Term t1, char *msg, Term mod USES_REGS)
|
||||||
{
|
{
|
||||||
BBProp p;
|
BBProp p;
|
||||||
|
|
||||||
@ -195,9 +196,9 @@ AddBBProp(Term t1, char *msg, Term mod)
|
|||||||
Yap_Error(INSTANTIATION_ERROR, t1, msg);
|
Yap_Error(INSTANTIATION_ERROR, t1, msg);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
} if (IsAtomTerm(t1)) {
|
} if (IsAtomTerm(t1)) {
|
||||||
p = PutBBProp(RepAtom(AtomOfTerm(t1)), mod);
|
p = PutBBProp(RepAtom(AtomOfTerm(t1)), mod PASS_REGS);
|
||||||
} else if (IsIntegerTerm(t1)) {
|
} else if (IsIntegerTerm(t1)) {
|
||||||
p = PutIntBBProp(IntegerOfTerm(t1), mod);
|
p = PutIntBBProp(IntegerOfTerm(t1), mod PASS_REGS);
|
||||||
} else if (IsApplTerm(t1) && FunctorOfTerm(t1) == FunctorModule) {
|
} else if (IsApplTerm(t1) && FunctorOfTerm(t1) == FunctorModule) {
|
||||||
Term tmod = ArgOfTerm(1, t1);
|
Term tmod = ArgOfTerm(1, t1);
|
||||||
if (!IsVarTerm(tmod) ) {
|
if (!IsVarTerm(tmod) ) {
|
||||||
@ -264,10 +265,10 @@ BBPut(Term t0, Term t2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_bb_put(void)
|
p_bb_put( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1 = Deref(ARG1);
|
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) {
|
if (p == NULL) {
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@ -283,7 +284,7 @@ p_bb_put(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
BBGet(Term t, UInt arity)
|
BBGet(Term t, UInt arity USES_REGS)
|
||||||
{
|
{
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
return MkVarTerm();
|
return MkVarTerm();
|
||||||
@ -295,7 +296,7 @@ BBGet(Term t, UInt arity)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_bb_get(void)
|
p_bb_get( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
BBProp p = FetchBBProp(t1, "bb_get/2", CurrentModule);
|
BBProp p = FetchBBProp(t1, "bb_get/2", CurrentModule);
|
||||||
@ -309,12 +310,12 @@ p_bb_get(void)
|
|||||||
*/
|
*/
|
||||||
t0 = p->Element;
|
t0 = p->Element;
|
||||||
READ_UNLOCK(p->BBRWLock);
|
READ_UNLOCK(p->BBRWLock);
|
||||||
out = BBGet(t0, 2);
|
out = BBGet(t0, 2 PASS_REGS);
|
||||||
return Yap_unify(ARG2,out);
|
return Yap_unify(ARG2,out);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_bb_delete(void)
|
p_bb_delete( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
BBProp p;
|
BBProp p;
|
||||||
@ -324,7 +325,7 @@ p_bb_delete(void)
|
|||||||
if (p == NULL || p->Element == 0L)
|
if (p == NULL || p->Element == 0L)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
WRITE_LOCK(p->BBRWLock);
|
WRITE_LOCK(p->BBRWLock);
|
||||||
out = BBGet(p->Element,2);
|
out = BBGet(p->Element, 2 PASS_REGS);
|
||||||
if (!IsVarTerm(p->Element) && IsApplTerm(p->Element)) {
|
if (!IsVarTerm(p->Element) && IsApplTerm(p->Element)) {
|
||||||
Yap_ErLogUpdCl((LogUpdClause *)DBRefOfTerm(p->Element));
|
Yap_ErLogUpdCl((LogUpdClause *)DBRefOfTerm(p->Element));
|
||||||
}
|
}
|
||||||
@ -334,7 +335,7 @@ p_bb_delete(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_bb_update(void)
|
p_bb_update( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
BBProp p;
|
BBProp p;
|
||||||
@ -344,7 +345,7 @@ p_bb_update(void)
|
|||||||
if (p == NULL || p->Element == 0L)
|
if (p == NULL || p->Element == 0L)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
WRITE_LOCK(p->BBRWLock);
|
WRITE_LOCK(p->BBRWLock);
|
||||||
out = BBGet(p->Element, 3);
|
out = BBGet(p->Element, 3 PASS_REGS);
|
||||||
if (!Yap_unify(out,ARG2)) {
|
if (!Yap_unify(out,ARG2)) {
|
||||||
WRITE_UNLOCK(p->BBRWLock);
|
WRITE_UNLOCK(p->BBRWLock);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -355,7 +356,7 @@ p_bb_update(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_resize_bb_int_keys(void)
|
p_resize_bb_int_keys( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
if (IsVarTerm(t1)) {
|
if (IsVarTerm(t1)) {
|
||||||
|
12
C/bignum.c
12
C/bignum.c
@ -34,6 +34,7 @@ static char SccsId[] = "%W% %G%";
|
|||||||
Term
|
Term
|
||||||
Yap_MkBigIntTerm(MP_INT *big)
|
Yap_MkBigIntTerm(MP_INT *big)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Int nlimbs;
|
Int nlimbs;
|
||||||
MP_INT *dst = (MP_INT *)(H+2);
|
MP_INT *dst = (MP_INT *)(H+2);
|
||||||
CELL *ret = H;
|
CELL *ret = H;
|
||||||
@ -70,6 +71,7 @@ Yap_BigIntOfTerm(Term t)
|
|||||||
Term
|
Term
|
||||||
Yap_MkBigRatTerm(MP_RAT *big)
|
Yap_MkBigRatTerm(MP_RAT *big)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Int nlimbs;
|
Int nlimbs;
|
||||||
MP_INT *dst = (MP_INT *)(H+2);
|
MP_INT *dst = (MP_INT *)(H+2);
|
||||||
MP_INT *num = mpq_numref(big);
|
MP_INT *num = mpq_numref(big);
|
||||||
@ -157,7 +159,7 @@ Yap_MkULLIntTerm(YAP_ULONG_LONG n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_is_bignum(void)
|
p_is_bignum( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#ifdef USE_GMP
|
#ifdef USE_GMP
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
@ -173,7 +175,7 @@ p_is_bignum(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_has_bignums(void)
|
p_has_bignums( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#ifdef USE_GMP
|
#ifdef USE_GMP
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -183,7 +185,7 @@ p_has_bignums(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_is_rational(void)
|
p_is_rational( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
if (IsVarTerm(t))
|
if (IsVarTerm(t))
|
||||||
@ -205,7 +207,7 @@ p_is_rational(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_rational(void)
|
p_rational( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#ifdef USE_GMP
|
#ifdef USE_GMP
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
@ -246,6 +248,7 @@ p_rational(void)
|
|||||||
Term
|
Term
|
||||||
Yap_MkBlobStringTerm(const char *s, size_t len)
|
Yap_MkBlobStringTerm(const char *s, size_t len)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
CELL *ret = H;
|
CELL *ret = H;
|
||||||
size_t sz;
|
size_t sz;
|
||||||
MP_INT *dst = (MP_INT *)(H+2);
|
MP_INT *dst = (MP_INT *)(H+2);
|
||||||
@ -275,6 +278,7 @@ Yap_MkBlobStringTerm(const char *s, size_t len)
|
|||||||
Term
|
Term
|
||||||
Yap_MkBlobWideStringTerm(const wchar_t *s, size_t len)
|
Yap_MkBlobWideStringTerm(const wchar_t *s, size_t len)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
CELL *ret = H;
|
CELL *ret = H;
|
||||||
size_t sz;
|
size_t sz;
|
||||||
MP_INT *dst = (MP_INT *)(H+2);
|
MP_INT *dst = (MP_INT *)(H+2);
|
||||||
|
344
C/c_interface.c
344
C/c_interface.c
@ -545,6 +545,7 @@ static int do_yap_putc(int streamno,wchar_t ch) {
|
|||||||
static int
|
static int
|
||||||
dogc(void)
|
dogc(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
UInt arity;
|
UInt arity;
|
||||||
|
|
||||||
if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) {
|
if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) {
|
||||||
@ -561,6 +562,7 @@ dogc(void)
|
|||||||
static int
|
static int
|
||||||
doexpand(UInt sz)
|
doexpand(UInt sz)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
UInt arity;
|
UInt arity;
|
||||||
|
|
||||||
if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) {
|
if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) {
|
||||||
@ -577,6 +579,7 @@ doexpand(UInt sz)
|
|||||||
X_API Term
|
X_API Term
|
||||||
YAP_A(int i)
|
YAP_A(int i)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
return(Deref(XREGS[i]));
|
return(Deref(XREGS[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -751,6 +754,7 @@ YAP_RationalOfTerm(Term t, void *b)
|
|||||||
X_API Term
|
X_API Term
|
||||||
YAP_MkBlobTerm(unsigned int sz)
|
YAP_MkBlobTerm(unsigned int sz)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term I;
|
Term I;
|
||||||
MP_INT *dst;
|
MP_INT *dst;
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
@ -846,6 +850,7 @@ YAP_WideAtomName(Atom a)
|
|||||||
X_API Atom
|
X_API Atom
|
||||||
YAP_LookupAtom(char *c)
|
YAP_LookupAtom(char *c)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Atom a;
|
Atom a;
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
@ -863,6 +868,7 @@ YAP_LookupAtom(char *c)
|
|||||||
X_API Atom
|
X_API Atom
|
||||||
YAP_LookupWideAtom(wchar_t *c)
|
YAP_LookupWideAtom(wchar_t *c)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Atom a;
|
Atom a;
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
@ -880,6 +886,7 @@ YAP_LookupWideAtom(wchar_t *c)
|
|||||||
X_API Atom
|
X_API Atom
|
||||||
YAP_FullLookupAtom(char *c)
|
YAP_FullLookupAtom(char *c)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Atom at;
|
Atom at;
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
@ -914,6 +921,7 @@ YAP_AtomNameLength(Atom at)
|
|||||||
X_API Term
|
X_API Term
|
||||||
YAP_MkVarTerm(void)
|
YAP_MkVarTerm(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
CELL t;
|
CELL t;
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
|
|
||||||
@ -926,19 +934,20 @@ YAP_MkVarTerm(void)
|
|||||||
X_API Term
|
X_API Term
|
||||||
YAP_MkPairTerm(Term t1, Term t2)
|
YAP_MkPairTerm(Term t1, Term t2)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term t;
|
Term t;
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
|
|
||||||
if (H > ASP-1024) {
|
if (H > ASP-1024) {
|
||||||
Int sl1 = Yap_InitSlot(t1);
|
Int sl1 = Yap_InitSlot(t1 PASS_REGS);
|
||||||
Int sl2 = Yap_InitSlot(t2);
|
Int sl2 = Yap_InitSlot(t2 PASS_REGS);
|
||||||
if (!dogc()) {
|
if (!dogc()) {
|
||||||
RECOVER_H();
|
RECOVER_H();
|
||||||
return TermNil;
|
return TermNil;
|
||||||
}
|
}
|
||||||
t1 = Yap_GetFromSlot(sl1);
|
t1 = Yap_GetFromSlot(sl1 PASS_REGS);
|
||||||
t2 = Yap_GetFromSlot(sl2);
|
t2 = Yap_GetFromSlot(sl2 PASS_REGS);
|
||||||
Yap_RecoverSlots(2);
|
Yap_RecoverSlots(2 PASS_REGS);
|
||||||
}
|
}
|
||||||
t = MkPairTerm(t1, t2);
|
t = MkPairTerm(t1, t2);
|
||||||
RECOVER_H();
|
RECOVER_H();
|
||||||
@ -948,6 +957,7 @@ YAP_MkPairTerm(Term t1, Term t2)
|
|||||||
X_API Term
|
X_API Term
|
||||||
YAP_MkNewPairTerm()
|
YAP_MkNewPairTerm()
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term t;
|
Term t;
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
|
|
||||||
@ -1003,6 +1013,7 @@ YAP_SkipList(Term *l, Term **tailp)
|
|||||||
X_API Term
|
X_API Term
|
||||||
YAP_MkApplTerm(Functor f,UInt arity, Term args[])
|
YAP_MkApplTerm(Functor f,UInt arity, Term args[])
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term t;
|
Term t;
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
|
|
||||||
@ -1018,6 +1029,7 @@ YAP_MkApplTerm(Functor f,UInt arity, Term args[])
|
|||||||
X_API Term
|
X_API Term
|
||||||
YAP_MkNewApplTerm(Functor f,UInt arity)
|
YAP_MkNewApplTerm(Functor f,UInt arity)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term t;
|
Term t;
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
|
|
||||||
@ -1075,6 +1087,7 @@ YAP_ArityOfFunctor(Functor f)
|
|||||||
X_API void *
|
X_API void *
|
||||||
YAP_ExtraSpaceCut(void)
|
YAP_ExtraSpaceCut(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
void *ptr;
|
void *ptr;
|
||||||
BACKUP_B();
|
BACKUP_B();
|
||||||
|
|
||||||
@ -1088,6 +1101,7 @@ YAP_ExtraSpaceCut(void)
|
|||||||
X_API void *
|
X_API void *
|
||||||
YAP_ExtraSpace(void)
|
YAP_ExtraSpace(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
void *ptr;
|
void *ptr;
|
||||||
BACKUP_B();
|
BACKUP_B();
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
@ -1104,6 +1118,7 @@ YAP_ExtraSpace(void)
|
|||||||
X_API void
|
X_API void
|
||||||
YAP_cut_up(void)
|
YAP_cut_up(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
BACKUP_B();
|
BACKUP_B();
|
||||||
#ifdef CUT_C
|
#ifdef CUT_C
|
||||||
{
|
{
|
||||||
@ -1189,43 +1204,50 @@ YAP_TermHash(Term t, Int sz, Int depth, int variant)
|
|||||||
X_API Int
|
X_API Int
|
||||||
YAP_CurrentSlot(void)
|
YAP_CurrentSlot(void)
|
||||||
{
|
{
|
||||||
return Yap_CurrentSlot();
|
CACHE_REGS
|
||||||
|
return Yap_CurrentSlot( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API Int
|
X_API Int
|
||||||
YAP_NewSlots(int n)
|
YAP_NewSlots(int n)
|
||||||
{
|
{
|
||||||
return Yap_NewSlots(n);
|
CACHE_REGS
|
||||||
|
return Yap_NewSlots(n PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API Int
|
X_API Int
|
||||||
YAP_InitSlot(Term t)
|
YAP_InitSlot(Term t)
|
||||||
{
|
{
|
||||||
return Yap_InitSlot(t);
|
CACHE_REGS
|
||||||
|
return Yap_InitSlot(t PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API int
|
X_API int
|
||||||
YAP_RecoverSlots(int n)
|
YAP_RecoverSlots(int n)
|
||||||
{
|
{
|
||||||
return Yap_RecoverSlots(n);
|
CACHE_REGS
|
||||||
|
return Yap_RecoverSlots(n PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API Term
|
X_API Term
|
||||||
YAP_GetFromSlot(Int slot)
|
YAP_GetFromSlot(Int slot)
|
||||||
{
|
{
|
||||||
return Yap_GetFromSlot(slot);
|
CACHE_REGS
|
||||||
|
return Yap_GetFromSlot(slot PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API Term *
|
X_API Term *
|
||||||
YAP_AddressFromSlot(Int slot)
|
YAP_AddressFromSlot(Int slot)
|
||||||
{
|
{
|
||||||
return Yap_AddressFromSlot(slot);
|
CACHE_REGS
|
||||||
|
return Yap_AddressFromSlot(slot PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API Term *
|
X_API Term *
|
||||||
YAP_AddressOfTermInSlot(Int slot)
|
YAP_AddressOfTermInSlot(Int slot)
|
||||||
{
|
{
|
||||||
Term *b = Yap_AddressFromSlot(slot);
|
CACHE_REGS
|
||||||
|
Term *b = Yap_AddressFromSlot(slot PASS_REGS);
|
||||||
Term a = *b;
|
Term a = *b;
|
||||||
restart:
|
restart:
|
||||||
if (!IsVarTerm(a)) {
|
if (!IsVarTerm(a)) {
|
||||||
@ -1242,7 +1264,8 @@ YAP_AddressOfTermInSlot(Int slot)
|
|||||||
X_API void
|
X_API void
|
||||||
YAP_PutInSlot(Int slot, Term t)
|
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 */
|
struct PL_local_data *engine; /* invoking engine */
|
||||||
} scontext ;
|
} scontext ;
|
||||||
|
|
||||||
|
typedef Int (*CPredicate0)(void);
|
||||||
typedef Int (*CPredicate1)(Int);
|
typedef Int (*CPredicate1)(Int);
|
||||||
typedef Int (*CPredicate2)(Int,Int);
|
typedef Int (*CPredicate2)(Int,Int);
|
||||||
typedef Int (*CPredicate3)(Int,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 *);
|
typedef Int (*CPredicateV)(Int,Int,struct foreign_context *);
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
execute_cargs(PredEntry *pe, CPredicate exec_code)
|
execute_cargs(PredEntry *pe, CPredicate exec_code USES_REGS)
|
||||||
{
|
{
|
||||||
switch (pe->ArityOfPE) {
|
switch (pe->ArityOfPE) {
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
CPredicate code0 = exec_code;
|
CPredicate0 code0 = (CPredicate0)exec_code;
|
||||||
return ((code0)());
|
return ((code0)());
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
CPredicate1 code1 = (CPredicate1)exec_code;
|
CPredicate1 code1 = (CPredicate1)exec_code;
|
||||||
return ((code1)(Yap_InitSlot(Deref(ARG1))));
|
return ((code1)(Yap_InitSlot(Deref(ARG1) PASS_REGS)));
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
CPredicate2 code2 = (CPredicate2)exec_code;
|
CPredicate2 code2 = (CPredicate2)exec_code;
|
||||||
return ((code2)(Yap_InitSlot(Deref(ARG1)),
|
return ((code2)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2))));
|
Yap_InitSlot(Deref(ARG2) PASS_REGS)));
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
CPredicate3 code3 = (CPredicate3)exec_code;
|
CPredicate3 code3 = (CPredicate3)exec_code;
|
||||||
return ((code3)(Yap_InitSlot(Deref(ARG1)),
|
return ((code3)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG3))));
|
Yap_InitSlot(Deref(ARG3) PASS_REGS)));
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
CPredicate4 code4 = (CPredicate4)exec_code;
|
CPredicate4 code4 = (CPredicate4)exec_code;
|
||||||
return ((code4)(Yap_InitSlot(Deref(ARG1)),
|
return ((code4)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG3)),
|
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG4))));
|
Yap_InitSlot(Deref(ARG4) PASS_REGS)));
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
{
|
{
|
||||||
CPredicate5 code5 = (CPredicate5)exec_code;
|
CPredicate5 code5 = (CPredicate5)exec_code;
|
||||||
return ((code5)(Yap_InitSlot(Deref(ARG1)),
|
return ((code5)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG3)),
|
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG4)),
|
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG5))));
|
Yap_InitSlot(Deref(ARG5) PASS_REGS)));
|
||||||
}
|
}
|
||||||
case 6:
|
case 6:
|
||||||
{
|
{
|
||||||
CPredicate6 code6 = (CPredicate6)exec_code;
|
CPredicate6 code6 = (CPredicate6)exec_code;
|
||||||
return ((code6)(Yap_InitSlot(Deref(ARG1)),
|
return ((code6)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG3)),
|
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG4)),
|
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG5)),
|
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG6))));
|
Yap_InitSlot(Deref(ARG6) PASS_REGS)));
|
||||||
}
|
}
|
||||||
case 7:
|
case 7:
|
||||||
{
|
{
|
||||||
CPredicate7 code7 = (CPredicate7)exec_code;
|
CPredicate7 code7 = (CPredicate7)exec_code;
|
||||||
return ((code7)(Yap_InitSlot(Deref(ARG1)),
|
return ((code7)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG3)),
|
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG4)),
|
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG5)),
|
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG6)),
|
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG7))));
|
Yap_InitSlot(Deref(ARG7) PASS_REGS)));
|
||||||
}
|
}
|
||||||
case 8:
|
case 8:
|
||||||
{
|
{
|
||||||
CPredicate8 code8 = (CPredicate8)exec_code;
|
CPredicate8 code8 = (CPredicate8)exec_code;
|
||||||
return ((code8)(Yap_InitSlot(Deref(ARG1)),
|
return ((code8)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG3)),
|
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG4)),
|
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG5)),
|
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG6)),
|
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG7)),
|
Yap_InitSlot(Deref(ARG7) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG8))));
|
Yap_InitSlot(Deref(ARG8) PASS_REGS)));
|
||||||
}
|
}
|
||||||
case 9:
|
case 9:
|
||||||
{
|
{
|
||||||
CPredicate9 code9 = (CPredicate9)exec_code;
|
CPredicate9 code9 = (CPredicate9)exec_code;
|
||||||
return ((code9)(Yap_InitSlot(Deref(ARG1)),
|
return ((code9)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG3)),
|
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG4)),
|
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG5)),
|
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG6)),
|
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG7)),
|
Yap_InitSlot(Deref(ARG7) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG8)),
|
Yap_InitSlot(Deref(ARG8) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG9))));
|
Yap_InitSlot(Deref(ARG9) PASS_REGS)));
|
||||||
}
|
}
|
||||||
case 10:
|
case 10:
|
||||||
{
|
{
|
||||||
CPredicate10 code10 = (CPredicate10)exec_code;
|
CPredicate10 code10 = (CPredicate10)exec_code;
|
||||||
return ((code10)(Yap_InitSlot(Deref(ARG1)),
|
return ((code10)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG3)),
|
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG4)),
|
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG5)),
|
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG6)),
|
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG7)),
|
Yap_InitSlot(Deref(ARG7) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG8)),
|
Yap_InitSlot(Deref(ARG8) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG9)),
|
Yap_InitSlot(Deref(ARG9) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG10))));
|
Yap_InitSlot(Deref(ARG10) PASS_REGS)));
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return(FALSE);
|
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 *);
|
typedef Int (*CBPredicate10)(Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,struct foreign_context *);
|
||||||
|
|
||||||
static Int
|
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) {
|
switch (pe->ArityOfPE) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -1403,105 +1427,105 @@ execute_cargs_back(PredEntry *pe, CPredicate exec_code, struct foreign_context *
|
|||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
CBPredicate1 code1 = (CBPredicate1)exec_code;
|
CBPredicate1 code1 = (CBPredicate1)exec_code;
|
||||||
return ((code1)(Yap_InitSlot(Deref(ARG1)),
|
return ((code1)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
ctx));
|
ctx));
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
CBPredicate2 code2 = (CBPredicate2)exec_code;
|
CBPredicate2 code2 = (CBPredicate2)exec_code;
|
||||||
return ((code2)(Yap_InitSlot(Deref(ARG1)),
|
return ((code2)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
ctx));
|
ctx));
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
CBPredicate3 code3 = (CBPredicate3)exec_code;
|
CBPredicate3 code3 = (CBPredicate3)exec_code;
|
||||||
return ((code3)(Yap_InitSlot(Deref(ARG1)),
|
return ((code3)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG3)),
|
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||||
ctx));
|
ctx));
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
CBPredicate4 code4 = (CBPredicate4)exec_code;
|
CBPredicate4 code4 = (CBPredicate4)exec_code;
|
||||||
return ((code4)(Yap_InitSlot(Deref(ARG1)),
|
return ((code4)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG3)),
|
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG4)),
|
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||||
ctx));
|
ctx));
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
{
|
{
|
||||||
CBPredicate5 code5 = (CBPredicate5)exec_code;
|
CBPredicate5 code5 = (CBPredicate5)exec_code;
|
||||||
return ((code5)(Yap_InitSlot(Deref(ARG1)),
|
return ((code5)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG3)),
|
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG4)),
|
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG5)), ctx));
|
Yap_InitSlot(Deref(ARG5) PASS_REGS), ctx));
|
||||||
}
|
}
|
||||||
case 6:
|
case 6:
|
||||||
{
|
{
|
||||||
CBPredicate6 code6 = (CBPredicate6)exec_code;
|
CBPredicate6 code6 = (CBPredicate6)exec_code;
|
||||||
return ((code6)(Yap_InitSlot(Deref(ARG1)),
|
return ((code6)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG3)),
|
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG4)),
|
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG5)),
|
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG6)),
|
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||||
ctx));
|
ctx));
|
||||||
}
|
}
|
||||||
case 7:
|
case 7:
|
||||||
{
|
{
|
||||||
CBPredicate7 code7 = (CBPredicate7)exec_code;
|
CBPredicate7 code7 = (CBPredicate7)exec_code;
|
||||||
return ((code7)(Yap_InitSlot(Deref(ARG1)),
|
return ((code7)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG3)),
|
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG4)),
|
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG5)),
|
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG6)),
|
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG7)),
|
Yap_InitSlot(Deref(ARG7) PASS_REGS),
|
||||||
ctx));
|
ctx));
|
||||||
}
|
}
|
||||||
case 8:
|
case 8:
|
||||||
{
|
{
|
||||||
CBPredicate8 code8 = (CBPredicate8)exec_code;
|
CBPredicate8 code8 = (CBPredicate8)exec_code;
|
||||||
return ((code8)(Yap_InitSlot(Deref(ARG1)),
|
return ((code8)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG3)),
|
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG4)),
|
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG5)),
|
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG6)),
|
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG7)),
|
Yap_InitSlot(Deref(ARG7) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG8)),
|
Yap_InitSlot(Deref(ARG8) PASS_REGS),
|
||||||
ctx));
|
ctx));
|
||||||
}
|
}
|
||||||
case 9:
|
case 9:
|
||||||
{
|
{
|
||||||
CBPredicate9 code9 = (CBPredicate9)exec_code;
|
CBPredicate9 code9 = (CBPredicate9)exec_code;
|
||||||
return ((code9)(Yap_InitSlot(Deref(ARG1)),
|
return ((code9)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG3)),
|
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG4)),
|
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG5)),
|
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG6)),
|
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG7)),
|
Yap_InitSlot(Deref(ARG7) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG8)),
|
Yap_InitSlot(Deref(ARG8) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG9)),
|
Yap_InitSlot(Deref(ARG9) PASS_REGS),
|
||||||
ctx));
|
ctx));
|
||||||
}
|
}
|
||||||
case 10:
|
case 10:
|
||||||
{
|
{
|
||||||
CBPredicate10 code10 = (CBPredicate10)exec_code;
|
CBPredicate10 code10 = (CBPredicate10)exec_code;
|
||||||
return ((code10)(Yap_InitSlot(Deref(ARG1)),
|
return ((code10)(Yap_InitSlot(Deref(ARG1) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG2)),
|
Yap_InitSlot(Deref(ARG2) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG3)),
|
Yap_InitSlot(Deref(ARG3) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG4)),
|
Yap_InitSlot(Deref(ARG4) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG5)),
|
Yap_InitSlot(Deref(ARG5) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG6)),
|
Yap_InitSlot(Deref(ARG6) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG7)),
|
Yap_InitSlot(Deref(ARG7) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG8)),
|
Yap_InitSlot(Deref(ARG8) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG9)),
|
Yap_InitSlot(Deref(ARG9) PASS_REGS),
|
||||||
Yap_InitSlot(Deref(ARG10)),
|
Yap_InitSlot(Deref(ARG10) PASS_REGS),
|
||||||
ctx));
|
ctx));
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -1513,6 +1537,7 @@ execute_cargs_back(PredEntry *pe, CPredicate exec_code, struct foreign_context *
|
|||||||
Int
|
Int
|
||||||
YAP_Execute(PredEntry *pe, CPredicate exec_code)
|
YAP_Execute(PredEntry *pe, CPredicate exec_code)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (pe->PredFlags & SWIEnvPredFlag) {
|
if (pe->PredFlags & SWIEnvPredFlag) {
|
||||||
CPredicateV codev = (CPredicateV)exec_code;
|
CPredicateV codev = (CPredicateV)exec_code;
|
||||||
struct foreign_context ctx;
|
struct foreign_context ctx;
|
||||||
@ -1522,7 +1547,7 @@ YAP_Execute(PredEntry *pe, CPredicate exec_code)
|
|||||||
|
|
||||||
ctx.engine = NULL;
|
ctx.engine = NULL;
|
||||||
for (i=pe->ArityOfPE; i > 0; i--) {
|
for (i=pe->ArityOfPE; i > 0; i--) {
|
||||||
sl = Yap_InitSlot(XREGS[i]);
|
sl = Yap_InitSlot(XREGS[i] PASS_REGS);
|
||||||
}
|
}
|
||||||
PP = pe;
|
PP = pe;
|
||||||
ret = ((codev)(sl,0,&ctx));
|
ret = ((codev)(sl,0,&ctx));
|
||||||
@ -1541,7 +1566,7 @@ YAP_Execute(PredEntry *pe, CPredicate exec_code)
|
|||||||
}
|
}
|
||||||
if (pe->PredFlags & CArgsPredFlag) {
|
if (pe->PredFlags & CArgsPredFlag) {
|
||||||
PP = pe;
|
PP = pe;
|
||||||
Int out = execute_cargs(pe, exec_code);
|
Int out = execute_cargs(pe, exec_code PASS_REGS);
|
||||||
PP = NULL;
|
PP = NULL;
|
||||||
if (!out) {
|
if (!out) {
|
||||||
Term t;
|
Term t;
|
||||||
@ -1555,7 +1580,7 @@ YAP_Execute(PredEntry *pe, CPredicate exec_code)
|
|||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
} else {
|
} else {
|
||||||
Int ret = (exec_code)();
|
Int ret = (exec_code)( PASS_REGS1 );
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
Term t;
|
Term t;
|
||||||
|
|
||||||
@ -1578,6 +1603,7 @@ YAP_Execute(PredEntry *pe, CPredicate exec_code)
|
|||||||
Int
|
Int
|
||||||
YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code)
|
YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (pe->PredFlags & (SWIEnvPredFlag|CArgsPredFlag)) {
|
if (pe->PredFlags & (SWIEnvPredFlag|CArgsPredFlag)) {
|
||||||
Int val;
|
Int val;
|
||||||
CPredicateV codev = (CPredicateV)exec_code;
|
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->engine = NULL; //(PL_local_data *)Yap_regp;
|
||||||
ctx->context = NULL;
|
ctx->context = NULL;
|
||||||
if (pe->PredFlags & CArgsPredFlag) {
|
if (pe->PredFlags & CArgsPredFlag) {
|
||||||
val = execute_cargs_back(pe, exec_code, ctx);
|
val = execute_cargs_back(pe, exec_code, ctx PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
val = ((codev)((&ARG1)-LCL0,0,ctx));
|
val = ((codev)((&ARG1)-LCL0,0,ctx));
|
||||||
}
|
}
|
||||||
@ -1620,7 +1646,7 @@ YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Int ret = (exec_code)();
|
Int ret = (exec_code)( PASS_REGS1 );
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
Term t;
|
Term t;
|
||||||
|
|
||||||
@ -1638,6 +1664,7 @@ YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code)
|
|||||||
Int
|
Int
|
||||||
YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code)
|
YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (pe->PredFlags & (SWIEnvPredFlag|CArgsPredFlag)) {
|
if (pe->PredFlags & (SWIEnvPredFlag|CArgsPredFlag)) {
|
||||||
Int val;
|
Int val;
|
||||||
CPredicateV codev = (CPredicateV)exec_code;
|
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->engine = NULL; //(PL_local_data *)Yap_regp;
|
||||||
ctx->context = NULL;
|
ctx->context = NULL;
|
||||||
if (pe->PredFlags & CArgsPredFlag) {
|
if (pe->PredFlags & CArgsPredFlag) {
|
||||||
val = execute_cargs_back(pe, exec_code, ctx);
|
val = execute_cargs_back(pe, exec_code, ctx PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
val = ((codev)((&ARG1)-LCL0,0,ctx));
|
val = ((codev)((&ARG1)-LCL0,0,ctx));
|
||||||
}
|
}
|
||||||
@ -1674,7 +1701,7 @@ YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Int ret = (exec_code)();
|
Int ret = (exec_code)( PASS_REGS1 );
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
Term t;
|
Term t;
|
||||||
|
|
||||||
@ -1693,6 +1720,7 @@ YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code)
|
|||||||
Int
|
Int
|
||||||
YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code)
|
YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (pe->PredFlags & (SWIEnvPredFlag|CArgsPredFlag)) {
|
if (pe->PredFlags & (SWIEnvPredFlag|CArgsPredFlag)) {
|
||||||
Int val;
|
Int val;
|
||||||
CPredicateV codev = (CPredicateV)exec_code;
|
CPredicateV codev = (CPredicateV)exec_code;
|
||||||
@ -1703,7 +1731,7 @@ YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code)
|
|||||||
PP = pe;
|
PP = pe;
|
||||||
ctx->control = FRG_REDO;
|
ctx->control = FRG_REDO;
|
||||||
if (pe->PredFlags & CArgsPredFlag) {
|
if (pe->PredFlags & CArgsPredFlag) {
|
||||||
val = execute_cargs_back(pe, exec_code, ctx);
|
val = execute_cargs_back(pe, exec_code, ctx PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
val = ((codev)((&ARG1)-LCL0,0,ctx));
|
val = ((codev)((&ARG1)-LCL0,0,ctx));
|
||||||
}
|
}
|
||||||
@ -1736,7 +1764,7 @@ YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code)
|
|||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
Int ret = (exec_code)();
|
Int ret = (exec_code)( PASS_REGS1 );
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
Term t;
|
Term t;
|
||||||
|
|
||||||
@ -1754,6 +1782,7 @@ YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code)
|
|||||||
X_API Int
|
X_API Int
|
||||||
YAP_CallProlog(Term t)
|
YAP_CallProlog(Term t)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Int out;
|
Int out;
|
||||||
Term mod = CurrentModule;
|
Term mod = CurrentModule;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
@ -1774,6 +1803,7 @@ YAP_CallProlog(Term t)
|
|||||||
|
|
||||||
X_API void *
|
X_API void *
|
||||||
YAP_ReallocSpaceFromYap(void *ptr,unsigned int size) {
|
YAP_ReallocSpaceFromYap(void *ptr,unsigned int size) {
|
||||||
|
CACHE_REGS
|
||||||
void *new_ptr;
|
void *new_ptr;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
while ((new_ptr = Yap_ReallocCodeSpace(ptr,size)) == NULL) {
|
while ((new_ptr = Yap_ReallocCodeSpace(ptr,size)) == NULL) {
|
||||||
@ -1788,6 +1818,7 @@ YAP_ReallocSpaceFromYap(void *ptr,unsigned int size) {
|
|||||||
X_API void *
|
X_API void *
|
||||||
YAP_AllocSpaceFromYap(unsigned int size)
|
YAP_AllocSpaceFromYap(unsigned int size)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
void *ptr;
|
void *ptr;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
|
|
||||||
@ -1905,6 +1936,7 @@ YAP_NWideBufferToString(wchar_t *s, size_t len)
|
|||||||
X_API Term
|
X_API Term
|
||||||
YAP_ReadBuffer(char *s, Term *tp)
|
YAP_ReadBuffer(char *s, Term *tp)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term t;
|
Term t;
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
|
|
||||||
@ -2016,10 +2048,11 @@ YAP_NWideBufferToAtomDiffList(wchar_t *s, Term t0, size_t len)
|
|||||||
X_API Term
|
X_API Term
|
||||||
YAP_BufferToDiffList(char *s, Term t0)
|
YAP_BufferToDiffList(char *s, Term t0)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term t;
|
Term t;
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
|
|
||||||
t = Yap_StringToDiffList(s, t0);
|
t = Yap_StringToDiffList(s, t0 PASS_REGS);
|
||||||
|
|
||||||
RECOVER_H();
|
RECOVER_H();
|
||||||
return t;
|
return t;
|
||||||
@ -2099,12 +2132,14 @@ static int myputc (wchar_t ch)
|
|||||||
X_API PredEntry *
|
X_API PredEntry *
|
||||||
YAP_FunctorToPred(Functor func)
|
YAP_FunctorToPred(Functor func)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
return RepPredProp(PredPropByFunc(func, CurrentModule));
|
return RepPredProp(PredPropByFunc(func, CurrentModule));
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API PredEntry *
|
X_API PredEntry *
|
||||||
YAP_AtomToPred(Atom at)
|
YAP_AtomToPred(Atom at)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
return RepPredProp(PredPropByAtom(at, CurrentModule));
|
return RepPredProp(PredPropByAtom(at, CurrentModule));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2112,6 +2147,7 @@ YAP_AtomToPred(Atom at)
|
|||||||
static int
|
static int
|
||||||
run_emulator(YAP_dogoalinfo *dgi)
|
run_emulator(YAP_dogoalinfo *dgi)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
choiceptr myB;
|
choiceptr myB;
|
||||||
int out;
|
int out;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
@ -2134,7 +2170,7 @@ run_emulator(YAP_dogoalinfo *dgi)
|
|||||||
B = B->cp_b;
|
B = B->cp_b;
|
||||||
HB = B->cp_h;
|
HB = B->cp_h;
|
||||||
} else {
|
} else {
|
||||||
Yap_StartSlots();
|
Yap_StartSlots( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
P = dgi->p;
|
P = dgi->p;
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
@ -2144,6 +2180,7 @@ run_emulator(YAP_dogoalinfo *dgi)
|
|||||||
X_API int
|
X_API int
|
||||||
YAP_EnterGoal(PredEntry *pe, Term *ptr, YAP_dogoalinfo *dgi)
|
YAP_EnterGoal(PredEntry *pe, Term *ptr, YAP_dogoalinfo *dgi)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
UInt i;
|
UInt i;
|
||||||
choiceptr myB;
|
choiceptr myB;
|
||||||
int out;
|
int out;
|
||||||
@ -2186,6 +2223,7 @@ YAP_EnterGoal(PredEntry *pe, Term *ptr, YAP_dogoalinfo *dgi)
|
|||||||
X_API int
|
X_API int
|
||||||
YAP_RetryGoal(YAP_dogoalinfo *dgi)
|
YAP_RetryGoal(YAP_dogoalinfo *dgi)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
choiceptr myB;
|
choiceptr myB;
|
||||||
int out;
|
int out;
|
||||||
|
|
||||||
@ -2205,6 +2243,7 @@ YAP_RetryGoal(YAP_dogoalinfo *dgi)
|
|||||||
X_API int
|
X_API int
|
||||||
YAP_LeaveGoal(int backtrack, YAP_dogoalinfo *dgi)
|
YAP_LeaveGoal(int backtrack, YAP_dogoalinfo *dgi)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
choiceptr myB;
|
choiceptr myB;
|
||||||
|
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
@ -2246,6 +2285,7 @@ YAP_LeaveGoal(int backtrack, YAP_dogoalinfo *dgi)
|
|||||||
X_API Term
|
X_API Term
|
||||||
YAP_RunGoal(Term t)
|
YAP_RunGoal(Term t)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term out;
|
Term out;
|
||||||
yamop *old_CP = CP;
|
yamop *old_CP = CP;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
@ -2272,6 +2312,7 @@ YAP_RunGoal(Term t)
|
|||||||
X_API Term
|
X_API Term
|
||||||
YAP_RunGoalOnce(Term t)
|
YAP_RunGoalOnce(Term t)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term out;
|
Term out;
|
||||||
yamop *old_CP = CP;
|
yamop *old_CP = CP;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
@ -2308,6 +2349,7 @@ YAP_RunGoalOnce(Term t)
|
|||||||
X_API int
|
X_API int
|
||||||
YAP_RestartGoal(void)
|
YAP_RestartGoal(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
int out;
|
int out;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
if (Yap_AllowRestart) {
|
if (Yap_AllowRestart) {
|
||||||
@ -2318,7 +2360,7 @@ YAP_RestartGoal(void)
|
|||||||
Yap_PrologMode = UserCCallMode;
|
Yap_PrologMode = UserCCallMode;
|
||||||
if (out == FALSE) {
|
if (out == FALSE) {
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
Yap_CloseSlots();
|
Yap_CloseSlots( PASS_REGS1 );
|
||||||
Yap_trust_last();
|
Yap_trust_last();
|
||||||
Yap_AllowRestart = FALSE;
|
Yap_AllowRestart = FALSE;
|
||||||
}
|
}
|
||||||
@ -2332,6 +2374,7 @@ YAP_RestartGoal(void)
|
|||||||
X_API int
|
X_API int
|
||||||
YAP_ShutdownGoal(int backtrack)
|
YAP_ShutdownGoal(int backtrack)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
|
|
||||||
if (Yap_AllowRestart) {
|
if (Yap_AllowRestart) {
|
||||||
@ -2384,6 +2427,7 @@ YAP_ContinueGoal(void)
|
|||||||
X_API void
|
X_API void
|
||||||
YAP_PruneGoal(void)
|
YAP_PruneGoal(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
BACKUP_B();
|
BACKUP_B();
|
||||||
|
|
||||||
while (B->cp_ap != NOCODE) {
|
while (B->cp_ap != NOCODE) {
|
||||||
@ -2400,6 +2444,7 @@ YAP_PruneGoal(void)
|
|||||||
X_API int
|
X_API int
|
||||||
YAP_GoalHasException(Term *t)
|
YAP_GoalHasException(Term *t)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
int out = FALSE;
|
int out = FALSE;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
if (EX) {
|
if (EX) {
|
||||||
@ -2434,6 +2479,7 @@ YAP_GoalHasException(Term *t)
|
|||||||
X_API void
|
X_API void
|
||||||
YAP_ClearExceptions(void)
|
YAP_ClearExceptions(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Yap_ResetExceptionTerm();
|
Yap_ResetExceptionTerm();
|
||||||
if (EX) {
|
if (EX) {
|
||||||
BallTerm = EX;
|
BallTerm = EX;
|
||||||
@ -2472,6 +2518,7 @@ YAP_EndConsult(IOSTREAM *s)
|
|||||||
X_API Term
|
X_API Term
|
||||||
YAP_Read(IOSTREAM *inp)
|
YAP_Read(IOSTREAM *inp)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term t, tpos = TermNil;
|
Term t, tpos = TermNil;
|
||||||
TokEntry *tokstart;
|
TokEntry *tokstart;
|
||||||
|
|
||||||
@ -2534,6 +2581,7 @@ YAP_WriteBuffer(Term t, char *buf, unsigned int sze, int flags)
|
|||||||
X_API char *
|
X_API char *
|
||||||
YAP_CompileClause(Term t)
|
YAP_CompileClause(Term t)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
yamop *codeaddr;
|
yamop *codeaddr;
|
||||||
int mod = CurrentModule;
|
int mod = CurrentModule;
|
||||||
Term tn = TermNil;
|
Term tn = TermNil;
|
||||||
@ -2671,6 +2719,7 @@ construct_init_file(char *boot_file, char *BootFile)
|
|||||||
X_API Int
|
X_API Int
|
||||||
YAP_Init(YAP_init_args *yap_init)
|
YAP_Init(YAP_init_args *yap_init)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
int restore_result;
|
int restore_result;
|
||||||
int do_bootstrap = (yap_init->YapPrologBootFile != NULL);
|
int do_bootstrap = (yap_init->YapPrologBootFile != NULL);
|
||||||
CELL Trail = 0, Stack = 0, Heap = 0, Atts = 0;
|
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->SchedulerLoop,
|
||||||
yap_init->DelayedReleaseLoad
|
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 USE_SYSTEM_MALLOC
|
||||||
if (Trail < MinTrailSpace)
|
if (Trail < MinTrailSpace)
|
||||||
Trail = MinTrailSpace;
|
Trail = MinTrailSpace;
|
||||||
@ -2987,6 +3040,7 @@ YAP_CompareTerms(Term t1, Term t2)
|
|||||||
X_API int
|
X_API int
|
||||||
YAP_Reset(void)
|
YAP_Reset(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
|
|
||||||
/* first, backtrack to the root */
|
/* first, backtrack to the root */
|
||||||
@ -3077,6 +3131,7 @@ YAP_Halt(int i)
|
|||||||
X_API CELL *
|
X_API CELL *
|
||||||
YAP_TopOfLocalStack(void)
|
YAP_TopOfLocalStack(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
return(ASP);
|
return(ASP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3139,6 +3194,7 @@ YAP_UserBackCutCPredicate(char *name, CPredicate init, CPredicate cont, CPredica
|
|||||||
X_API void
|
X_API void
|
||||||
YAP_UserCPredicateWithArgs(char *a, CPredicate f, UInt arity, Term mod)
|
YAP_UserCPredicateWithArgs(char *a, CPredicate f, UInt arity, Term mod)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
Term cm = CurrentModule;
|
Term cm = CurrentModule;
|
||||||
CurrentModule = mod;
|
CurrentModule = mod;
|
||||||
@ -3156,12 +3212,14 @@ YAP_UserCPredicateWithArgs(char *a, CPredicate f, UInt arity, Term mod)
|
|||||||
X_API Term
|
X_API Term
|
||||||
YAP_CurrentModule(void)
|
YAP_CurrentModule(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
return(CurrentModule);
|
return(CurrentModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API Term
|
X_API Term
|
||||||
YAP_SetCurrentModule(Term new)
|
YAP_SetCurrentModule(Term new)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term omod = CurrentModule;
|
Term omod = CurrentModule;
|
||||||
CurrentModule = new;
|
CurrentModule = new;
|
||||||
return omod;
|
return omod;
|
||||||
@ -3270,6 +3328,7 @@ YAP_HaltRegisterHook(HaltHookFunc hook, void * closure)
|
|||||||
X_API char *
|
X_API char *
|
||||||
YAP_cwd(void)
|
YAP_cwd(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
char *buf;
|
char *buf;
|
||||||
int len;
|
int len;
|
||||||
if (!Yap_getcwd(Yap_FileNameBuf, YAP_FILENAME_MAX))
|
if (!Yap_getcwd(Yap_FileNameBuf, YAP_FILENAME_MAX))
|
||||||
@ -3285,6 +3344,7 @@ YAP_cwd(void)
|
|||||||
X_API Term
|
X_API Term
|
||||||
YAP_OpenList(int n)
|
YAP_OpenList(int n)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term t;
|
Term t;
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
|
|
||||||
@ -3403,6 +3463,7 @@ YAP_Record(Term t)
|
|||||||
X_API Term
|
X_API Term
|
||||||
YAP_Recorded(void *handle)
|
YAP_Recorded(void *handle)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term t;
|
Term t;
|
||||||
DBTerm *dbterm = ((DBRecordList *)handle)->dbrecord;
|
DBTerm *dbterm = ((DBRecordList *)handle)->dbrecord;
|
||||||
|
|
||||||
@ -3452,7 +3513,8 @@ YAP_Erase(void *handle)
|
|||||||
X_API Int
|
X_API Int
|
||||||
YAP_ArgsToSlots(int n)
|
YAP_ArgsToSlots(int n)
|
||||||
{
|
{
|
||||||
Int slot = Yap_NewSlots(n);
|
CACHE_REGS
|
||||||
|
Int slot = Yap_NewSlots(n PASS_REGS);
|
||||||
CELL *ptr0 = LCL0+slot, *ptr1=&ARG1;
|
CELL *ptr0 = LCL0+slot, *ptr1=&ARG1;
|
||||||
while (n--) {
|
while (n--) {
|
||||||
*ptr0++ = *ptr1++;
|
*ptr0++ = *ptr1++;
|
||||||
@ -3463,6 +3525,7 @@ YAP_ArgsToSlots(int n)
|
|||||||
X_API void
|
X_API void
|
||||||
YAP_SlotsToArgs(int n, Int slot)
|
YAP_SlotsToArgs(int n, Int slot)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
CELL *ptr0 = LCL0+slot, *ptr1=&ARG1;
|
CELL *ptr0 = LCL0+slot, *ptr1=&ARG1;
|
||||||
while (n--) {
|
while (n--) {
|
||||||
*ptr1++ = *ptr0++;
|
*ptr1++ = *ptr0++;
|
||||||
@ -3501,7 +3564,8 @@ YAP_SetYAPFlag(yap_flag_t flag, int val)
|
|||||||
|
|
||||||
/* Int YAP_VarSlotToNumber(Int) */
|
/* Int YAP_VarSlotToNumber(Int) */
|
||||||
Int YAP_VarSlotToNumber(Int s) {
|
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)
|
if (t < H)
|
||||||
return t-H0;
|
return t-H0;
|
||||||
return t-LCL0;
|
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 asserta_dynam_clause, (PredEntry *, yamop *));
|
||||||
STATIC_PROTO(void assertz_stat_clause, (PredEntry *, yamop *, int));
|
STATIC_PROTO(void assertz_stat_clause, (PredEntry *, yamop *, int));
|
||||||
STATIC_PROTO(void assertz_dynam_clause, (PredEntry *, yamop *));
|
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 not_was_reconsulted, (PredEntry *, Term, int));
|
||||||
STATIC_PROTO(int RemoveIndexation, (PredEntry *));
|
STATIC_PROTO(int RemoveIndexation, (PredEntry *));
|
||||||
#if EMACS
|
#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 mark_pred, (int, PredEntry *));
|
||||||
STATIC_PROTO(void do_toggle_static_predicates_in_use, (int));
|
STATIC_PROTO(void do_toggle_static_predicates_in_use, (int));
|
||||||
#endif
|
#endif
|
||||||
STATIC_PROTO(Int p_number_of_clauses, (void));
|
STATIC_PROTO(Int p_number_of_clauses, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_compile, (void));
|
STATIC_PROTO(Int p_compile, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_compile_dynamic, (void));
|
STATIC_PROTO(Int p_compile_dynamic, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_purge_clauses, (void));
|
STATIC_PROTO(Int p_purge_clauses, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_setspy, (void));
|
STATIC_PROTO(Int p_setspy, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_rmspy, (void));
|
STATIC_PROTO(Int p_rmspy, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_startconsult, (void));
|
STATIC_PROTO(Int p_startconsult, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_showconslultlev, (void));
|
STATIC_PROTO(Int p_showconslultlev, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_endconsult, (void));
|
STATIC_PROTO(Int p_endconsult, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_undefined, (void));
|
STATIC_PROTO(Int p_undefined, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_in_use, (void));
|
STATIC_PROTO(Int p_in_use, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_new_multifile, (void));
|
STATIC_PROTO(Int p_new_multifile, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_is_multifile, (void));
|
STATIC_PROTO(Int p_is_multifile, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_optimizer_on, (void));
|
STATIC_PROTO(Int p_optimizer_on, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_optimizer_off, (void));
|
STATIC_PROTO(Int p_optimizer_off, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_is_dynamic, (void));
|
STATIC_PROTO(Int p_is_dynamic, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_kill_dynamic, (void));
|
STATIC_PROTO(Int p_kill_dynamic, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_compile_mode, (void));
|
STATIC_PROTO(Int p_compile_mode, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_is_profiled, (void));
|
STATIC_PROTO(Int p_is_profiled, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_profile_info, (void));
|
STATIC_PROTO(Int p_profile_info, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_profile_reset, (void));
|
STATIC_PROTO(Int p_profile_reset, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_is_call_counted, (void));
|
STATIC_PROTO(Int p_is_call_counted, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_call_count_info, (void));
|
STATIC_PROTO(Int p_call_count_info, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_call_count_set, (void));
|
STATIC_PROTO(Int p_call_count_set, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_call_count_reset, (void));
|
STATIC_PROTO(Int p_call_count_reset, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_toggle_static_predicates_in_use, (void));
|
STATIC_PROTO(Int p_toggle_static_predicates_in_use, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Atom YapConsultingFile, (void));
|
STATIC_PROTO(Atom YapConsultingFile, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int PredForCode,(yamop *, Atom *, UInt *, Term *));
|
STATIC_PROTO(Int PredForCode,(yamop *, Atom *, UInt *, Term *));
|
||||||
STATIC_PROTO(void kill_first_log_iblock,(LogUpdIndex *, LogUpdIndex *, PredEntry *));
|
STATIC_PROTO(void kill_first_log_iblock,(LogUpdIndex *, LogUpdIndex *, PredEntry *));
|
||||||
STATIC_PROTO(LogUpdIndex *find_owner_log_index,(LogUpdIndex *, yamop *));
|
STATIC_PROTO(LogUpdIndex *find_owner_log_index,(LogUpdIndex *, yamop *));
|
||||||
@ -632,8 +632,9 @@ Yap_PredForChoicePt(choiceptr cp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
InitConsultStack(void)
|
InitConsultStack( void )
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
ConsultLow = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj)*InitialConsultCapacity);
|
ConsultLow = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj)*InitialConsultCapacity);
|
||||||
if (ConsultLow == NULL) {
|
if (ConsultLow == NULL) {
|
||||||
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"No Heap Space in InitCodes");
|
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"No Heap Space in InitCodes");
|
||||||
@ -645,8 +646,9 @@ InitConsultStack(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Yap_ResetConsultStack(void)
|
Yap_ResetConsultStack( void )
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Yap_FreeCodeSpace((char *)ConsultLow);
|
Yap_FreeCodeSpace((char *)ConsultLow);
|
||||||
ConsultBase =
|
ConsultBase =
|
||||||
ConsultSp =
|
ConsultSp =
|
||||||
@ -776,6 +778,7 @@ get_pred(Term t, Term tmod, char *pname)
|
|||||||
|
|
||||||
static Term BlobTermInCodeAdjust(Term t)
|
static Term BlobTermInCodeAdjust(Term t)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
#if TAGS_FAST_OPS
|
#if TAGS_FAST_OPS
|
||||||
return t-ClDiff;
|
return t-ClDiff;
|
||||||
#else
|
#else
|
||||||
@ -801,6 +804,7 @@ static UInt total_megaclause, total_released, nof_megaclauses;
|
|||||||
void
|
void
|
||||||
Yap_BuildMegaClause(PredEntry *ap)
|
Yap_BuildMegaClause(PredEntry *ap)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
StaticClause *cl;
|
StaticClause *cl;
|
||||||
UInt sz;
|
UInt sz;
|
||||||
MegaClause *mcl;
|
MegaClause *mcl;
|
||||||
@ -860,7 +864,7 @@ Yap_BuildMegaClause(PredEntry *ap)
|
|||||||
memcpy((void *)ptr, (void *)cl->ClCode, sz);
|
memcpy((void *)ptr, (void *)cl->ClCode, sz);
|
||||||
if (has_blobs) {
|
if (has_blobs) {
|
||||||
ClDiff = (char *)(ptr)-(char *)cl->ClCode;
|
ClDiff = (char *)(ptr)-(char *)cl->ClCode;
|
||||||
restore_opcodes(ptr, NULL);
|
restore_opcodes(ptr, NULL PASS_REGS);
|
||||||
}
|
}
|
||||||
ptr = (yamop *)((char *)ptr + sz);
|
ptr = (yamop *)((char *)ptr + sz);
|
||||||
if (cl->ClCode == ap->cs.p_code.LastClause)
|
if (cl->ClCode == ap->cs.p_code.LastClause)
|
||||||
@ -953,6 +957,7 @@ split_megaclause(PredEntry *ap)
|
|||||||
static void
|
static void
|
||||||
IPred(PredEntry *ap, UInt NSlots, yamop *next_pc)
|
IPred(PredEntry *ap, UInt NSlots, yamop *next_pc)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
yamop *BaseAddr;
|
yamop *BaseAddr;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -1938,8 +1943,9 @@ assertz_dynam_clause(PredEntry *p, yamop *cp)
|
|||||||
p->cs.p_code.NOfClauses++;
|
p->cs.p_code.NOfClauses++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void expand_consult(void)
|
static void expand_consult( void )
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
consult_obj *new_cl, *new_cs;
|
consult_obj *new_cl, *new_cs;
|
||||||
UInt OldConsultCapacity = ConsultCapacity;
|
UInt OldConsultCapacity = ConsultCapacity;
|
||||||
|
|
||||||
@ -1971,6 +1977,7 @@ static void expand_consult(void)
|
|||||||
static int
|
static int
|
||||||
not_was_reconsulted(PredEntry *p, Term t, int mode)
|
not_was_reconsulted(PredEntry *p, Term t, int mode)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
register consult_obj *fp;
|
register consult_obj *fp;
|
||||||
Prop p0 = AbsProp((PropEntry *)p);
|
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 */ {
|
!(p->PredFlags & MultiFileFlag)) /* we are in reconsult mode */ {
|
||||||
retract_all(p, static_in_use(p,TRUE));
|
retract_all(p, static_in_use(p,TRUE));
|
||||||
}
|
}
|
||||||
p->src.OwnerFile = YapConsultingFile();
|
p->src.OwnerFile = YapConsultingFile( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
return TRUE; /* careful */
|
return TRUE; /* careful */
|
||||||
}
|
}
|
||||||
@ -2007,6 +2014,7 @@ not_was_reconsulted(PredEntry *p, Term t, int mode)
|
|||||||
static void
|
static void
|
||||||
addcl_permission_error(AtomEntry *ap, Int Arity, int in_use)
|
addcl_permission_error(AtomEntry *ap, Int Arity, int in_use)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term t, ti[2];
|
Term t, ti[2];
|
||||||
|
|
||||||
ti[0] = MkAtomTerm(AbsAtom(ap));
|
ti[0] = MkAtomTerm(AbsAtom(ap));
|
||||||
@ -2078,6 +2086,7 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
|
|||||||
2 asserta
|
2 asserta
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
PredEntry *p;
|
PredEntry *p;
|
||||||
int spy_flag = FALSE;
|
int spy_flag = FALSE;
|
||||||
Atom at;
|
Atom at;
|
||||||
@ -2276,7 +2285,7 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
|
|||||||
if (pflags & MultiFileFlag) {
|
if (pflags & MultiFileFlag) {
|
||||||
/* add Info on new clause for multifile predicates to the DB */
|
/* add Info on new clause for multifile predicates to the DB */
|
||||||
Term t[5], tn;
|
Term t[5], tn;
|
||||||
t[0] = MkAtomTerm(YapConsultingFile());
|
t[0] = MkAtomTerm(YapConsultingFile( PASS_REGS1 ));
|
||||||
t[1] = MkAtomTerm(at);
|
t[1] = MkAtomTerm(at);
|
||||||
t[2] = MkIntegerTerm(Arity);
|
t[2] = MkIntegerTerm(Arity);
|
||||||
t[3] = mod;
|
t[3] = mod;
|
||||||
@ -2438,7 +2447,7 @@ where_new_clause(pred_prop, mode)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_compile(void)
|
p_compile( USES_REGS1 )
|
||||||
{ /* '$compile'(+C,+Flags, Mod) */
|
{ /* '$compile'(+C,+Flags, Mod) */
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Term t1 = Deref(ARG2);
|
Term t1 = Deref(ARG2);
|
||||||
@ -2471,7 +2480,7 @@ p_compile(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_compile_dynamic(void)
|
p_compile_dynamic( USES_REGS1 )
|
||||||
{ /* '$compile_dynamic'(+C,+Flags,Mod,-Ref) */
|
{ /* '$compile_dynamic'(+C,+Flags,Mod,-Ref) */
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Term t1 = Deref(ARG2);
|
Term t1 = Deref(ARG2);
|
||||||
@ -2513,7 +2522,7 @@ p_compile_dynamic(void)
|
|||||||
static int consult_level = 0;
|
static int consult_level = 0;
|
||||||
|
|
||||||
static Atom
|
static Atom
|
||||||
YapConsultingFile (void)
|
YapConsultingFile ( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (consult_level == 0) {
|
if (consult_level == 0) {
|
||||||
return(AtomUser);
|
return(AtomUser);
|
||||||
@ -2523,15 +2532,17 @@ YapConsultingFile (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Atom
|
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 */
|
/* consult file *file*, *mode* may be one of either consult or reconsult */
|
||||||
static void
|
static void
|
||||||
init_consult(int mode, char *file)
|
init_consult(int mode, char *file)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (!ConsultSp) {
|
if (!ConsultSp) {
|
||||||
InitConsultStack();
|
InitConsultStack();
|
||||||
}
|
}
|
||||||
@ -2557,7 +2568,7 @@ Yap_init_consult(int mode, char *file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_startconsult(void)
|
p_startconsult( USES_REGS1 )
|
||||||
{ /* '$start_consult'(+Mode) */
|
{ /* '$start_consult'(+Mode) */
|
||||||
Term t;
|
Term t;
|
||||||
char *smode = RepAtom(AtomOfTerm(Deref(ARG1)))->StrOfAE;
|
char *smode = RepAtom(AtomOfTerm(Deref(ARG1)))->StrOfAE;
|
||||||
@ -2570,7 +2581,7 @@ p_startconsult(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_showconslultlev(void)
|
p_showconslultlev( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t;
|
Term t;
|
||||||
|
|
||||||
@ -2579,7 +2590,7 @@ p_showconslultlev(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
end_consult(void)
|
end_consult( USES_REGS1 )
|
||||||
{
|
{
|
||||||
ConsultSp = ConsultBase;
|
ConsultSp = ConsultBase;
|
||||||
ConsultBase = ConsultSp+ConsultSp->c;
|
ConsultBase = ConsultSp+ConsultSp->c;
|
||||||
@ -2593,15 +2604,16 @@ end_consult(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Yap_end_consult(void) {
|
Yap_end_consult( void ) {
|
||||||
end_consult();
|
CACHE_REGS
|
||||||
|
end_consult( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_endconsult(void)
|
p_endconsult( USES_REGS1 )
|
||||||
{ /* '$end_consult' */
|
{ /* '$end_consult' */
|
||||||
end_consult();
|
end_consult( PASS_REGS1 );
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2626,7 +2638,7 @@ Yap_Abolish(PredEntry *pred)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_purge_clauses(void)
|
p_purge_clauses( USES_REGS1 )
|
||||||
{ /* '$purge_clauses'(+Func) */
|
{ /* '$purge_clauses'(+Func) */
|
||||||
PredEntry *pred;
|
PredEntry *pred;
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
@ -2664,7 +2676,7 @@ p_purge_clauses(void)
|
|||||||
******************************************************************/
|
******************************************************************/
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_setspy(void)
|
p_setspy( USES_REGS1 )
|
||||||
{ /* '$set_spy'(+Fun,+M) */
|
{ /* '$set_spy'(+Fun,+M) */
|
||||||
Atom at;
|
Atom at;
|
||||||
PredEntry *pred;
|
PredEntry *pred;
|
||||||
@ -2723,7 +2735,7 @@ p_setspy(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_rmspy(void)
|
p_rmspy( USES_REGS1 )
|
||||||
{ /* '$rm_spy'(+T,+Mod) */
|
{ /* '$rm_spy'(+T,+Mod) */
|
||||||
Atom at;
|
Atom at;
|
||||||
PredEntry *pred;
|
PredEntry *pred;
|
||||||
@ -2791,7 +2803,7 @@ p_rmspy(void)
|
|||||||
******************************************************************/
|
******************************************************************/
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_number_of_clauses(void)
|
p_number_of_clauses( USES_REGS1 )
|
||||||
{ /* '$number_of_clauses'(Predicate,M,N) */
|
{ /* '$number_of_clauses'(Predicate,M,N) */
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Term mod = Deref(ARG2);
|
Term mod = Deref(ARG2);
|
||||||
@ -2819,7 +2831,7 @@ p_number_of_clauses(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_in_use(void)
|
p_in_use( USES_REGS1 )
|
||||||
{ /* '$in_use'(+P,+Mod) */
|
{ /* '$in_use'(+P,+Mod) */
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
Int out;
|
Int out;
|
||||||
@ -2834,7 +2846,7 @@ p_in_use(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_new_multifile(void)
|
p_new_multifile( USES_REGS1 )
|
||||||
{ /* '$new_multifile'(+N,+Ar,+Mod) */
|
{ /* '$new_multifile'(+N,+Ar,+Mod) */
|
||||||
Atom at;
|
Atom at;
|
||||||
int arity;
|
int arity;
|
||||||
@ -2873,7 +2885,7 @@ p_new_multifile(void)
|
|||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_is_multifile(void)
|
p_is_multifile( USES_REGS1 )
|
||||||
{ /* '$is_multifile'(+S,+Mod) */
|
{ /* '$is_multifile'(+S,+Mod) */
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
Int out;
|
Int out;
|
||||||
@ -2888,7 +2900,7 @@ p_is_multifile(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_is_log_updatable(void)
|
p_is_log_updatable( USES_REGS1 )
|
||||||
{ /* '$is_dynamic'(+P) */
|
{ /* '$is_dynamic'(+P) */
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
Int out;
|
Int out;
|
||||||
@ -2903,7 +2915,7 @@ p_is_log_updatable(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_is_source(void)
|
p_is_source( USES_REGS1 )
|
||||||
{ /* '$is_dynamic'(+P) */
|
{ /* '$is_dynamic'(+P) */
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
Int out;
|
Int out;
|
||||||
@ -2918,7 +2930,7 @@ p_is_source(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_owner_file(void)
|
p_owner_file( USES_REGS1 )
|
||||||
{ /* '$owner_file'(+P,M,F) */
|
{ /* '$owner_file'(+P,M,F) */
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
Atom owner;
|
Atom owner;
|
||||||
@ -2941,7 +2953,7 @@ p_owner_file(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_mk_d(void)
|
p_mk_d( USES_REGS1 )
|
||||||
{ /* '$is_dynamic'(+P) */
|
{ /* '$is_dynamic'(+P) */
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
|
|
||||||
@ -2957,7 +2969,7 @@ p_mk_d(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_is_dynamic(void)
|
p_is_dynamic( USES_REGS1 )
|
||||||
{ /* '$is_dynamic'(+P) */
|
{ /* '$is_dynamic'(+P) */
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
Int out;
|
Int out;
|
||||||
@ -2972,7 +2984,7 @@ p_is_dynamic(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_is_metapredicate(void)
|
p_is_metapredicate( USES_REGS1 )
|
||||||
{ /* '$is_metapredicate'(+P) */
|
{ /* '$is_metapredicate'(+P) */
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
Int out;
|
Int out;
|
||||||
@ -2987,7 +2999,7 @@ p_is_metapredicate(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_is_expandgoalormetapredicate(void)
|
p_is_expandgoalormetapredicate( USES_REGS1 )
|
||||||
{ /* '$is_expand_goal_predicate'(+P) */
|
{ /* '$is_expand_goal_predicate'(+P) */
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
@ -3050,7 +3062,7 @@ p_is_expandgoalormetapredicate(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_pred_exists(void)
|
p_pred_exists( USES_REGS1 )
|
||||||
{ /* '$pred_exists'(+P,+M) */
|
{ /* '$pred_exists'(+P,+M) */
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
Int out;
|
Int out;
|
||||||
@ -3069,7 +3081,7 @@ p_pred_exists(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_set_pred_module(void)
|
p_set_pred_module( USES_REGS1 )
|
||||||
{ /* '$set_pred_module'(+P,+Mod) */
|
{ /* '$set_pred_module'(+P,+Mod) */
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
|
|
||||||
@ -3083,7 +3095,7 @@ p_set_pred_module(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_undefined(void)
|
p_undefined( USES_REGS1 )
|
||||||
{ /* '$undefined'(P,Mod) */
|
{ /* '$undefined'(P,Mod) */
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
|
|
||||||
@ -3109,7 +3121,7 @@ p_undefined(void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_kill_dynamic(void)
|
p_kill_dynamic( USES_REGS1 )
|
||||||
{ /* '$kill_dynamic'(P,M) */
|
{ /* '$kill_dynamic'(P,M) */
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
|
|
||||||
@ -3134,21 +3146,21 @@ p_kill_dynamic(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_optimizer_on(void)
|
p_optimizer_on( USES_REGS1 )
|
||||||
{ /* '$optimizer_on' */
|
{ /* '$optimizer_on' */
|
||||||
optimizer_on = TRUE;
|
optimizer_on = TRUE;
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_optimizer_off(void)
|
p_optimizer_off( USES_REGS1 )
|
||||||
{ /* '$optimizer_off' */
|
{ /* '$optimizer_off' */
|
||||||
optimizer_on = FALSE;
|
optimizer_on = FALSE;
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_compile_mode(void)
|
p_compile_mode( USES_REGS1 )
|
||||||
{ /* $compile_mode(Old,New) */
|
{ /* $compile_mode(Old,New) */
|
||||||
Term t2, t3 = MkIntTerm(compile_mode);
|
Term t2, t3 = MkIntTerm(compile_mode);
|
||||||
if (!Yap_unify_constant(ARG1, t3))
|
if (!Yap_unify_constant(ARG1, t3))
|
||||||
@ -3368,7 +3380,7 @@ Yap_find_owner_index(yamop *ipc, PredEntry *ap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
all_envs(CELL *env_ptr)
|
all_envs(CELL *env_ptr USES_REGS)
|
||||||
{
|
{
|
||||||
Term tf = AbsPair(H);
|
Term tf = AbsPair(H);
|
||||||
CELL *start = H;
|
CELL *start = H;
|
||||||
@ -3398,7 +3410,7 @@ all_envs(CELL *env_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
all_cps(choiceptr b_ptr)
|
all_cps(choiceptr b_ptr USES_REGS)
|
||||||
{
|
{
|
||||||
CELL *bp = NULL;
|
CELL *bp = NULL;
|
||||||
CELL *start = H;
|
CELL *start = H;
|
||||||
@ -3428,7 +3440,7 @@ all_cps(choiceptr b_ptr)
|
|||||||
|
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
all_calls(void)
|
all_calls( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term ts[4];
|
Term ts[4];
|
||||||
Functor f = Yap_MkFunctor(AtomLocalSp,4);
|
Functor f = Yap_MkFunctor(AtomLocalSp,4);
|
||||||
@ -3436,8 +3448,8 @@ all_calls(void)
|
|||||||
ts[0] = MkIntegerTerm((Int)P);
|
ts[0] = MkIntegerTerm((Int)P);
|
||||||
ts[1] = MkIntegerTerm((Int)CP);
|
ts[1] = MkIntegerTerm((Int)CP);
|
||||||
if (yap_flags[STACK_DUMP_ON_ERROR_FLAG]) {
|
if (yap_flags[STACK_DUMP_ON_ERROR_FLAG]) {
|
||||||
ts[2] = all_envs(ENV);
|
ts[2] = all_envs(ENV PASS_REGS);
|
||||||
ts[3] = all_cps(B);
|
ts[3] = all_cps(B PASS_REGS);
|
||||||
if (ts[2] == 0L ||
|
if (ts[2] == 0L ||
|
||||||
ts[3] == 0L)
|
ts[3] == 0L)
|
||||||
return 0L;
|
return 0L;
|
||||||
@ -3448,16 +3460,17 @@ all_calls(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Term
|
Term
|
||||||
Yap_all_calls(void)
|
Yap_all_calls( void )
|
||||||
{
|
{
|
||||||
return all_calls();
|
CACHE_REGS
|
||||||
|
return all_calls( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_all_choicepoints(void)
|
p_all_choicepoints( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t;
|
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))) {
|
if (!Yap_gcl(Yap_Error_Size, 1, ENV, gc_P(P,CP))) {
|
||||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while dumping choicepoints");
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while dumping choicepoints");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -3467,10 +3480,10 @@ p_all_choicepoints(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_all_envs(void)
|
p_all_envs( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t;
|
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))) {
|
if (!Yap_gcl(Yap_Error_Size, 1, ENV, gc_P(P,CP))) {
|
||||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while dumping environments");
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while dumping environments");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -3480,10 +3493,10 @@ p_all_envs(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_current_stack(void)
|
p_current_stack( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t;
|
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))) {
|
if (!Yap_gcl(Yap_Error_Size, 1, ENV, gc_P(P,CP))) {
|
||||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while dumping stack");
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while dumping stack");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -3499,7 +3512,7 @@ p_current_stack(void)
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
static Int
|
static Int
|
||||||
p_toggle_static_predicates_in_use(void)
|
p_toggle_static_predicates_in_use( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#if !defined(YAPOR) && !defined(THREADS)
|
#if !defined(YAPOR) && !defined(THREADS)
|
||||||
Term t = Deref(ARG1);
|
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 */
|
/* we hit a expand_index, no point in going on */
|
||||||
static PredEntry *
|
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;
|
PredEntry *pp = codeptr->u.sssllp.p;
|
||||||
if (pc == codeptr) {
|
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 */
|
/* we hit a expand_index, no point in going on */
|
||||||
static PredEntry *
|
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));
|
PredEntry *pp = RepPredProp(Yap_GetPredPropByAtom(AtomFail,CurrentModule));
|
||||||
*startp = *endp = (CODEADDR)FAILCODE;
|
*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 */
|
/* we hit a expand_index, no point in going on */
|
||||||
static PredEntry *
|
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))));
|
PredEntry *pp = ((PredEntry *)(Unsigned(pc)-(CELL)(&(((PredEntry *)NULL)->OpcodeOfPred))));
|
||||||
*startp = (CODEADDR)&(pp->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 */
|
/* we hit a expand_index, no point in going on */
|
||||||
static PredEntry *
|
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))));
|
PredEntry *pp = ((PredEntry *)(Unsigned(pc)-(CELL)(&(((PredEntry *)NULL)->cs.p_code.ExpandCode))));
|
||||||
*startp = (CODEADDR)&(pp->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 *
|
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) {
|
if (pc == YESCODE) {
|
||||||
pp = RepPredProp(Yap_GetPredPropByAtom(AtomTrue,CurrentModule));
|
pp = RepPredProp(Yap_GetPredPropByAtom(AtomTrue,CurrentModule));
|
||||||
@ -3919,7 +3932,7 @@ found_ystop(yamop *pc, int clause_code, CODEADDR *startp, CODEADDR *endp, PredEn
|
|||||||
}
|
}
|
||||||
|
|
||||||
static PredEntry *
|
static PredEntry *
|
||||||
ClauseInfoForCode(yamop *codeptr, CODEADDR *startp, CODEADDR *endp) {
|
ClauseInfoForCode(yamop *codeptr, CODEADDR *startp, CODEADDR *endp USES_REGS) {
|
||||||
yamop *pc;
|
yamop *pc;
|
||||||
PredEntry *pp = NULL;
|
PredEntry *pp = NULL;
|
||||||
int clause_code = FALSE;
|
int clause_code = FALSE;
|
||||||
@ -3938,7 +3951,7 @@ ClauseInfoForCode(yamop *codeptr, CODEADDR *startp, CODEADDR *endp) {
|
|||||||
|
|
||||||
PredEntry *
|
PredEntry *
|
||||||
Yap_PredEntryForCode(yamop *codeptr, find_pred_type where_from, CODEADDR *startp, CODEADDR *endp) {
|
Yap_PredEntryForCode(yamop *codeptr, find_pred_type where_from, CODEADDR *startp, CODEADDR *endp) {
|
||||||
|
CACHE_REGS
|
||||||
if (where_from == FIND_PRED_FROM_CP) {
|
if (where_from == FIND_PRED_FROM_CP) {
|
||||||
PredEntry *pp = PredForChoicePt(codeptr);
|
PredEntry *pp = PredForChoicePt(codeptr);
|
||||||
if (cl_code_in_pred(pp, codeptr, startp, endp)) {
|
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;
|
return pp;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return ClauseInfoForCode(codeptr, startp, endp);
|
return ClauseInfoForCode(codeptr, startp, endp PASS_REGS);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_pred_for_code(void) {
|
p_pred_for_code( USES_REGS1 ) {
|
||||||
yamop *codeptr;
|
yamop *codeptr;
|
||||||
Atom at;
|
Atom at;
|
||||||
UInt arity;
|
UInt arity;
|
||||||
@ -3989,7 +4002,7 @@ p_pred_for_code(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_is_profiled(void)
|
p_is_profiled( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
char *s;
|
char *s;
|
||||||
@ -4021,7 +4034,7 @@ p_is_profiled(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_profile_info(void)
|
p_profile_info( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term mod = Deref(ARG1);
|
Term mod = Deref(ARG1);
|
||||||
Term tfun = Deref(ARG2);
|
Term tfun = Deref(ARG2);
|
||||||
@ -4060,7 +4073,7 @@ p_profile_info(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_profile_reset(void)
|
p_profile_reset( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term mod = Deref(ARG1);
|
Term mod = Deref(ARG1);
|
||||||
Term tfun = Deref(ARG2);
|
Term tfun = Deref(ARG2);
|
||||||
@ -4092,7 +4105,7 @@ p_profile_reset(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_is_call_counted(void)
|
p_is_call_counted( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
char *s;
|
char *s;
|
||||||
@ -4124,7 +4137,7 @@ p_is_call_counted(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_call_count_info(void)
|
p_call_count_info( USES_REGS1 )
|
||||||
{
|
{
|
||||||
return(Yap_unify(MkIntegerTerm(ReductionsCounter),ARG1) &&
|
return(Yap_unify(MkIntegerTerm(ReductionsCounter),ARG1) &&
|
||||||
Yap_unify(MkIntegerTerm(PredEntriesCounter),ARG2) &&
|
Yap_unify(MkIntegerTerm(PredEntriesCounter),ARG2) &&
|
||||||
@ -4132,7 +4145,7 @@ p_call_count_info(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_call_count_reset(void)
|
p_call_count_reset( USES_REGS1 )
|
||||||
{
|
{
|
||||||
ReductionsCounter = 0;
|
ReductionsCounter = 0;
|
||||||
ReductionsCounterOn = FALSE;
|
ReductionsCounterOn = FALSE;
|
||||||
@ -4144,7 +4157,7 @@ p_call_count_reset(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_call_count_set(void)
|
p_call_count_set( USES_REGS1 )
|
||||||
{
|
{
|
||||||
int do_calls = IntOfTerm(ARG2);
|
int do_calls = IntOfTerm(ARG2);
|
||||||
int do_retries = IntOfTerm(ARG4);
|
int do_retries = IntOfTerm(ARG4);
|
||||||
@ -4163,7 +4176,7 @@ p_call_count_set(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_clean_up_dead_clauses(void)
|
p_clean_up_dead_clauses( USES_REGS1 )
|
||||||
{
|
{
|
||||||
while (DeadStaticClauses != NULL) {
|
while (DeadStaticClauses != NULL) {
|
||||||
char *pt = (char *)DeadStaticClauses;
|
char *pt = (char *)DeadStaticClauses;
|
||||||
@ -4193,7 +4206,7 @@ p_clean_up_dead_clauses(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int /* $parent_pred(Module, Name, Arity) */
|
static Int /* $parent_pred(Module, Name, Arity) */
|
||||||
p_parent_pred(void)
|
p_parent_pred( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/* This predicate is called from the debugger.
|
/* This predicate is called from the debugger.
|
||||||
We assume a sequence of the form a -> b */
|
We assume a sequence of the form a -> b */
|
||||||
@ -4211,7 +4224,7 @@ p_parent_pred(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int /* $system_predicate(P) */
|
static Int /* $system_predicate(P) */
|
||||||
p_system_pred(void)
|
p_system_pred( USES_REGS1 )
|
||||||
{
|
{
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
|
|
||||||
@ -4256,7 +4269,7 @@ p_system_pred(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int /* $system_predicate(P) */
|
static Int /* $system_predicate(P) */
|
||||||
p_all_system_pred(void)
|
p_all_system_pred( USES_REGS1 )
|
||||||
{
|
{
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
|
|
||||||
@ -4308,7 +4321,7 @@ p_all_system_pred(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int /* $system_predicate(P) */
|
static Int /* $system_predicate(P) */
|
||||||
p_hide_predicate(void)
|
p_hide_predicate( USES_REGS1 )
|
||||||
{
|
{
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
|
|
||||||
@ -4350,7 +4363,7 @@ p_hide_predicate(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int /* $hidden_predicate(P) */
|
static Int /* $hidden_predicate(P) */
|
||||||
p_hidden_predicate(void)
|
p_hidden_predicate( USES_REGS1 )
|
||||||
{
|
{
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
|
|
||||||
@ -4393,6 +4406,7 @@ p_hidden_predicate(void)
|
|||||||
static Int
|
static Int
|
||||||
fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, yamop *cp_ptr, int first_time)
|
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;
|
LogUpdClause *cl;
|
||||||
Term rtn;
|
Term rtn;
|
||||||
Term Terms[3];
|
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) */
|
static Int /* $hidden_predicate(P) */
|
||||||
p_log_update_clause(void)
|
p_log_update_clause( USES_REGS1 )
|
||||||
{
|
{
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
@ -4527,7 +4541,7 @@ p_log_update_clause(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int /* $hidden_predicate(P) */
|
static Int /* $hidden_predicate(P) */
|
||||||
p_continue_log_update_clause(void)
|
p_continue_log_update_clause( USES_REGS1 )
|
||||||
{
|
{
|
||||||
PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
||||||
yamop *ipc = (yamop *)IntegerOfTerm(ARG2);
|
yamop *ipc = (yamop *)IntegerOfTerm(ARG2);
|
||||||
@ -4539,6 +4553,7 @@ p_continue_log_update_clause(void)
|
|||||||
static Int
|
static Int
|
||||||
fetch_next_lu_clause_erase(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, yamop *cp_ptr, int first_time)
|
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;
|
LogUpdClause *cl;
|
||||||
Term rtn;
|
Term rtn;
|
||||||
Term Terms[3];
|
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) */
|
static Int /* $hidden_predicate(P) */
|
||||||
p_log_update_clause_erase(void)
|
p_log_update_clause_erase( USES_REGS1 )
|
||||||
{
|
{
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
@ -4677,7 +4692,7 @@ p_log_update_clause_erase(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int /* $hidden_predicate(P) */
|
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));
|
PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
||||||
yamop *ipc = (yamop *)IntegerOfTerm(ARG2);
|
yamop *ipc = (yamop *)IntegerOfTerm(ARG2);
|
||||||
@ -4733,6 +4748,7 @@ replace_integer(Term orig, UInt new)
|
|||||||
void /* $hidden_predicate(P) */
|
void /* $hidden_predicate(P) */
|
||||||
Yap_UpdateTimestamps(PredEntry *ap)
|
Yap_UpdateTimestamps(PredEntry *ap)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
choiceptr bptr = B;
|
choiceptr bptr = B;
|
||||||
yamop *cl0 = NEXTOP(PredLogUpdClause0->CodeOfPred,Otapl);
|
yamop *cl0 = NEXTOP(PredLogUpdClause0->CodeOfPred,Otapl);
|
||||||
yamop *cl = NEXTOP(PredLogUpdClause->CodeOfPred,Otapl);
|
yamop *cl = NEXTOP(PredLogUpdClause->CodeOfPred,Otapl);
|
||||||
@ -4859,6 +4875,7 @@ Yap_UpdateTimestamps(PredEntry *ap)
|
|||||||
static Int
|
static Int
|
||||||
fetch_next_static_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, yamop *cp_ptr, int first_time)
|
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;
|
StaticClause *cl;
|
||||||
Term rtn;
|
Term rtn;
|
||||||
Term Terms[3];
|
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) */
|
static Int /* $hidden_predicate(P) */
|
||||||
p_static_clause(void)
|
p_static_clause( USES_REGS1 )
|
||||||
{
|
{
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
@ -5015,7 +5032,7 @@ p_static_clause(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int /* $hidden_predicate(P) */
|
static Int /* $hidden_predicate(P) */
|
||||||
p_nth_clause(void)
|
p_nth_clause( USES_REGS1 )
|
||||||
{
|
{
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
@ -5073,7 +5090,7 @@ p_nth_clause(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int /* $hidden_predicate(P) */
|
static Int /* $hidden_predicate(P) */
|
||||||
p_continue_static_clause(void)
|
p_continue_static_clause( USES_REGS1 )
|
||||||
{
|
{
|
||||||
PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
||||||
yamop *ipc = (yamop *)IntegerOfTerm(ARG2);
|
yamop *ipc = (yamop *)IntegerOfTerm(ARG2);
|
||||||
@ -5224,6 +5241,7 @@ index_ssz(StaticIndex *x)
|
|||||||
static Int
|
static Int
|
||||||
static_statistics(PredEntry *pe)
|
static_statistics(PredEntry *pe)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
UInt sz = 0, cls = 0, isz = 0;
|
UInt sz = 0, cls = 0, isz = 0;
|
||||||
StaticClause *cl = ClauseCodeToStaticClause(pe->cs.p_code.FirstClause);
|
StaticClause *cl = ClauseCodeToStaticClause(pe->cs.p_code.FirstClause);
|
||||||
|
|
||||||
@ -5252,7 +5270,7 @@ static_statistics(PredEntry *pe)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_static_pred_statistics(void)
|
p_static_pred_statistics( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Int out;
|
Int out;
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
@ -5272,7 +5290,7 @@ p_static_pred_statistics(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_predicate_erased_statistics(void)
|
p_predicate_erased_statistics( USES_REGS1 )
|
||||||
{
|
{
|
||||||
UInt sz = 0, cls = 0;
|
UInt sz = 0, cls = 0;
|
||||||
UInt isz = 0, icls = 0;
|
UInt isz = 0, icls = 0;
|
||||||
@ -5307,7 +5325,7 @@ p_predicate_erased_statistics(void)
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
static Int
|
static Int
|
||||||
p_predicate_lu_cps(void)
|
p_predicate_lu_cps( USES_REGS1 )
|
||||||
{
|
{
|
||||||
return Yap_unify(ARG1, MkIntegerTerm(Yap_LiveCps)) &&
|
return Yap_unify(ARG1, MkIntegerTerm(Yap_LiveCps)) &&
|
||||||
Yap_unify(ARG2, MkIntegerTerm(Yap_FreedCps)) &&
|
Yap_unify(ARG2, MkIntegerTerm(Yap_FreedCps)) &&
|
||||||
@ -5317,7 +5335,7 @@ p_predicate_lu_cps(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_program_continuation(void)
|
p_program_continuation( USES_REGS1 )
|
||||||
{
|
{
|
||||||
PredEntry *pe = EnvPreg((yamop *)((ENV_Parent(ENV))[E_CP]));
|
PredEntry *pe = EnvPreg((yamop *)((ENV_Parent(ENV))[E_CP]));
|
||||||
if (pe->ModuleOfPred) {
|
if (pe->ModuleOfPred) {
|
||||||
@ -5344,6 +5362,7 @@ p_program_continuation(void)
|
|||||||
static Term
|
static Term
|
||||||
BuildActivePred(PredEntry *ap, CELL *vect)
|
BuildActivePred(PredEntry *ap, CELL *vect)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
UInt i;
|
UInt i;
|
||||||
|
|
||||||
if (!ap->ArityOfPE) {
|
if (!ap->ArityOfPE) {
|
||||||
@ -5364,7 +5383,7 @@ BuildActivePred(PredEntry *ap, CELL *vect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
UnifyPredInfo(PredEntry *pe, int start_arg) {
|
UnifyPredInfo(PredEntry *pe, int start_arg USES_REGS) {
|
||||||
UInt arity = pe->ArityOfPE;
|
UInt arity = pe->ArityOfPE;
|
||||||
Term tmod, tname;
|
Term tmod, tname;
|
||||||
|
|
||||||
@ -5407,7 +5426,7 @@ ClauseId(yamop *ipc, PredEntry *pe)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_env_info(void)
|
p_env_info( USES_REGS1 )
|
||||||
{
|
{
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
CELL *env = LCL0-IntegerOfTerm(Deref(ARG1));
|
CELL *env = LCL0-IntegerOfTerm(Deref(ARG1));
|
||||||
@ -5427,18 +5446,18 @@ p_env_info(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_cpc_info(void)
|
p_cpc_info( USES_REGS1 )
|
||||||
{
|
{
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
yamop *ipc = (yamop *)IntegerOfTerm(Deref(ARG1));
|
yamop *ipc = (yamop *)IntegerOfTerm(Deref(ARG1));
|
||||||
|
|
||||||
pe = PREVOP(ipc,Osbpp)->u.Osbpp.p0;
|
pe = PREVOP(ipc,Osbpp)->u.Osbpp.p0;
|
||||||
return UnifyPredInfo(pe, 2) &&
|
return UnifyPredInfo(pe, 2 PASS_REGS) &&
|
||||||
Yap_unify(ARG5,MkIntegerTerm(ClauseId(ipc,pe)));
|
Yap_unify(ARG5,MkIntegerTerm(ClauseId(ipc,pe)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_choicepoint_info(void)
|
p_choicepoint_info( USES_REGS1 )
|
||||||
{
|
{
|
||||||
choiceptr cptr = (choiceptr)(LCL0-IntegerOfTerm(Deref(ARG1)));
|
choiceptr cptr = (choiceptr)(LCL0-IntegerOfTerm(Deref(ARG1)));
|
||||||
PredEntry *pe = NULL;
|
PredEntry *pe = NULL;
|
||||||
@ -5608,7 +5627,7 @@ p_choicepoint_info(void)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return UnifyPredInfo(pe, 3) &&
|
return UnifyPredInfo(pe, 3 PASS_REGS) &&
|
||||||
Yap_unify(ARG2, taddr) &&
|
Yap_unify(ARG2, taddr) &&
|
||||||
Yap_unify(ARG6,t) &&
|
Yap_unify(ARG6,t) &&
|
||||||
Yap_unify(ARG7,MkIntegerTerm(ClauseId(ncl,pe)));
|
Yap_unify(ARG7,MkIntegerTerm(ClauseId(ncl,pe)));
|
||||||
@ -5617,6 +5636,7 @@ p_choicepoint_info(void)
|
|||||||
void
|
void
|
||||||
Yap_InitCdMgr(void)
|
Yap_InitCdMgr(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term cm = CurrentModule;
|
Term cm = CurrentModule;
|
||||||
|
|
||||||
Yap_InitCPred("$compile_mode", 2, p_compile_mode, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
Yap_InitCPred("$compile_mode", 2, p_compile_mode, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
/* need to fix overflow handling */
|
/* need to fix overflow handling */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mk_blob(int sz)
|
mk_blob(int sz USES_REGS)
|
||||||
{
|
{
|
||||||
MP_INT *dst;
|
MP_INT *dst;
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ mk_blob(int sz)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static CELL *
|
static CELL *
|
||||||
extend_blob(CELL *start, int sz)
|
extend_blob(CELL *start, int sz USES_REGS)
|
||||||
{
|
{
|
||||||
UInt osize;
|
UInt osize;
|
||||||
MP_INT *dst;
|
MP_INT *dst;
|
||||||
@ -44,9 +44,10 @@ extend_blob(CELL *start, int sz)
|
|||||||
X_API clause_list_t
|
X_API clause_list_t
|
||||||
Yap_ClauseListInit(clause_list_t in)
|
Yap_ClauseListInit(clause_list_t in)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
in->n = 0;
|
in->n = 0;
|
||||||
in->start = H;
|
in->start = H;
|
||||||
mk_blob(0);
|
mk_blob(0 PASS_REGS);
|
||||||
in->end = H;
|
in->end = H;
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
@ -56,6 +57,7 @@ Yap_ClauseListInit(clause_list_t in)
|
|||||||
X_API int
|
X_API int
|
||||||
Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
PredEntry *ap = (PredEntry *)pred;
|
PredEntry *ap = (PredEntry *)pred;
|
||||||
|
|
||||||
/* fprintf(stderr,"cl=%p\n",clause); */
|
/* fprintf(stderr,"cl=%p\n",clause); */
|
||||||
@ -63,13 +65,13 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
if (cl->n == 0) {
|
if (cl->n == 0) {
|
||||||
void **ptr;
|
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;
|
ptr[0] = clause;
|
||||||
} else if (cl->n == 1) {
|
} else if (cl->n == 1) {
|
||||||
yamop **ptr;
|
yamop **ptr;
|
||||||
yamop *code_p, *fclause;
|
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];
|
fclause = ptr[-1];
|
||||||
code_p = (yamop *)(ptr-1);
|
code_p = (yamop *)(ptr-1);
|
||||||
code_p->opc = Yap_opcode(_try_clause);
|
code_p->opc = Yap_opcode(_try_clause);
|
||||||
@ -96,7 +98,7 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
|||||||
} else {
|
} else {
|
||||||
yamop *code_p;
|
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->opc = Yap_opcode(_trust);
|
||||||
code_p->u.Otapl.d = clause;
|
code_p->u.Otapl.d = clause;
|
||||||
code_p->u.Otapl.s = ap->ArityOfPE;
|
code_p->u.Otapl.s = ap->ArityOfPE;
|
||||||
@ -126,6 +128,7 @@ Yap_ClauseListClose(clause_list_t cl)
|
|||||||
X_API int
|
X_API int
|
||||||
Yap_ClauseListDestroy(clause_list_t cl)
|
Yap_ClauseListDestroy(clause_list_t cl)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (cl->end != H)
|
if (cl->end != H)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
H = cl->start;
|
H = cl->start;
|
||||||
@ -136,12 +139,13 @@ Yap_ClauseListDestroy(clause_list_t cl)
|
|||||||
X_API void *
|
X_API void *
|
||||||
Yap_ClauseListToClause(clause_list_t cl)
|
Yap_ClauseListToClause(clause_list_t cl)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
void **ptr;
|
void **ptr;
|
||||||
if (cl->end != H)
|
if (cl->end != H)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (cl->n != 1)
|
if (cl->n != 1)
|
||||||
return NULL;
|
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];
|
return ptr[-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
39
C/cmppreds.c
39
C/cmppreds.c
@ -28,8 +28,8 @@ static char SccsId[] = "%W% %G%";
|
|||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
STATIC_PROTO(Int compare, (Term, Term));
|
STATIC_PROTO(Int compare, (Term, Term));
|
||||||
STATIC_PROTO(Int p_compare, (void));
|
STATIC_PROTO(Int p_compare, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_acomp, (void));
|
STATIC_PROTO(Int p_acomp, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int a_eq, (Term,Term));
|
STATIC_PROTO(Int a_eq, (Term,Term));
|
||||||
STATIC_PROTO(Int a_dif, (Term,Term));
|
STATIC_PROTO(Int a_dif, (Term,Term));
|
||||||
STATIC_PROTO(Int a_gt, (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
|
static int compare_complex(register CELL *pt0, register CELL *pt0_end, register
|
||||||
CELL *pt1)
|
CELL *pt1)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
register CELL **to_visit = (CELL **)H;
|
register CELL **to_visit = (CELL **)H;
|
||||||
register int out = 0;
|
register int out = 0;
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ int Yap_compare_terms(CELL d0, CELL d1)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_compare(void)
|
p_compare( USES_REGS1 )
|
||||||
{ /* compare(?Op,?T1,?T2) */
|
{ /* compare(?Op,?T1,?T2) */
|
||||||
Int r = compare(Deref(ARG2), Deref(ARG3));
|
Int r = compare(Deref(ARG2), Deref(ARG3));
|
||||||
Atom p;
|
Atom p;
|
||||||
@ -479,7 +479,7 @@ flt_cmp(Float dif)
|
|||||||
|
|
||||||
|
|
||||||
static inline Int
|
static inline Int
|
||||||
a_cmp(Term t1, Term t2)
|
a_cmp(Term t1, Term t2 USES_REGS)
|
||||||
{
|
{
|
||||||
ArithError = FALSE;
|
ArithError = FALSE;
|
||||||
if (IsVarTerm(t1)) {
|
if (IsVarTerm(t1)) {
|
||||||
@ -596,20 +596,22 @@ a_cmp(Term t1, Term t2)
|
|||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_acomp(void)
|
p_acomp( USES_REGS1 )
|
||||||
{ /* $a_compare(?R,+X,+Y) */
|
{ /* $a_compare(?R,+X,+Y) */
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
Term t2 = Deref(ARG2);
|
Term t2 = Deref(ARG2);
|
||||||
Int out;
|
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; }
|
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
a_eq(Term t1, Term t2)
|
a_eq(Term t1, Term t2)
|
||||||
{ /* A =:= B */
|
{
|
||||||
|
CACHE_REGS
|
||||||
|
/* A =:= B */
|
||||||
int out;
|
int out;
|
||||||
|
|
||||||
if (IsVarTerm(t1)) {
|
if (IsVarTerm(t1)) {
|
||||||
@ -634,7 +636,7 @@ a_eq(Term t1, Term t2)
|
|||||||
return (FloatOfTerm(t2) == IntegerOfTerm(t1));
|
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; }
|
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||||
return out == 0;
|
return out == 0;
|
||||||
}
|
}
|
||||||
@ -642,7 +644,8 @@ a_eq(Term t1, Term t2)
|
|||||||
static Int
|
static Int
|
||||||
a_dif(Term t1, Term t2)
|
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; }
|
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||||
return out != 0;
|
return out != 0;
|
||||||
}
|
}
|
||||||
@ -650,7 +653,8 @@ a_dif(Term t1, Term t2)
|
|||||||
static Int
|
static Int
|
||||||
a_gt(Term t1, Term t2)
|
a_gt(Term t1, Term t2)
|
||||||
{ /* A > B */
|
{ /* 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; }
|
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||||
return out > 0;
|
return out > 0;
|
||||||
}
|
}
|
||||||
@ -658,7 +662,8 @@ a_gt(Term t1, Term t2)
|
|||||||
static Int
|
static Int
|
||||||
a_ge(Term t1, Term t2)
|
a_ge(Term t1, Term t2)
|
||||||
{ /* A >= B */
|
{ /* 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; }
|
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||||
return out >= 0;
|
return out >= 0;
|
||||||
}
|
}
|
||||||
@ -666,7 +671,8 @@ a_ge(Term t1, Term t2)
|
|||||||
static Int
|
static Int
|
||||||
a_lt(Term t1, Term t2)
|
a_lt(Term t1, Term t2)
|
||||||
{ /* A < B */
|
{ /* 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; }
|
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||||
return out < 0;
|
return out < 0;
|
||||||
}
|
}
|
||||||
@ -674,7 +680,8 @@ a_lt(Term t1, Term t2)
|
|||||||
static Int
|
static Int
|
||||||
a_le(Term t1, Term t2)
|
a_le(Term t1, Term t2)
|
||||||
{ /* A <= B */
|
{ /* 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; }
|
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
|
||||||
return out <= 0;
|
return out <= 0;
|
||||||
}
|
}
|
||||||
@ -701,13 +708,13 @@ a_gen_le(Term t1, Term t2)
|
|||||||
static Int
|
static Int
|
||||||
a_gen_gt(Term t1, Term t2)
|
a_gen_gt(Term t1, Term t2)
|
||||||
{
|
{
|
||||||
return (compare(t1, t2) > 0);
|
return compare(t1, t2) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
a_gen_ge(Term t1, Term t2)
|
a_gen_ge(Term t1, Term t2)
|
||||||
{
|
{
|
||||||
return (compare(t1, t2) >= 0);
|
return compare(t1, t2) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
23
C/compiler.c
23
C/compiler.c
@ -322,6 +322,7 @@ adjust_current_commits(compiler_struct *cglobs) {
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
check_var(Term t, unsigned int level, Int argno, compiler_struct *cglobs) {
|
check_var(Term t, unsigned int level, Int argno, compiler_struct *cglobs) {
|
||||||
|
CACHE_REGS
|
||||||
int flags, new = FALSE;
|
int flags, new = FALSE;
|
||||||
Ventry *v = (Ventry *)t;
|
Ventry *v = (Ventry *)t;
|
||||||
|
|
||||||
@ -498,6 +499,7 @@ reset_vars(Ventry *vtable)
|
|||||||
static Term
|
static Term
|
||||||
optimize_ce(Term t, unsigned int arity, unsigned int level, compiler_struct *cglobs)
|
optimize_ce(Term t, unsigned int arity, unsigned int level, compiler_struct *cglobs)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
CExpEntry *p = cglobs->common_exps;
|
CExpEntry *p = cglobs->common_exps;
|
||||||
int cmp = 0;
|
int cmp = 0;
|
||||||
|
|
||||||
@ -586,6 +588,7 @@ compile_sf_term(Term t, int argno, int level)
|
|||||||
inline static void
|
inline static void
|
||||||
c_args(Term app, unsigned int level, compiler_struct *cglobs)
|
c_args(Term app, unsigned int level, compiler_struct *cglobs)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Functor f = FunctorOfTerm(app);
|
Functor f = FunctorOfTerm(app);
|
||||||
unsigned int Arity = ArityOfFunctor(f);
|
unsigned int Arity = ArityOfFunctor(f);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@ -608,6 +611,7 @@ c_args(Term app, unsigned int level, compiler_struct *cglobs)
|
|||||||
static int
|
static int
|
||||||
try_store_as_dbterm(Term t, Int argno, unsigned int arity, int level, compiler_struct *cglobs)
|
try_store_as_dbterm(Term t, Int argno, unsigned int arity, int level, compiler_struct *cglobs)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
DBTerm *dbt;
|
DBTerm *dbt;
|
||||||
int g;
|
int g;
|
||||||
CELL *h0 = H;
|
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)) {
|
} else if (IsRefTerm(t)) {
|
||||||
PELOCK(40,cglobs->cint.CurrentPred);
|
PELOCK(40,cglobs->cint.CurrentPred);
|
||||||
if (!(cglobs->cint.CurrentPred->PredFlags & (DynamicPredFlag|LogUpdatePredFlag))) {
|
if (!(cglobs->cint.CurrentPred->PredFlags & (DynamicPredFlag|LogUpdatePredFlag))) {
|
||||||
|
CACHE_REGS
|
||||||
UNLOCK(cglobs->cint.CurrentPred->PELock);
|
UNLOCK(cglobs->cint.CurrentPred->PELock);
|
||||||
FAIL("can not compile data base reference",TYPE_ERROR_CALLABLE,t);
|
FAIL("can not compile data base reference",TYPE_ERROR_CALLABLE,t);
|
||||||
} else {
|
} else {
|
||||||
@ -819,6 +824,7 @@ c_arg(Int argno, Term t, unsigned int arity, unsigned int level, compiler_struct
|
|||||||
static void
|
static void
|
||||||
c_eq(Term t1, Term t2, compiler_struct *cglobs)
|
c_eq(Term t1, Term t2, compiler_struct *cglobs)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (t1 == t2) {
|
if (t1 == t2) {
|
||||||
Yap_emit(nop_op, Zero, Zero, &cglobs->cint);
|
Yap_emit(nop_op, Zero, Zero, &cglobs->cint);
|
||||||
return;
|
return;
|
||||||
@ -914,6 +920,7 @@ c_eq(Term t1, Term t2, compiler_struct *cglobs)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
c_test(Int Op, Term t1, compiler_struct *cglobs) {
|
c_test(Int Op, Term t1, compiler_struct *cglobs) {
|
||||||
|
CACHE_REGS
|
||||||
Term t = Deref(t1);
|
Term t = Deref(t1);
|
||||||
|
|
||||||
if (!IsVarTerm(t) || IsNewVar(t)) {
|
if (!IsVarTerm(t) || IsNewVar(t)) {
|
||||||
@ -958,6 +965,7 @@ bip_cons Op,Xk,Ri,C
|
|||||||
static void
|
static void
|
||||||
c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler_struct *cglobs)
|
c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler_struct *cglobs)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
/* compile Z = X Op Y arithmetic function */
|
/* compile Z = X Op Y arithmetic function */
|
||||||
/* first we fetch the arguments */
|
/* first we fetch the arguments */
|
||||||
|
|
||||||
@ -1314,6 +1322,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
|||||||
static void
|
static void
|
||||||
c_functor(Term Goal, Term mod, compiler_struct *cglobs)
|
c_functor(Term Goal, Term mod, compiler_struct *cglobs)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term t1 = ArgOfTerm(1, Goal);
|
Term t1 = ArgOfTerm(1, Goal);
|
||||||
Term t2 = ArgOfTerm(2, Goal);
|
Term t2 = ArgOfTerm(2, Goal);
|
||||||
Term t3 = ArgOfTerm(3, Goal);
|
Term t3 = ArgOfTerm(3, Goal);
|
||||||
@ -1439,6 +1448,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
|||||||
Term M = ArgOfTerm(1, Goal);
|
Term M = ArgOfTerm(1, Goal);
|
||||||
|
|
||||||
if (IsVarTerm(M) || !IsAtomTerm(M)) {
|
if (IsVarTerm(M) || !IsAtomTerm(M)) {
|
||||||
|
CACHE_REGS
|
||||||
if (IsVarTerm(M)) {
|
if (IsVarTerm(M)) {
|
||||||
Yap_Error_TYPE = INSTANTIATION_ERROR;
|
Yap_Error_TYPE = INSTANTIATION_ERROR;
|
||||||
} else {
|
} else {
|
||||||
@ -1455,8 +1465,10 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
|||||||
if (IsVarTerm(Goal)) {
|
if (IsVarTerm(Goal)) {
|
||||||
Goal = Yap_MkApplTerm(FunctorCall, 1, &Goal);
|
Goal = Yap_MkApplTerm(FunctorCall, 1, &Goal);
|
||||||
} else if (IsNumTerm(Goal)) {
|
} else if (IsNumTerm(Goal)) {
|
||||||
|
CACHE_REGS
|
||||||
FAIL("goal can not be a number", TYPE_ERROR_CALLABLE, Goal);
|
FAIL("goal can not be a number", TYPE_ERROR_CALLABLE, Goal);
|
||||||
} else if (IsRefTerm(Goal)) {
|
} else if (IsRefTerm(Goal)) {
|
||||||
|
CACHE_REGS
|
||||||
Yap_Error_TYPE = TYPE_ERROR_DBREF;
|
Yap_Error_TYPE = TYPE_ERROR_DBREF;
|
||||||
Yap_Error_Term = Goal;
|
Yap_Error_Term = Goal;
|
||||||
FAIL("goal argument in static procedure can not be a data base reference", TYPE_ERROR_CALLABLE, 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 (looking_at_commit) {
|
||||||
if (!optimizing_commit && !commitflag) {
|
if (!optimizing_commit && !commitflag) {
|
||||||
|
CACHE_REGS
|
||||||
/* This instruction is placed before
|
/* This instruction is placed before
|
||||||
* the disjunction. This means that
|
* the disjunction. This means that
|
||||||
* the program counter must point
|
* the program counter must point
|
||||||
@ -1734,6 +1747,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (f == FunctorNot || f == FunctorAltNot) {
|
else if (f == FunctorNot || f == FunctorAltNot) {
|
||||||
|
CACHE_REGS
|
||||||
CELL label = (cglobs->labelno += 2);
|
CELL label = (cglobs->labelno += 2);
|
||||||
CELL end_label = (cglobs->labelno += 2);
|
CELL end_label = (cglobs->labelno += 2);
|
||||||
int save = cglobs->onlast;
|
int save = cglobs->onlast;
|
||||||
@ -1773,6 +1787,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (f == FunctorArrow) {
|
else if (f == FunctorArrow) {
|
||||||
|
CACHE_REGS
|
||||||
Term commitvar;
|
Term commitvar;
|
||||||
int save = cglobs->onlast;
|
int save = cglobs->onlast;
|
||||||
|
|
||||||
@ -1884,6 +1899,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
|||||||
#else
|
#else
|
||||||
else if (p->PredFlags & BinaryPredFlag) {
|
else if (p->PredFlags & BinaryPredFlag) {
|
||||||
#endif
|
#endif
|
||||||
|
CACHE_REGS
|
||||||
Term a1 = ArgOfTerm(1,Goal);
|
Term a1 = ArgOfTerm(1,Goal);
|
||||||
|
|
||||||
if (IsVarTerm(a1) && !IsNewVar(a1)) {
|
if (IsVarTerm(a1) && !IsNewVar(a1)) {
|
||||||
@ -2296,6 +2312,7 @@ clear_bvarray(int var, CELL *bvarray
|
|||||||
nbit = ((CELL)1 << var);
|
nbit = ((CELL)1 << var);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (*bvarray & nbit) {
|
if (*bvarray & nbit) {
|
||||||
|
CACHE_REGS
|
||||||
/* someone had already marked this variable: complain */
|
/* someone had already marked this variable: complain */
|
||||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||||
Yap_Error_Term = TermNil;
|
Yap_Error_Term = TermNil;
|
||||||
@ -2339,6 +2356,7 @@ static void
|
|||||||
push_bvmap(int label, PInstr *pcpc, compiler_struct *cglobs)
|
push_bvmap(int label, PInstr *pcpc, compiler_struct *cglobs)
|
||||||
{
|
{
|
||||||
if (bvindex == MAX_DISJUNCTIONS) {
|
if (bvindex == MAX_DISJUNCTIONS) {
|
||||||
|
CACHE_REGS
|
||||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||||
Yap_Error_Term = TermNil;
|
Yap_Error_Term = TermNil;
|
||||||
Yap_ErrorMessage = "Too many embedded disjunctions";
|
Yap_ErrorMessage = "Too many embedded disjunctions";
|
||||||
@ -2362,6 +2380,7 @@ reset_bvmap(CELL *bvarray, int nperm, compiler_struct *cglobs)
|
|||||||
if (bvarray == NULL)
|
if (bvarray == NULL)
|
||||||
|
|
||||||
if (bvindex == 0) {
|
if (bvindex == 0) {
|
||||||
|
CACHE_REGS
|
||||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||||
Yap_Error_Term = TermNil;
|
Yap_Error_Term = TermNil;
|
||||||
Yap_ErrorMessage = "No embedding in disjunctions";
|
Yap_ErrorMessage = "No embedding in disjunctions";
|
||||||
@ -2382,6 +2401,7 @@ static void
|
|||||||
pop_bvmap(CELL *bvarray, int nperm, compiler_struct *cglobs)
|
pop_bvmap(CELL *bvarray, int nperm, compiler_struct *cglobs)
|
||||||
{
|
{
|
||||||
if (bvindex == 0) {
|
if (bvindex == 0) {
|
||||||
|
CACHE_REGS
|
||||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||||
Yap_Error_Term = TermNil;
|
Yap_Error_Term = TermNil;
|
||||||
Yap_ErrorMessage = "Too few embedded disjunctions";
|
Yap_ErrorMessage = "Too few embedded disjunctions";
|
||||||
@ -2652,6 +2672,7 @@ checktemp(Int arg, Int rn, compiler_vm_op ic, compiler_struct *cglobs)
|
|||||||
++target1;
|
++target1;
|
||||||
}
|
}
|
||||||
if (target1 == cglobs->MaxCTemps) {
|
if (target1 == cglobs->MaxCTemps) {
|
||||||
|
CACHE_REGS
|
||||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||||
Yap_Error_Term = TermNil;
|
Yap_Error_Term = TermNil;
|
||||||
Yap_ErrorMessage = "too many temporaries";
|
Yap_ErrorMessage = "too many temporaries";
|
||||||
@ -2785,6 +2806,7 @@ c_layout(compiler_struct *cglobs)
|
|||||||
CheckUnsafe(cglobs->cint.CodeStart, cglobs);
|
CheckUnsafe(cglobs->cint.CodeStart, cglobs);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (cglobs->pbvars != nperm) {
|
if (cglobs->pbvars != nperm) {
|
||||||
|
CACHE_REGS
|
||||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||||
Yap_Error_Term = TermNil;
|
Yap_Error_Term = TermNil;
|
||||||
Yap_ErrorMessage = "wrong number of variables found in bitmap";
|
Yap_ErrorMessage = "wrong number of variables found in bitmap";
|
||||||
@ -3321,6 +3343,7 @@ c_optimize(PInstr *pc)
|
|||||||
yamop *
|
yamop *
|
||||||
Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
|
Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
|
||||||
{ /* compile a prolog clause, copy of clause myst be in ARG1 */
|
{ /* compile a prolog clause, copy of clause myst be in ARG1 */
|
||||||
|
CACHE_REGS
|
||||||
/* returns address of code for clause */
|
/* returns address of code for clause */
|
||||||
Term head, body;
|
Term head, body;
|
||||||
yamop *acode;
|
yamop *acode;
|
||||||
|
@ -111,6 +111,7 @@ AllocCMem (UInt size, struct intermediates *cip)
|
|||||||
else
|
else
|
||||||
blksz = CMEM_BLK_SIZE;
|
blksz = CMEM_BLK_SIZE;
|
||||||
if (!cip->blks) {
|
if (!cip->blks) {
|
||||||
|
CACHE_REGS
|
||||||
if (Yap_CMemFirstBlock) {
|
if (Yap_CMemFirstBlock) {
|
||||||
p = Yap_CMemFirstBlock;
|
p = Yap_CMemFirstBlock;
|
||||||
blksz = Yap_CMemFirstBlockSz;
|
blksz = Yap_CMemFirstBlockSz;
|
||||||
@ -130,6 +131,7 @@ AllocCMem (UInt size, struct intermediates *cip)
|
|||||||
} else {
|
} else {
|
||||||
p = (struct mem_blk *)Yap_AllocCodeSpace(blksz);
|
p = (struct mem_blk *)Yap_AllocCodeSpace(blksz);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
|
CACHE_REGS
|
||||||
Yap_Error_Size = size;
|
Yap_Error_Size = size;
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
siglongjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
|
siglongjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||||
@ -150,6 +152,7 @@ AllocCMem (UInt size, struct intermediates *cip)
|
|||||||
p = cip->freep;
|
p = cip->freep;
|
||||||
cip->freep += size;
|
cip->freep += size;
|
||||||
if (ASP <= CellPtr (cip->freep) + 256) {
|
if (ASP <= CellPtr (cip->freep) + 256) {
|
||||||
|
CACHE_REGS
|
||||||
Yap_Error_Size = 256+((char *)cip->freep - (char *)H);
|
Yap_Error_Size = 256+((char *)cip->freep - (char *)H);
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
siglongjmp(cip->CompilerBotch, OUT_OF_STACK_BOTCH);
|
siglongjmp(cip->CompilerBotch, OUT_OF_STACK_BOTCH);
|
||||||
@ -162,6 +165,7 @@ void
|
|||||||
Yap_ReleaseCMem (struct intermediates *cip)
|
Yap_ReleaseCMem (struct intermediates *cip)
|
||||||
{
|
{
|
||||||
#if USE_SYSTEM_MALLOC
|
#if USE_SYSTEM_MALLOC
|
||||||
|
CACHE_REGS
|
||||||
struct mem_blk *p = cip->blks;
|
struct mem_blk *p = cip->blks;
|
||||||
while (p) {
|
while (p) {
|
||||||
struct mem_blk *nextp = p->u.next;
|
struct mem_blk *nextp = p->u.next;
|
||||||
@ -843,6 +847,7 @@ static char *opformat[] =
|
|||||||
void
|
void
|
||||||
Yap_ShowCode (struct intermediates *cint)
|
Yap_ShowCode (struct intermediates *cint)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
CELL *oldH = H;
|
CELL *oldH = H;
|
||||||
struct PSEUDO *cpc;
|
struct PSEUDO *cpc;
|
||||||
|
|
||||||
|
49
C/corout.c
49
C/corout.c
@ -30,7 +30,7 @@ static char SccsId[]="%W% %G%";
|
|||||||
#ifdef COROUTINING
|
#ifdef COROUTINING
|
||||||
|
|
||||||
/* check if variable was there */
|
/* check if variable was there */
|
||||||
static Term AddVarIfNotThere(Term var , Term dest)
|
static Term AddVarIfNotThere(Term var , Term dest USES_REGS)
|
||||||
{
|
{
|
||||||
Term test = dest;
|
Term test = dest;
|
||||||
while (test != TermNil) {
|
while (test != TermNil) {
|
||||||
@ -45,7 +45,7 @@ static Term AddVarIfNotThere(Term var , Term dest)
|
|||||||
static int can_unify_complex(register CELL *pt0,
|
static int can_unify_complex(register CELL *pt0,
|
||||||
register CELL *pt0_end,
|
register CELL *pt0_end,
|
||||||
register CELL *pt1,
|
register CELL *pt1,
|
||||||
Term *Vars)
|
Term *Vars USES_REGS)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* This is really just unification, folks */
|
/* This is really just unification, folks */
|
||||||
@ -73,7 +73,7 @@ static int can_unify_complex(register CELL *pt0,
|
|||||||
if (IsVarTerm(d1)) {
|
if (IsVarTerm(d1)) {
|
||||||
if (d0 != d1) {
|
if (d0 != d1) {
|
||||||
/* we need to suspend on both variables ! */
|
/* 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
|
/* bind the two variables, we would have to do that to unify
|
||||||
them */
|
them */
|
||||||
if (d1 > d0) { /* youngest */
|
if (d1 > d0) { /* youngest */
|
||||||
@ -88,13 +88,13 @@ static int can_unify_complex(register CELL *pt0,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* oh no, some more variables! */
|
/* oh no, some more variables! */
|
||||||
*Vars = AddVarIfNotThere(d0, *Vars);
|
*Vars = AddVarIfNotThere(d0, *Vars PASS_REGS);
|
||||||
}
|
}
|
||||||
/* now bind it */
|
/* now bind it */
|
||||||
Bind_Global((CELL *)d0, d1);
|
Bind_Global((CELL *)d0, d1);
|
||||||
/* continue the loop */
|
/* continue the loop */
|
||||||
} else if (IsVarTerm(d1)) {
|
} else if (IsVarTerm(d1)) {
|
||||||
*Vars = AddVarIfNotThere(d1, *Vars);
|
*Vars = AddVarIfNotThere(d1, *Vars PASS_REGS);
|
||||||
/* and bind it */
|
/* and bind it */
|
||||||
Bind_Global((CELL *)d1, d0);
|
Bind_Global((CELL *)d1, d0);
|
||||||
/* continue the loop */
|
/* continue the loop */
|
||||||
@ -236,7 +236,7 @@ static int can_unify_complex(register CELL *pt0,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
can_unify(Term t1, Term t2, Term *Vars)
|
can_unify(Term t1, Term t2, Term *Vars USES_REGS)
|
||||||
{
|
{
|
||||||
t1 = Deref(t1);
|
t1 = Deref(t1);
|
||||||
t2 = Deref(t2);
|
t2 = Deref(t2);
|
||||||
@ -274,7 +274,7 @@ can_unify(Term t1, Term t2, Term *Vars)
|
|||||||
} else if (IsPairTerm(t1)) {
|
} else if (IsPairTerm(t1)) {
|
||||||
if (IsPairTerm(t2)) {
|
if (IsPairTerm(t2)) {
|
||||||
return(can_unify_complex(RepPair(t1)-1, RepPair(t1)+1,
|
return(can_unify_complex(RepPair(t1)-1, RepPair(t1)+1,
|
||||||
RepPair(t2)-1, Vars));
|
RepPair(t2)-1, Vars PASS_REGS));
|
||||||
} else return FALSE;
|
} else return FALSE;
|
||||||
} else {
|
} else {
|
||||||
Functor f = FunctorOfTerm(t1);
|
Functor f = FunctorOfTerm(t1);
|
||||||
@ -303,14 +303,14 @@ can_unify(Term t1, Term t2, Term *Vars)
|
|||||||
/* Two complex terms with the same functor */
|
/* Two complex terms with the same functor */
|
||||||
return can_unify_complex(RepAppl(t1),
|
return can_unify_complex(RepAppl(t1),
|
||||||
RepAppl(t1)+ArityOfFunctor(f),
|
RepAppl(t1)+ArityOfFunctor(f),
|
||||||
RepAppl(t2), Vars);
|
RepAppl(t2), Vars PASS_REGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This routine verifies whether a complex has variables. */
|
/* This routine verifies whether a complex has variables. */
|
||||||
static int non_ground_complex(register CELL *pt0,
|
static int non_ground_complex(register CELL *pt0,
|
||||||
register CELL *pt0_end,
|
register CELL *pt0_end,
|
||||||
Term *Var)
|
Term *Var USES_REGS)
|
||||||
{
|
{
|
||||||
|
|
||||||
register CELL **to_visit = (CELL **)Yap_PreAllocCodeSpace();
|
register CELL **to_visit = (CELL **)Yap_PreAllocCodeSpace();
|
||||||
@ -428,7 +428,7 @@ static int non_ground_complex(register CELL *pt0,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
non_ground(Term t, Term *Var)
|
non_ground(Term t, Term *Var USES_REGS)
|
||||||
{
|
{
|
||||||
int out = -1;
|
int out = -1;
|
||||||
while (out < 0) {
|
while (out < 0) {
|
||||||
@ -441,7 +441,7 @@ non_ground(Term t, Term *Var)
|
|||||||
if (IsPrimitiveTerm(t)) {
|
if (IsPrimitiveTerm(t)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (IsPairTerm(t)) {
|
} 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)
|
if (out >= 0)
|
||||||
return out;
|
return out;
|
||||||
} else {
|
} else {
|
||||||
@ -451,7 +451,7 @@ non_ground(Term t, Term *Var)
|
|||||||
}
|
}
|
||||||
out = non_ground_complex(RepAppl(t),
|
out = non_ground_complex(RepAppl(t),
|
||||||
RepAppl(t)+ArityOfFunctor(FunctorOfTerm(t)),
|
RepAppl(t)+ArityOfFunctor(FunctorOfTerm(t)),
|
||||||
Var);
|
Var PASS_REGS);
|
||||||
if (out >= 0)
|
if (out >= 0)
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@ -467,11 +467,11 @@ non_ground(Term t, Term *Var)
|
|||||||
|
|
||||||
/* check whether the two terms unify and return what variables should
|
/* check whether the two terms unify and return what variables should
|
||||||
be bound before the terms are exactly equal */
|
be bound before the terms are exactly equal */
|
||||||
static Int p_can_unify(void)
|
static Int p_can_unify( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#ifdef COROUTINING
|
#ifdef COROUTINING
|
||||||
Term r = TermNil;
|
Term r = TermNil;
|
||||||
if (!can_unify(ARG1, ARG2, &r))
|
if (!can_unify(ARG1, ARG2, &r PASS_REGS))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return Yap_unify(ARG3, r);
|
return Yap_unify(ARG3, r);
|
||||||
#else
|
#else
|
||||||
@ -480,11 +480,11 @@ static Int p_can_unify(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if the term is not ground return a variable in the term */
|
/* 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
|
#ifdef COROUTINING
|
||||||
Term r = TermNil;
|
Term r = TermNil;
|
||||||
if (!non_ground(ARG1, &r))
|
if (!non_ground(ARG1, &r PASS_REGS))
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
return (Yap_unify(ARG2, r));
|
return (Yap_unify(ARG2, r));
|
||||||
#else
|
#else
|
||||||
@ -493,7 +493,7 @@ static Int p_non_ground(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if the term is not ground return a variable in the term */
|
/* 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
|
#ifdef COROUTINING
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
@ -504,25 +504,26 @@ static Int p_coroutining(void)
|
|||||||
|
|
||||||
#if COROUTINING
|
#if COROUTINING
|
||||||
static Term
|
static Term
|
||||||
ListOfWokenGoals(void) {
|
ListOfWokenGoals( USES_REGS1 ) {
|
||||||
return Yap_ReadTimedVar(WokenGoals);
|
return Yap_ReadTimedVar(WokenGoals);
|
||||||
}
|
}
|
||||||
|
|
||||||
Term
|
Term
|
||||||
Yap_ListOfWokenGoals(void) {
|
Yap_ListOfWokenGoals(void) {
|
||||||
return ListOfWokenGoals();
|
CACHE_REGS
|
||||||
|
return ListOfWokenGoals( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* return a list of awoken goals */
|
/* return a list of awoken goals */
|
||||||
static Int p_awoken_goals(void)
|
static Int p_awoken_goals( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#ifdef COROUTINING
|
#ifdef COROUTINING
|
||||||
Term WGs = Yap_ReadTimedVar(WokenGoals);
|
Term WGs = Yap_ReadTimedVar(WokenGoals);
|
||||||
if (WGs == TermNil) {
|
if (WGs == TermNil) {
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
WGs = ListOfWokenGoals();
|
WGs = ListOfWokenGoals( PASS_REGS1 );
|
||||||
Yap_UpdateTimedVar(WokenGoals, TermNil);
|
Yap_UpdateTimedVar(WokenGoals, TermNil);
|
||||||
return(Yap_unify(ARG1,WGs));
|
return(Yap_unify(ARG1,WGs));
|
||||||
#else
|
#else
|
||||||
@ -531,7 +532,7 @@ static Int p_awoken_goals(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_yap_has_rational_trees(void)
|
p_yap_has_rational_trees( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#if RATIONAL_TREES
|
#if RATIONAL_TREES
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -541,7 +542,7 @@ p_yap_has_rational_trees(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_yap_has_coroutining(void)
|
p_yap_has_coroutining( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#if COROUTINING
|
#if COROUTINING
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -551,7 +552,7 @@ p_yap_has_coroutining(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Yap_InitCoroutPreds(void)
|
Yap_InitCoroutPreds( void )
|
||||||
{
|
{
|
||||||
#ifdef COROUTINING
|
#ifdef COROUTINING
|
||||||
Atom at;
|
Atom at;
|
||||||
|
@ -5,11 +5,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void cut_c_initialize(void){
|
void cut_c_initialize(void){
|
||||||
|
CACHE_REGS
|
||||||
Yap_REGS.CUT_C_TOP=(cut_c_str_ptr)Yap_LocalBase;
|
Yap_REGS.CUT_C_TOP=(cut_c_str_ptr)Yap_LocalBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Removes a choice_point from the stack*/
|
/*Removes a choice_point from the stack*/
|
||||||
void cut_c_pop(void){
|
void cut_c_pop(void){
|
||||||
|
CACHE_REGS
|
||||||
cut_c_str_ptr to_delete = NULL;
|
cut_c_str_ptr to_delete = NULL;
|
||||||
if (((CELL *)Yap_REGS.CUT_C_TOP) == ((CELL *)Yap_LocalBase))
|
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*/
|
/*Insert a choice_point in the stack*/
|
||||||
void cut_c_push(cut_c_str_ptr new_top){
|
void cut_c_push(cut_c_str_ptr new_top){
|
||||||
|
CACHE_REGS
|
||||||
new_top->before = Yap_REGS.CUT_C_TOP;
|
new_top->before = Yap_REGS.CUT_C_TOP;
|
||||||
Yap_REGS.CUT_C_TOP=new_top;
|
Yap_REGS.CUT_C_TOP=new_top;
|
||||||
return;
|
return;
|
||||||
|
@ -24,15 +24,15 @@ static char SccsId[] = "%W% %G%";
|
|||||||
|
|
||||||
#include "Yatom.h"
|
#include "Yatom.h"
|
||||||
|
|
||||||
STD_PROTO(static Int p_get_depth_limit, (void));
|
STD_PROTO(static Int p_get_depth_limit, ( USES_REGS1 ));
|
||||||
STD_PROTO(static Int p_set_depth_limit, (void));
|
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))));
|
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);
|
Term d = Deref(ARG1);
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ static Int p_set_depth_limit(void)
|
|||||||
return(TRUE);
|
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);
|
Term d = Deref(ARG1);
|
||||||
|
|
||||||
|
35
C/errors.c
35
C/errors.c
@ -32,8 +32,8 @@
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
STATIC_PROTO (int hidden, (Atom));
|
STATIC_PROTO (int hidden, (Atom));
|
||||||
STATIC_PROTO (int legal_env, (CELL *));
|
STATIC_PROTO (int legal_env, (CELL * CACHE_TYPE));
|
||||||
void STD_PROTO (DumpActiveGoals, (void));
|
void STD_PROTO (DumpActiveGoals, ( CACHE_TYPE1 ));
|
||||||
STATIC_PROTO (void detect_bug_location, (yamop *,find_pred_type,char *, int));
|
STATIC_PROTO (void detect_bug_location, (yamop *,find_pred_type,char *, int));
|
||||||
|
|
||||||
#define ONHEAP(ptr) (CellPtr(ptr) >= CellPtr(Yap_HeapBase) && CellPtr(ptr) < CellPtr(HeapTop))
|
#define ONHEAP(ptr) (CellPtr(ptr) >= CellPtr(Yap_HeapBase) && CellPtr(ptr) < CellPtr(HeapTop))
|
||||||
@ -56,7 +56,7 @@ hidden (Atom at)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
legal_env (CELL *ep)
|
legal_env (CELL *ep USES_REGS)
|
||||||
{
|
{
|
||||||
CELL cp, ps;
|
CELL cp, ps;
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
@ -77,7 +77,7 @@ legal_env (CELL *ep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DumpActiveGoals (void)
|
DumpActiveGoals ( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/* try to dump active goals */
|
/* try to dump active goals */
|
||||||
CELL *ep = YENV; /* and current environment */
|
CELL *ep = YENV; /* and current environment */
|
||||||
@ -86,9 +86,9 @@ DumpActiveGoals (void)
|
|||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
int first = 1;
|
int first = 1;
|
||||||
|
|
||||||
if (legal_env (YENV) && YENV < ENV)
|
if (legal_env (YENV PASS_REGS) && YENV < ENV)
|
||||||
ep = YENV;
|
ep = YENV;
|
||||||
else if (legal_env (ENV))
|
else if (legal_env (ENV PASS_REGS))
|
||||||
ep = ENV;
|
ep = ENV;
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
@ -226,7 +226,7 @@ detect_bug_location(yamop *yap_pc, find_pred_type where_from, char *tp, int psiz
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
handled_exception(void)
|
handled_exception( USES_REGS1 )
|
||||||
{
|
{
|
||||||
yamop *pos = NEXTOP(PredDollarCatch->cs.p_code.TrueCodeOfPred,l);
|
yamop *pos = NEXTOP(PredDollarCatch->cs.p_code.TrueCodeOfPred,l);
|
||||||
int found_handler = FALSE;
|
int found_handler = FALSE;
|
||||||
@ -251,7 +251,7 @@ handled_exception(void)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dump_stack(void)
|
dump_stack( USES_REGS1 )
|
||||||
{
|
{
|
||||||
choiceptr b_ptr = B;
|
choiceptr b_ptr = B;
|
||||||
CELL *env_ptr = ENV;
|
CELL *env_ptr = ENV;
|
||||||
@ -260,7 +260,7 @@ dump_stack(void)
|
|||||||
int max_count = 200;
|
int max_count = 200;
|
||||||
|
|
||||||
/* check if handled */
|
/* check if handled */
|
||||||
if (handled_exception())
|
if (handled_exception( PASS_REGS1 ))
|
||||||
return;
|
return;
|
||||||
#if DEBUG
|
#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);
|
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
|
static void
|
||||||
error_exit_yap (int value)
|
error_exit_yap (int value)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (!(Yap_PrologMode & BootMode)) {
|
if (!(Yap_PrologMode & BootMode)) {
|
||||||
dump_stack();
|
dump_stack( PASS_REGS1 );
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -362,6 +363,7 @@ error_exit_yap (int value)
|
|||||||
void
|
void
|
||||||
Yap_bug_location(yamop *pc)
|
Yap_bug_location(yamop *pc)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
detect_bug_location(pc, FIND_PRED_FROM_ANYWHERE, (char *)H, 256);
|
detect_bug_location(pc, FIND_PRED_FROM_ANYWHERE, (char *)H, 256);
|
||||||
fprintf(stderr,"%s\n",(char *)H);
|
fprintf(stderr,"%s\n",(char *)H);
|
||||||
}
|
}
|
||||||
@ -377,6 +379,7 @@ static char tmpbuf[YAP_BUF_SIZE];
|
|||||||
yamop *
|
yamop *
|
||||||
Yap_Error(yap_error_number type, Term where, char *format,...)
|
Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
va_list ap;
|
va_list ap;
|
||||||
CELL nt[3];
|
CELL nt[3];
|
||||||
Functor fun;
|
Functor fun;
|
||||||
@ -492,7 +495,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
|||||||
error_exit_yap (1);
|
error_exit_yap (1);
|
||||||
}
|
}
|
||||||
#ifdef DEBUGX
|
#ifdef DEBUGX
|
||||||
DumpActiveGoals();
|
DumpActiveGoals( USES_REGS1 );
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case INTERNAL_ERROR:
|
case INTERNAL_ERROR:
|
||||||
@ -1050,7 +1053,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
|||||||
int i;
|
int i;
|
||||||
Term ti[1];
|
Term ti[1];
|
||||||
|
|
||||||
dump_stack();
|
dump_stack( PASS_REGS1 );
|
||||||
ti[0] = MkAtomTerm(AtomCodeSpace);
|
ti[0] = MkAtomTerm(AtomCodeSpace);
|
||||||
i = strlen(tmpbuf);
|
i = strlen(tmpbuf);
|
||||||
nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti);
|
nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti);
|
||||||
@ -1065,7 +1068,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
|||||||
int i;
|
int i;
|
||||||
Term ti[1];
|
Term ti[1];
|
||||||
|
|
||||||
dump_stack();
|
dump_stack( PASS_REGS1 );
|
||||||
i = strlen(tmpbuf);
|
i = strlen(tmpbuf);
|
||||||
ti[0] = MkAtomTerm(AtomStack);
|
ti[0] = MkAtomTerm(AtomStack);
|
||||||
nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti);
|
nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti);
|
||||||
@ -1080,7 +1083,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
|||||||
int i;
|
int i;
|
||||||
Term ti[1];
|
Term ti[1];
|
||||||
|
|
||||||
dump_stack();
|
dump_stack( PASS_REGS1 );
|
||||||
i = strlen(tmpbuf);
|
i = strlen(tmpbuf);
|
||||||
ti[0] = MkAtomTerm(AtomAttributes);
|
ti[0] = MkAtomTerm(AtomAttributes);
|
||||||
nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti);
|
nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti);
|
||||||
@ -1095,7 +1098,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
|||||||
int i;
|
int i;
|
||||||
Term ti[1];
|
Term ti[1];
|
||||||
|
|
||||||
dump_stack();
|
dump_stack( PASS_REGS1 );
|
||||||
i = strlen(tmpbuf);
|
i = strlen(tmpbuf);
|
||||||
tp = tmpbuf+i;
|
tp = tmpbuf+i;
|
||||||
ti[0] = MkAtomTerm(AtomUnificationStack);
|
ti[0] = MkAtomTerm(AtomUnificationStack);
|
||||||
@ -1110,7 +1113,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
|||||||
int i;
|
int i;
|
||||||
Term ti[1];
|
Term ti[1];
|
||||||
|
|
||||||
dump_stack();
|
dump_stack( PASS_REGS1 );
|
||||||
i = strlen(tmpbuf);
|
i = strlen(tmpbuf);
|
||||||
ti[0] = MkAtomTerm(AtomTrail);
|
ti[0] = MkAtomTerm(AtomTrail);
|
||||||
nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti);
|
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;
|
yap_error_number Yap_matherror = YAP_NO_ERROR;
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
Eval(Term t)
|
Eval(Term t USES_REGS)
|
||||||
{
|
{
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
ArithError = TRUE;
|
ArithError = TRUE;
|
||||||
@ -78,7 +78,7 @@ Eval(Term t)
|
|||||||
RepAtom(name)->StrOfAE,n);
|
RepAtom(name)->StrOfAE,n);
|
||||||
}
|
}
|
||||||
*RepAppl(t) = (CELL)AtomFoundVar;
|
*RepAppl(t) = (CELL)AtomFoundVar;
|
||||||
t1 = Eval(ArgOfTerm(1,t));
|
t1 = Eval(ArgOfTerm(1,t) PASS_REGS);
|
||||||
if (t1 == 0L) {
|
if (t1 == 0L) {
|
||||||
*RepAppl(t) = (CELL)fun;
|
*RepAppl(t) = (CELL)fun;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -87,7 +87,7 @@ Eval(Term t)
|
|||||||
*RepAppl(t) = (CELL)fun;
|
*RepAppl(t) = (CELL)fun;
|
||||||
return Yap_eval_unary(p->FOfEE, t1);
|
return Yap_eval_unary(p->FOfEE, t1);
|
||||||
}
|
}
|
||||||
t2 = Eval(ArgOfTerm(2,t));
|
t2 = Eval(ArgOfTerm(2,t) PASS_REGS);
|
||||||
*RepAppl(t) = (CELL)fun;
|
*RepAppl(t) = (CELL)fun;
|
||||||
if (t2 == 0L)
|
if (t2 == 0L)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -98,14 +98,15 @@ Eval(Term t)
|
|||||||
return Yap_ArithError(TYPE_ERROR_EVALUABLE, t,
|
return Yap_ArithError(TYPE_ERROR_EVALUABLE, t,
|
||||||
"string must contain a single character to be evaluated as an arithmetic expression");
|
"string must contain a single character to be evaluated as an arithmetic expression");
|
||||||
}
|
}
|
||||||
return Eval(HeadOfTerm(t));
|
return Eval(HeadOfTerm(t) PASS_REGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Term
|
Term
|
||||||
Yap_InnerEval(Term t)
|
Yap_InnerEval(Term t)
|
||||||
{
|
{
|
||||||
return Eval(t);
|
CACHE_REGS
|
||||||
|
return Eval(t PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BEAM
|
#ifdef BEAM
|
||||||
@ -125,11 +126,11 @@ BEAM_is(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_is(void)
|
p_is( USES_REGS1 )
|
||||||
{ /* X is Y */
|
{ /* X is Y */
|
||||||
Term out = 0L;
|
Term out = 0L;
|
||||||
|
|
||||||
while (!(out = Eval(Deref(ARG2)))) {
|
while (!(out = Eval(Deref(ARG2) PASS_REGS))) {
|
||||||
if (Yap_Error_TYPE == RESOURCE_ERROR_STACK) {
|
if (Yap_Error_TYPE == RESOURCE_ERROR_STACK) {
|
||||||
Yap_Error_TYPE = YAP_NO_ERROR;
|
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||||
if (!Yap_gcl(Yap_Error_Size, 2, ENV, CP)) {
|
if (!Yap_gcl(Yap_Error_Size, 2, ENV, CP)) {
|
||||||
@ -147,6 +148,7 @@ p_is(void)
|
|||||||
Int
|
Int
|
||||||
Yap_ArithError(yap_error_number type, Term where, char *format,...)
|
Yap_ArithError(yap_error_number type, Term where, char *format,...)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
ArithError = TRUE;
|
ArithError = TRUE;
|
||||||
|
248
C/globals.c
248
C/globals.c
@ -102,7 +102,7 @@ CreateNewArena(CELL *ptr, UInt size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
NewArena(UInt size, UInt arity, CELL *where)
|
NewArena(UInt size, UInt arity, CELL *where USES_REGS)
|
||||||
{
|
{
|
||||||
Term t;
|
Term t;
|
||||||
UInt new_size;
|
UInt new_size;
|
||||||
@ -128,7 +128,7 @@ NewArena(UInt size, UInt arity, CELL *where)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_allocate_arena(void)
|
p_allocate_arena( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
@ -138,12 +138,12 @@ p_allocate_arena(void)
|
|||||||
Yap_Error(TYPE_ERROR_INTEGER,t,"allocate_arena");
|
Yap_Error(TYPE_ERROR_INTEGER,t,"allocate_arena");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return Yap_unify(ARG2,NewArena(IntegerOfTerm(t), 1, NULL));
|
return Yap_unify(ARG2,NewArena(IntegerOfTerm(t), 1, NULL PASS_REGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_default_arena_size(void)
|
p_default_arena_size( USES_REGS1 )
|
||||||
{
|
{
|
||||||
return Yap_unify(ARG1,MkIntegerTerm(ArenaSz(GlobalArena)));
|
return Yap_unify(ARG1,MkIntegerTerm(ArenaSz(GlobalArena)));
|
||||||
}
|
}
|
||||||
@ -152,11 +152,12 @@ p_default_arena_size(void)
|
|||||||
void
|
void
|
||||||
Yap_AllocateDefaultArena(Int gsize, Int attsize)
|
Yap_AllocateDefaultArena(Int gsize, Int attsize)
|
||||||
{
|
{
|
||||||
GlobalArena = NewArena(gsize, 2, NULL);
|
CACHE_REGS
|
||||||
|
GlobalArena = NewArena(gsize, 2, NULL PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
adjust_cps(UInt size)
|
adjust_cps(UInt size USES_REGS)
|
||||||
{
|
{
|
||||||
/* adjust possible back pointers in choice-point stack */
|
/* adjust possible back pointers in choice-point stack */
|
||||||
choiceptr b_ptr = B;
|
choiceptr b_ptr = B;
|
||||||
@ -168,7 +169,7 @@ adjust_cps(UInt size)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
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++;
|
ArenaOverflows++;
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
@ -192,9 +193,9 @@ GrowArena(Term arena, CELL *pt, UInt old_size, UInt size, UInt arity)
|
|||||||
arena = XREGS[arity+1];
|
arena = XREGS[arity+1];
|
||||||
/* we don't know if the GC added junk on top of the global */
|
/* we don't know if the GC added junk on top of the global */
|
||||||
pt = ArenaLimit(arena);
|
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;
|
H += size;
|
||||||
} else {
|
} else {
|
||||||
XREGS[arity+1] = arena;
|
XREGS[arity+1] = arena;
|
||||||
@ -220,6 +221,7 @@ GrowArena(Term arena, CELL *pt, UInt old_size, UInt size, UInt arity)
|
|||||||
CELL *
|
CELL *
|
||||||
Yap_GetFromArena(Term *arenap, UInt cells, UInt arity)
|
Yap_GetFromArena(Term *arenap, UInt cells, UInt arity)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
restart:
|
restart:
|
||||||
{
|
{
|
||||||
Term arena = *arenap;
|
Term arena = *arenap;
|
||||||
@ -234,7 +236,7 @@ Yap_GetFromArena(Term *arenap, UInt cells, UInt arity)
|
|||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
if (base+cells > max-1024) {
|
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;
|
return NULL;
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
@ -247,7 +249,7 @@ Yap_GetFromArena(Term *arenap, UInt cells, UInt arity)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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;
|
UInt new_size;
|
||||||
|
|
||||||
@ -261,7 +263,7 @@ CloseArena(CELL *oldH, CELL *oldHB, CELL *oldASP, Term *oldArenaP, UInt old_size
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
clean_dirty_tr(tr_fr_ptr TR0) {
|
clean_dirty_tr(tr_fr_ptr TR0 USES_REGS) {
|
||||||
if (TR != TR0) {
|
if (TR != TR0) {
|
||||||
tr_fr_ptr pt = TR0;
|
tr_fr_ptr pt = TR0;
|
||||||
|
|
||||||
@ -282,7 +284,7 @@ clean_dirty_tr(tr_fr_ptr TR0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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();
|
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;
|
CELL new;
|
||||||
|
|
||||||
bp = to_visit;
|
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;
|
goto overflow;
|
||||||
}
|
}
|
||||||
to_visit = bp;
|
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 */
|
/* restore our nice, friendly, term to its original state */
|
||||||
HB = HB0;
|
HB = HB0;
|
||||||
clean_dirty_tr(TR0);
|
clean_dirty_tr(TR0 PASS_REGS);
|
||||||
/* follow chain of multi-assigned variables */
|
/* follow chain of multi-assigned variables */
|
||||||
close_attvar_chain(dvarsmin, dvarsmax);
|
close_attvar_chain(dvarsmin, dvarsmax);
|
||||||
return 0;
|
return 0;
|
||||||
@ -591,7 +593,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
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);
|
UInt old_size = ArenaSz(arena);
|
||||||
CELL *oldH = H;
|
CELL *oldH = H;
|
||||||
@ -612,14 +614,14 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
|
|||||||
*H = t;
|
*H = t;
|
||||||
Hi = H+1;
|
Hi = H+1;
|
||||||
H += 2;
|
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;
|
goto error_handler;
|
||||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||||
return Hi[0];
|
return Hi[0];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (share && VarOfTerm(t) > ArenaPt(arena)) {
|
if (share && VarOfTerm(t) > ArenaPt(arena)) {
|
||||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
tn = MkVarTerm();
|
tn = MkVarTerm();
|
||||||
@ -627,7 +629,7 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
|
|||||||
res = -1;
|
res = -1;
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||||
return tn;
|
return tn;
|
||||||
} else if (IsAtomOrIntTerm(t)) {
|
} else if (IsAtomOrIntTerm(t)) {
|
||||||
return t;
|
return t;
|
||||||
@ -645,10 +647,10 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
|
|||||||
Hi = H;
|
Hi = H;
|
||||||
tf = AbsPair(H);
|
tf = AbsPair(H);
|
||||||
H += 2;
|
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;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||||
return tf;
|
return tf;
|
||||||
} else {
|
} else {
|
||||||
Functor f;
|
Functor f;
|
||||||
@ -669,7 +671,7 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
|
|||||||
if (IsExtensionFunctor(f)) {
|
if (IsExtensionFunctor(f)) {
|
||||||
switch((CELL)f) {
|
switch((CELL)f) {
|
||||||
case (CELL)FunctorDBRef:
|
case (CELL)FunctorDBRef:
|
||||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||||
return t;
|
return t;
|
||||||
case (CELL)FunctorLongInt:
|
case (CELL)FunctorLongInt:
|
||||||
if (H > ASP - (MIN_ARENA_SIZE+3)) {
|
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;
|
res = -1;
|
||||||
goto error_handler;
|
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;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||||
return tf;
|
return tf;
|
||||||
}
|
}
|
||||||
error_handler:
|
error_handler:
|
||||||
H = HB;
|
H = HB;
|
||||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||||
XREGS[arity+1] = t;
|
XREGS[arity+1] = t;
|
||||||
XREGS[arity+2] = arena;
|
XREGS[arity+2] = arena;
|
||||||
XREGS[arity+3] = (CELL)newarena;
|
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:
|
case -1:
|
||||||
if (arena == GlobalArena)
|
if (arena == GlobalArena)
|
||||||
GlobalArenaOverflows++;
|
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);
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
@ -760,7 +762,7 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
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);
|
UInt old_size = ArenaSz(arena);
|
||||||
CELL *oldH = H;
|
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) {
|
if (H > ASP-MIN_ARENA_SIZE) {
|
||||||
/* overflow */
|
/* overflow */
|
||||||
H = HB;
|
H = HB;
|
||||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||||
XREGS[arity+1] = arena;
|
XREGS[arity+1] = arena;
|
||||||
XREGS[arity+2] = (CELL)newarena;
|
XREGS[arity+2] = (CELL)newarena;
|
||||||
{
|
{
|
||||||
@ -791,7 +793,7 @@ CreateTermInArena(Term arena, Atom Na, UInt Nar, UInt arity, Term *newarena, Ter
|
|||||||
HB = oldHB;
|
HB = oldHB;
|
||||||
if (arena == GlobalArena)
|
if (arena == GlobalArena)
|
||||||
GlobalArenaOverflows++;
|
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");
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while creating large global term");
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
@ -813,12 +815,12 @@ CreateTermInArena(Term arena, Atom Na, UInt Nar, UInt arity, Term *newarena, Ter
|
|||||||
HB0[i] = init;
|
HB0[i] = init;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CloseArena(oldH, oldHB, oldASP, newarena, old_size);
|
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
|
||||||
return tf;
|
return tf;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static GlobalEntry *
|
inline static GlobalEntry *
|
||||||
FindGlobalEntry(Atom at)
|
FindGlobalEntry(Atom at USES_REGS)
|
||||||
/* get predicate entry for ap/arity; create it if neccessary. */
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
||||||
{
|
{
|
||||||
Prop p0;
|
Prop p0;
|
||||||
@ -843,7 +845,7 @@ FindGlobalEntry(Atom at)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline static GlobalEntry *
|
inline static GlobalEntry *
|
||||||
GetGlobalEntry(Atom at)
|
GetGlobalEntry(Atom at USES_REGS)
|
||||||
/* get predicate entry for ap/arity; create it if neccessary. */
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
||||||
{
|
{
|
||||||
Prop p0;
|
Prop p0;
|
||||||
@ -881,7 +883,7 @@ GetGlobalEntry(Atom at)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static UInt
|
static UInt
|
||||||
garena_overflow_size(CELL *arena)
|
garena_overflow_size(CELL *arena USES_REGS)
|
||||||
{
|
{
|
||||||
UInt dup = (((CELL *)arena-H0)*sizeof(CELL))>>3;
|
UInt dup = (((CELL *)arena-H0)*sizeof(CELL))>>3;
|
||||||
if (dup < 64*1024*GlobalArenaOverflows)
|
if (dup < 64*1024*GlobalArenaOverflows)
|
||||||
@ -892,7 +894,7 @@ garena_overflow_size(CELL *arena)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_setarg(void)
|
p_nb_setarg( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term wheret = Deref(ARG1);
|
Term wheret = Deref(ARG1);
|
||||||
Term dest = Deref(ARG2);
|
Term dest = Deref(ARG2);
|
||||||
@ -924,7 +926,7 @@ p_nb_setarg(void)
|
|||||||
}
|
}
|
||||||
if (pos < 1 || pos > arity)
|
if (pos < 1 || pos > arity)
|
||||||
return FALSE;
|
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)
|
if (to == 0L)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
destp[pos] = to;
|
destp[pos] = to;
|
||||||
@ -932,7 +934,7 @@ p_nb_setarg(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_set_shared_arg(void)
|
p_nb_set_shared_arg( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term wheret = Deref(ARG1);
|
Term wheret = Deref(ARG1);
|
||||||
Term dest = Deref(ARG2);
|
Term dest = Deref(ARG2);
|
||||||
@ -964,7 +966,7 @@ p_nb_set_shared_arg(void)
|
|||||||
}
|
}
|
||||||
if (pos < 1 || pos > arity)
|
if (pos < 1 || pos > arity)
|
||||||
return FALSE;
|
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)
|
if (to == 0L)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
destp[pos] = to;
|
destp[pos] = to;
|
||||||
@ -972,7 +974,7 @@ p_nb_set_shared_arg(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_linkarg(void)
|
p_nb_linkarg( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term wheret = Deref(ARG1);
|
Term wheret = Deref(ARG1);
|
||||||
Term dest = Deref(ARG2);
|
Term dest = Deref(ARG2);
|
||||||
@ -1008,7 +1010,7 @@ p_nb_linkarg(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_linkval(void)
|
p_nb_linkval( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1), to;
|
Term t = Deref(ARG1), to;
|
||||||
GlobalEntry *ge;
|
GlobalEntry *ge;
|
||||||
@ -1019,7 +1021,7 @@ p_nb_linkval(void)
|
|||||||
Yap_Error(TYPE_ERROR_ATOM,t,"nb_linkval");
|
Yap_Error(TYPE_ERROR_ATOM,t,"nb_linkval");
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
ge = GetGlobalEntry(AtomOfTerm(t));
|
ge = GetGlobalEntry(AtomOfTerm(t) PASS_REGS);
|
||||||
to = Deref(ARG2);
|
to = Deref(ARG2);
|
||||||
WRITE_LOCK(ge->GRWLock);
|
WRITE_LOCK(ge->GRWLock);
|
||||||
ge->global=to;
|
ge->global=to;
|
||||||
@ -1030,10 +1032,11 @@ p_nb_linkval(void)
|
|||||||
Term
|
Term
|
||||||
Yap_SetGlobalVal(Atom at, Term t0)
|
Yap_SetGlobalVal(Atom at, Term t0)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term to;
|
Term to;
|
||||||
GlobalEntry *ge;
|
GlobalEntry *ge;
|
||||||
ge = GetGlobalEntry(at);
|
ge = GetGlobalEntry(at PASS_REGS);
|
||||||
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)
|
if (to == 0L)
|
||||||
return to;
|
return to;
|
||||||
WRITE_LOCK(ge->GRWLock);
|
WRITE_LOCK(ge->GRWLock);
|
||||||
@ -1045,15 +1048,16 @@ Yap_SetGlobalVal(Atom at, Term t0)
|
|||||||
Term
|
Term
|
||||||
Yap_SaveTerm(Term t0)
|
Yap_SaveTerm(Term t0)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term to;
|
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)
|
if (to == 0L)
|
||||||
return to;
|
return to;
|
||||||
return to;
|
return to;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_setval(void)
|
p_nb_setval( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
@ -1067,7 +1071,7 @@ p_nb_setval(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_set_shared_val(void)
|
p_nb_set_shared_val( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1), to;
|
Term t = Deref(ARG1), to;
|
||||||
GlobalEntry *ge;
|
GlobalEntry *ge;
|
||||||
@ -1078,8 +1082,8 @@ p_nb_set_shared_val(void)
|
|||||||
Yap_Error(TYPE_ERROR_ATOM,t,"nb_setval");
|
Yap_Error(TYPE_ERROR_ATOM,t,"nb_setval");
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
ge = GetGlobalEntry(AtomOfTerm(t));
|
ge = GetGlobalEntry(AtomOfTerm(t) PASS_REGS);
|
||||||
to = CopyTermToArena(ARG2, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
to = CopyTermToArena(ARG2, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
|
||||||
if (to == 0L)
|
if (to == 0L)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
WRITE_LOCK(ge->GRWLock);
|
WRITE_LOCK(ge->GRWLock);
|
||||||
@ -1089,7 +1093,7 @@ p_nb_set_shared_val(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_b_setval(void)
|
p_b_setval( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
GlobalEntry *ge;
|
GlobalEntry *ge;
|
||||||
@ -1101,7 +1105,7 @@ p_b_setval(void)
|
|||||||
Yap_Error(TYPE_ERROR_ATOM,t,"b_setval");
|
Yap_Error(TYPE_ERROR_ATOM,t,"b_setval");
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
ge = GetGlobalEntry(AtomOfTerm(t));
|
ge = GetGlobalEntry(AtomOfTerm(t) PASS_REGS);
|
||||||
WRITE_LOCK(ge->GRWLock);
|
WRITE_LOCK(ge->GRWLock);
|
||||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||||
/* the evil deed is to be done now */
|
/* the evil deed is to be done now */
|
||||||
@ -1125,7 +1129,7 @@ p_b_setval(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_getval(void)
|
p_nb_getval( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1), to;
|
Term t = Deref(ARG1), to;
|
||||||
GlobalEntry *ge;
|
GlobalEntry *ge;
|
||||||
@ -1137,7 +1141,7 @@ p_nb_getval(void)
|
|||||||
Yap_Error(TYPE_ERROR_ATOM,t,"nb_getval");
|
Yap_Error(TYPE_ERROR_ATOM,t,"nb_getval");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
ge = FindGlobalEntry(AtomOfTerm(t));
|
ge = FindGlobalEntry(AtomOfTerm(t) PASS_REGS);
|
||||||
if (!ge) {
|
if (!ge) {
|
||||||
return Yap_unify(TermNil, ARG3);
|
return Yap_unify(TermNil, ARG3);
|
||||||
}
|
}
|
||||||
@ -1156,13 +1160,13 @@ p_nb_getval(void)
|
|||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
nbdelete(Atom at)
|
nbdelete(Atom at USES_REGS)
|
||||||
{
|
{
|
||||||
GlobalEntry *ge, *g;
|
GlobalEntry *ge, *g;
|
||||||
AtomEntry *ae;
|
AtomEntry *ae;
|
||||||
Prop gp, g0;
|
Prop gp, g0;
|
||||||
|
|
||||||
ge = FindGlobalEntry(at);
|
ge = FindGlobalEntry(at PASS_REGS);
|
||||||
if (!ge) {
|
if (!ge) {
|
||||||
Yap_Error(EXISTENCE_ERROR_VARIABLE,MkAtomTerm(at),"nb_delete");
|
Yap_Error(EXISTENCE_ERROR_VARIABLE,MkAtomTerm(at),"nb_delete");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1196,11 +1200,12 @@ nbdelete(Atom at)
|
|||||||
Int
|
Int
|
||||||
Yap_DeleteGlobal(Atom at)
|
Yap_DeleteGlobal(Atom at)
|
||||||
{
|
{
|
||||||
return nbdelete(at);
|
CACHE_REGS
|
||||||
|
return nbdelete(at PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_delete(void)
|
p_nb_delete( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
@ -1211,11 +1216,11 @@ p_nb_delete(void)
|
|||||||
Yap_Error(TYPE_ERROR_ATOM,t,"nb_delete");
|
Yap_Error(TYPE_ERROR_ATOM,t,"nb_delete");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return nbdelete(AtomOfTerm(t));
|
return nbdelete(AtomOfTerm(t) PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_create(void)
|
p_nb_create( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Term tname = Deref(ARG2);
|
Term tname = Deref(ARG2);
|
||||||
@ -1230,7 +1235,7 @@ p_nb_create(void)
|
|||||||
Yap_Error(TYPE_ERROR_ATOM,t,"nb_create");
|
Yap_Error(TYPE_ERROR_ATOM,t,"nb_create");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
ge = GetGlobalEntry(AtomOfTerm(t));
|
ge = GetGlobalEntry(AtomOfTerm(t) PASS_REGS);
|
||||||
if (!ge) {
|
if (!ge) {
|
||||||
Yap_Error(EXISTENCE_ERROR_VARIABLE,t,"nb_create");
|
Yap_Error(EXISTENCE_ERROR_VARIABLE,t,"nb_create");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1249,7 +1254,7 @@ p_nb_create(void)
|
|||||||
Yap_Error(TYPE_ERROR_ATOM,tname,"nb_create");
|
Yap_Error(TYPE_ERROR_ATOM,tname,"nb_create");
|
||||||
return FALSE;
|
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)
|
if (!to)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
WRITE_LOCK(ge->GRWLock);
|
WRITE_LOCK(ge->GRWLock);
|
||||||
@ -1259,7 +1264,7 @@ p_nb_create(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_create2(void)
|
p_nb_create2( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Term tname = Deref(ARG2);
|
Term tname = Deref(ARG2);
|
||||||
@ -1275,7 +1280,7 @@ p_nb_create2(void)
|
|||||||
Yap_Error(TYPE_ERROR_ATOM,t,"nb_create");
|
Yap_Error(TYPE_ERROR_ATOM,t,"nb_create");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
ge = GetGlobalEntry(AtomOfTerm(t));
|
ge = GetGlobalEntry(AtomOfTerm(t) PASS_REGS);
|
||||||
if (!ge) {
|
if (!ge) {
|
||||||
Yap_Error(EXISTENCE_ERROR_VARIABLE,t,"nb_create");
|
Yap_Error(EXISTENCE_ERROR_VARIABLE,t,"nb_create");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1301,7 +1306,7 @@ p_nb_create2(void)
|
|||||||
Yap_Error(TYPE_ERROR_ATOM,tname,"nb_create");
|
Yap_Error(TYPE_ERROR_ATOM,tname,"nb_create");
|
||||||
return FALSE;
|
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)
|
if (!to)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
WRITE_LOCK(ge->GRWLock);
|
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. */
|
/* a non-backtrackable queue is a term of the form $array(Arena,Start,End,Size) plus an Arena. */
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
nb_queue(UInt arena_sz)
|
nb_queue(UInt arena_sz USES_REGS)
|
||||||
{
|
{
|
||||||
Term queue_arena, queue, ar[QUEUE_FUNCTOR_ARITY], *nar;
|
Term queue_arena, queue, ar[QUEUE_FUNCTOR_ARITY], *nar;
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
@ -1335,7 +1340,7 @@ nb_queue(UInt arena_sz)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
if (arena_sz < 4*1024)
|
if (arena_sz < 4*1024)
|
||||||
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) {
|
if (queue_arena == 0L) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1345,7 +1350,7 @@ nb_queue(UInt arena_sz)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_queue(void)
|
p_nb_queue( USES_REGS1 )
|
||||||
{
|
{
|
||||||
UInt arena_sz = (ASP-H)/16;
|
UInt arena_sz = (ASP-H)/16;
|
||||||
if (DepthArenas > 1)
|
if (DepthArenas > 1)
|
||||||
@ -1354,11 +1359,11 @@ p_nb_queue(void)
|
|||||||
arena_sz = MIN_ARENA_SIZE;
|
arena_sz = MIN_ARENA_SIZE;
|
||||||
if (arena_sz > MAX_ARENA_SIZE)
|
if (arena_sz > MAX_ARENA_SIZE)
|
||||||
arena_sz = MAX_ARENA_SIZE;
|
arena_sz = MAX_ARENA_SIZE;
|
||||||
return nb_queue(arena_sz);
|
return nb_queue(arena_sz PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_queue_sized(void)
|
p_nb_queue_sized( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG2);
|
Term t = Deref(ARG2);
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
@ -1369,7 +1374,7 @@ p_nb_queue_sized(void)
|
|||||||
Yap_Error(TYPE_ERROR_INTEGER,t,"nb_queue");
|
Yap_Error(TYPE_ERROR_INTEGER,t,"nb_queue");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return nb_queue((UInt)IntegerOfTerm(t));
|
return nb_queue((UInt)IntegerOfTerm(t) PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CELL *
|
static CELL *
|
||||||
@ -1413,7 +1418,7 @@ GetQueueArena(CELL *qd, char* caller)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RecoverArena(Term arena)
|
RecoverArena(Term arena USES_REGS)
|
||||||
{
|
{
|
||||||
CELL *pt = ArenaPt(arena),
|
CELL *pt = ArenaPt(arena),
|
||||||
*max = ArenaLimit(arena);
|
*max = ArenaLimit(arena);
|
||||||
@ -1424,7 +1429,7 @@ RecoverArena(Term arena)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_queue_close(void)
|
p_nb_queue_close( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Int out;
|
Int out;
|
||||||
@ -1439,7 +1444,7 @@ p_nb_queue_close(void)
|
|||||||
Yap_unify(ARG3, ARG2);
|
Yap_unify(ARG3, ARG2);
|
||||||
}
|
}
|
||||||
if (qp[QUEUE_ARENA] != MkIntTerm(0))
|
if (qp[QUEUE_ARENA] != MkIntTerm(0))
|
||||||
RecoverArena(qp[QUEUE_ARENA]);
|
RecoverArena(qp[QUEUE_ARENA] PASS_REGS);
|
||||||
if (qp[QUEUE_SIZE] == MkIntTerm(0)) {
|
if (qp[QUEUE_SIZE] == MkIntTerm(0)) {
|
||||||
return
|
return
|
||||||
Yap_unify(ARG3, ARG2);
|
Yap_unify(ARG3, ARG2);
|
||||||
@ -1458,7 +1463,7 @@ p_nb_queue_close(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_queue_enqueue(void)
|
p_nb_queue_enqueue( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL *qd = GetQueue(ARG1,"enqueue"), *oldH, *oldHB;
|
CELL *qd = GetQueue(ARG1,"enqueue"), *oldH, *oldHB;
|
||||||
UInt old_sz;
|
UInt old_sz;
|
||||||
@ -1475,7 +1480,7 @@ p_nb_queue_enqueue(void)
|
|||||||
} else {
|
} else {
|
||||||
min_size = 0L;
|
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)
|
if (to == 0L)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
qd = GetQueue(ARG1,"enqueue");
|
qd = GetQueue(ARG1,"enqueue");
|
||||||
@ -1497,7 +1502,7 @@ p_nb_queue_enqueue(void)
|
|||||||
}
|
}
|
||||||
ARG3 = to;
|
ARG3 = to;
|
||||||
/* fprintf(stderr,"growing %ld cells\n",(unsigned long int)gsiz);*/
|
/* 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);
|
Yap_Error(OUT_OF_STACK_ERROR, arena, Yap_ErrorMessage);
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
@ -1519,12 +1524,12 @@ p_nb_queue_enqueue(void)
|
|||||||
RESET_VARIABLE(H);
|
RESET_VARIABLE(H);
|
||||||
qd[QUEUE_TAIL] = (CELL)H;
|
qd[QUEUE_TAIL] = (CELL)H;
|
||||||
H++;
|
H++;
|
||||||
CloseArena(oldH, oldHB, ASP, qd+QUEUE_ARENA, old_sz);
|
CloseArena(oldH, oldHB, ASP, qd+QUEUE_ARENA, old_sz PASS_REGS);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_queue_dequeue(void)
|
p_nb_queue_dequeue( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL *qd = GetQueue(ARG1,"dequeue");
|
CELL *qd = GetQueue(ARG1,"dequeue");
|
||||||
UInt old_sz, qsz;
|
UInt old_sz, qsz;
|
||||||
@ -1546,12 +1551,12 @@ p_nb_queue_dequeue(void)
|
|||||||
oldH = H;
|
oldH = H;
|
||||||
oldHB = HB;
|
oldHB = HB;
|
||||||
qd[QUEUE_SIZE] = Global_MkIntegerTerm(qsz-1);
|
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);
|
return Yap_unify(out, ARG2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_queue_peek(void)
|
p_nb_queue_peek( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL *qd = GetQueue(ARG1,"queue_peek");
|
CELL *qd = GetQueue(ARG1,"queue_peek");
|
||||||
UInt qsz;
|
UInt qsz;
|
||||||
@ -1565,7 +1570,7 @@ p_nb_queue_peek(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_queue_empty(void)
|
p_nb_queue_empty( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL *qd = GetQueue(ARG1,"queue_empty");
|
CELL *qd = GetQueue(ARG1,"queue_empty");
|
||||||
|
|
||||||
@ -1575,7 +1580,7 @@ p_nb_queue_empty(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_queue_size(void)
|
p_nb_queue_size( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL *qd = GetQueue(ARG1,"queue_size");
|
CELL *qd = GetQueue(ARG1,"queue_size");
|
||||||
|
|
||||||
@ -1602,7 +1607,7 @@ GetHeap(Term t, char* caller)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
MkZeroApplTerm(Functor f, UInt sz)
|
MkZeroApplTerm(Functor f, UInt sz USES_REGS)
|
||||||
{
|
{
|
||||||
Term t0, tf;
|
Term t0, tf;
|
||||||
CELL *pt;
|
CELL *pt;
|
||||||
@ -1621,7 +1626,7 @@ MkZeroApplTerm(Functor f, UInt sz)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_heap(void)
|
p_nb_heap( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term heap_arena, heap, *ar, *nar;
|
Term heap_arena, heap, *ar, *nar;
|
||||||
UInt hsize;
|
UInt hsize;
|
||||||
@ -1639,7 +1644,7 @@ p_nb_heap(void)
|
|||||||
hsize = IntegerOfTerm(tsize);
|
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)) {
|
if (!Yap_gcl((2*hsize+HEAP_START+1)*sizeof(CELL), 2, ENV, P)) {
|
||||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1654,7 +1659,7 @@ p_nb_heap(void)
|
|||||||
ar[HEAP_MAX] = tsize;
|
ar[HEAP_MAX] = tsize;
|
||||||
if (arena_sz < 1024)
|
if (arena_sz < 1024)
|
||||||
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) {
|
if (heap_arena == 0L) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1664,7 +1669,7 @@ p_nb_heap(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_heap_close(void)
|
p_nb_heap_close( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
if (!IsVarTerm(t)) {
|
if (!IsVarTerm(t)) {
|
||||||
@ -1672,7 +1677,7 @@ p_nb_heap_close(void)
|
|||||||
|
|
||||||
qp = RepAppl(t)+1;
|
qp = RepAppl(t)+1;
|
||||||
if (qp[HEAP_ARENA] != MkIntTerm(0))
|
if (qp[HEAP_ARENA] != MkIntTerm(0))
|
||||||
RecoverArena(qp[HEAP_ARENA]);
|
RecoverArena(qp[HEAP_ARENA] PASS_REGS);
|
||||||
qp[-1] = (CELL)Yap_MkFunctor(AtomHeap,1);
|
qp[-1] = (CELL)Yap_MkFunctor(AtomHeap,1);
|
||||||
qp[0] = MkIntegerTerm(0);
|
qp[0] = MkIntegerTerm(0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1737,7 +1742,7 @@ DelHeapRoot(CELL *pt, UInt sz)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
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;
|
CELL *qd = GetHeap(ARG1,"add_to_heap"), *oldH, *oldHB, *pt;
|
||||||
UInt hsize, hmsize, old_sz;
|
UInt hsize, hmsize, old_sz;
|
||||||
@ -1781,17 +1786,17 @@ p_nb_heap_add_to_heap(void)
|
|||||||
oldHB = HB;
|
oldHB = HB;
|
||||||
H = HB = ArenaPt(arena);
|
H = HB = ArenaPt(arena);
|
||||||
qd[HEAP_MAX] = Global_MkIntegerTerm(hmsize);
|
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;
|
goto restart;
|
||||||
}
|
}
|
||||||
arena = qd[HEAP_ARENA];
|
arena = qd[HEAP_ARENA];
|
||||||
if (arena == 0L)
|
if (arena == 0L)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
mingrow = garena_overflow_size(ArenaPt(arena));
|
mingrow = garena_overflow_size(ArenaPt(arena) PASS_REGS);
|
||||||
ARG2 = CopyTermToArena(ARG2, arena, FALSE, TRUE, 3, qd+HEAP_ARENA, mingrow);
|
ARG2 = CopyTermToArena(ARG2, arena, FALSE, TRUE, 3, qd+HEAP_ARENA, mingrow PASS_REGS);
|
||||||
qd = GetHeap(ARG1,"add_to_heap");
|
qd = GetHeap(ARG1,"add_to_heap");
|
||||||
arena = qd[HEAP_ARENA];
|
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 */
|
/* protect key in ARG2 in case there is an overflow while copying to */
|
||||||
key = ARG2;
|
key = ARG2;
|
||||||
if (key == 0 || to == 0L)
|
if (key == 0 || to == 0L)
|
||||||
@ -1814,7 +1819,7 @@ p_nb_heap_add_to_heap(void)
|
|||||||
gsiz = 1024;
|
gsiz = 1024;
|
||||||
}
|
}
|
||||||
ARG3 = to;
|
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);
|
Yap_Error(OUT_OF_STACK_ERROR, arena, Yap_ErrorMessage);
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
@ -1831,12 +1836,12 @@ p_nb_heap_add_to_heap(void)
|
|||||||
pt[2*hsize+1] = to;
|
pt[2*hsize+1] = to;
|
||||||
PushHeap(pt, hsize);
|
PushHeap(pt, hsize);
|
||||||
qd[HEAP_SIZE] = Global_MkIntegerTerm(hsize+1);
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_heap_del(void)
|
p_nb_heap_del( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL *qd = GetHeap(ARG1,"deheap");
|
CELL *qd = GetHeap(ARG1,"deheap");
|
||||||
UInt old_sz, qsz;
|
UInt old_sz, qsz;
|
||||||
@ -1857,7 +1862,7 @@ p_nb_heap_del(void)
|
|||||||
oldH = H;
|
oldH = H;
|
||||||
oldHB = HB;
|
oldHB = HB;
|
||||||
qd[HEAP_SIZE] = Global_MkIntegerTerm(qsz-1);
|
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];
|
tk = qd[HEAP_START];
|
||||||
tv = qd[HEAP_START+1];
|
tv = qd[HEAP_START+1];
|
||||||
DelHeapRoot(qd+HEAP_START, qsz);
|
DelHeapRoot(qd+HEAP_START, qsz);
|
||||||
@ -1866,7 +1871,7 @@ p_nb_heap_del(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_heap_peek(void)
|
p_nb_heap_peek( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL *qd = GetHeap(ARG1,"heap_peek");
|
CELL *qd = GetHeap(ARG1,"heap_peek");
|
||||||
UInt qsz;
|
UInt qsz;
|
||||||
@ -1884,7 +1889,7 @@ p_nb_heap_peek(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_heap_empty(void)
|
p_nb_heap_empty( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL *qd = GetHeap(ARG1,"heap_empty");
|
CELL *qd = GetHeap(ARG1,"heap_empty");
|
||||||
|
|
||||||
@ -1894,7 +1899,7 @@ p_nb_heap_empty(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_heap_size(void)
|
p_nb_heap_size( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL *qd = GetHeap(ARG1,"heap_size");
|
CELL *qd = GetHeap(ARG1,"heap_size");
|
||||||
|
|
||||||
@ -1904,7 +1909,7 @@ p_nb_heap_size(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_beam(void)
|
p_nb_beam( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term beam_arena, beam, *ar, *nar;
|
Term beam_arena, beam, *ar, *nar;
|
||||||
UInt hsize;
|
UInt hsize;
|
||||||
@ -1921,7 +1926,7 @@ p_nb_beam(void)
|
|||||||
}
|
}
|
||||||
hsize = IntegerOfTerm(tsize);
|
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)) {
|
if (!Yap_gcl((4*hsize+HEAP_START+1)*sizeof(CELL), 2, ENV, P)) {
|
||||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1936,7 +1941,7 @@ p_nb_beam(void)
|
|||||||
ar[HEAP_MAX] = tsize;
|
ar[HEAP_MAX] = tsize;
|
||||||
if (arena_sz < 1024)
|
if (arena_sz < 1024)
|
||||||
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) {
|
if (beam_arena == 0L) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1946,9 +1951,9 @@ p_nb_beam(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
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
|
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;
|
CELL *qd = GetHeap(ARG1,"add_to_beam"), *oldH, *oldHB, *pt;
|
||||||
UInt hsize, hmsize, old_sz;
|
UInt hsize, hmsize, old_sz;
|
||||||
@ -2176,10 +2181,10 @@ p_nb_beam_add_to_beam(void)
|
|||||||
arena = qd[HEAP_ARENA];
|
arena = qd[HEAP_ARENA];
|
||||||
if (arena == 0L)
|
if (arena == 0L)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
mingrow = garena_overflow_size(ArenaPt(arena));
|
mingrow = garena_overflow_size(ArenaPt(arena) PASS_REGS);
|
||||||
key = CopyTermToArena(ARG2, qd[HEAP_ARENA], FALSE, TRUE, 3, qd+HEAP_ARENA, mingrow);
|
key = CopyTermToArena(ARG2, qd[HEAP_ARENA], FALSE, TRUE, 3, qd+HEAP_ARENA, mingrow PASS_REGS);
|
||||||
arena = qd[HEAP_ARENA];
|
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)
|
if (key == 0 || to == 0L)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
qd = GetHeap(ARG1,"add_to_beam");
|
qd = GetHeap(ARG1,"add_to_beam");
|
||||||
@ -2200,7 +2205,7 @@ p_nb_beam_add_to_beam(void)
|
|||||||
gsiz = 1024;
|
gsiz = 1024;
|
||||||
}
|
}
|
||||||
ARG3 = to;
|
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);
|
Yap_Error(OUT_OF_STACK_ERROR, arena, Yap_ErrorMessage);
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
@ -2215,12 +2220,12 @@ p_nb_beam_add_to_beam(void)
|
|||||||
pt = qd+HEAP_START;
|
pt = qd+HEAP_START;
|
||||||
PushBeam(pt, pt+2*hmsize, hsize, key, to);
|
PushBeam(pt, pt+2*hmsize, hsize, key, to);
|
||||||
qd[HEAP_SIZE] = Global_MkIntegerTerm(hsize+1);
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_beam_del(void)
|
p_nb_beam_del( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL *qd = GetHeap(ARG1,"debeam");
|
CELL *qd = GetHeap(ARG1,"debeam");
|
||||||
UInt old_sz, qsz;
|
UInt old_sz, qsz;
|
||||||
@ -2241,7 +2246,7 @@ p_nb_beam_del(void)
|
|||||||
oldH = H;
|
oldH = H;
|
||||||
oldHB = HB;
|
oldHB = HB;
|
||||||
qd[HEAP_SIZE] = Global_MkIntegerTerm(qsz-1);
|
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];
|
tk = qd[HEAP_START];
|
||||||
tv = DelBeamMin(qd+HEAP_START, qd+(HEAP_START+2*IntegerOfTerm(qd[HEAP_MAX])), qsz);
|
tv = DelBeamMin(qd+HEAP_START, qd+(HEAP_START+2*IntegerOfTerm(qd[HEAP_MAX])), qsz);
|
||||||
return Yap_unify(tk, ARG2) &&
|
return Yap_unify(tk, ARG2) &&
|
||||||
@ -2250,7 +2255,7 @@ p_nb_beam_del(void)
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
static Int
|
static Int
|
||||||
p_nb_beam_check(void)
|
p_nb_beam_check( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL *qd = GetHeap(ARG1,"debeam");
|
CELL *qd = GetHeap(ARG1,"debeam");
|
||||||
UInt qsz, qmax;
|
UInt qsz, qmax;
|
||||||
@ -2293,7 +2298,7 @@ p_nb_beam_check(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_beam_keys(void)
|
p_nb_beam_keys( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL *qd;
|
CELL *qd;
|
||||||
UInt qsz;
|
UInt qsz;
|
||||||
@ -2328,7 +2333,7 @@ p_nb_beam_keys(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_beam_peek(void)
|
p_nb_beam_peek( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL *qd = GetHeap(ARG1,"beam_peek"), *pt, *pt2;
|
CELL *qd = GetHeap(ARG1,"beam_peek"), *pt, *pt2;
|
||||||
UInt qsz, qbsize;
|
UInt qsz, qbsize;
|
||||||
@ -2349,7 +2354,7 @@ p_nb_beam_peek(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_beam_empty(void)
|
p_nb_beam_empty( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL *qd = GetHeap(ARG1,"beam_empty");
|
CELL *qd = GetHeap(ARG1,"beam_empty");
|
||||||
|
|
||||||
@ -2359,7 +2364,7 @@ p_nb_beam_empty(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nb_beam_size(void)
|
p_nb_beam_size( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL *qd = GetHeap(ARG1,"beam_size");
|
CELL *qd = GetHeap(ARG1,"beam_size");
|
||||||
|
|
||||||
@ -2369,7 +2374,7 @@ p_nb_beam_size(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
cont_current_nb(void)
|
cont_current_nb( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Int unif;
|
Int unif;
|
||||||
GlobalEntry *ge = (GlobalEntry *)IntegerOfTerm(EXTRA_CBACK_ARG(1,1));
|
GlobalEntry *ge = (GlobalEntry *)IntegerOfTerm(EXTRA_CBACK_ARG(1,1));
|
||||||
@ -2388,12 +2393,12 @@ cont_current_nb(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
init_current_nb(void)
|
init_current_nb( USES_REGS1 )
|
||||||
{ /* current_atom(?Atom) */
|
{ /* current_atom(?Atom) */
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
if (!IsVarTerm(t1)) {
|
if (!IsVarTerm(t1)) {
|
||||||
if (IsAtomTerm(t1)) {
|
if (IsAtomTerm(t1)) {
|
||||||
if (!FindGlobalEntry(AtomOfTerm(t1))) {
|
if (!FindGlobalEntry(AtomOfTerm(t1) PASS_REGS)) {
|
||||||
cut_fail();
|
cut_fail();
|
||||||
} else {
|
} else {
|
||||||
cut_succeed();
|
cut_succeed();
|
||||||
@ -2405,12 +2410,13 @@ init_current_nb(void)
|
|||||||
}
|
}
|
||||||
READ_LOCK(HashChain[0].AERWLock);
|
READ_LOCK(HashChain[0].AERWLock);
|
||||||
EXTRA_CBACK_ARG(1,1) = MkIntegerTerm((Int)GlobalVariables);
|
EXTRA_CBACK_ARG(1,1) = MkIntegerTerm((Int)GlobalVariables);
|
||||||
return cont_current_nb();
|
return cont_current_nb( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Yap_InitGlobals(void)
|
void Yap_InitGlobals(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term cm = CurrentModule;
|
Term cm = CurrentModule;
|
||||||
Yap_InitCPred("$allocate_arena", 2, p_allocate_arena, 0);
|
Yap_InitCPred("$allocate_arena", 2, p_allocate_arena, 0);
|
||||||
Yap_InitCPred("arena_size", 1, p_default_arena_size, 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 */
|
int ts; /* start end timestamp towards retracts, eventually */
|
||||||
} clauseentry;
|
} clauseentry;
|
||||||
|
|
||||||
static Int profend(void);
|
static Int profend( USES_REGS1 );
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clean_tree(rb_red_blk_node* node) {
|
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);
|
pp = Yap_PredEntryForCode(current_p, FIND_PRED_FROM_ANYWHERE, &start, &end);
|
||||||
if (!pp) {
|
if (!pp) {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
CACHE_REGS
|
||||||
fprintf(stderr,"lost %p, %d\n", P, Yap_op_from_opcode(P->opc));
|
fprintf(stderr,"lost %p, %d\n", P, Yap_op_from_opcode(P->opc));
|
||||||
#endif
|
#endif
|
||||||
/* lost profiler event !! */
|
/* lost profiler event !! */
|
||||||
@ -832,14 +833,14 @@ static void RemoveCode(CODEADDR clau)
|
|||||||
#define MAX_LINE_SIZE 1024
|
#define MAX_LINE_SIZE 1024
|
||||||
|
|
||||||
static int
|
static int
|
||||||
showprofres(void) {
|
showprofres( USES_REGS1 ) {
|
||||||
char line[MAX_LINE_SIZE];
|
char line[MAX_LINE_SIZE];
|
||||||
yamop *pr_beg, *pr_end;
|
yamop *pr_beg, *pr_end;
|
||||||
PredEntry *pr_pp;
|
PredEntry *pr_pp;
|
||||||
long int pr_count;
|
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 */
|
/* First part: Read information about predicates and store it on yap trail */
|
||||||
|
|
||||||
@ -877,14 +878,14 @@ showprofres(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_test(void) {
|
p_test( USES_REGS1 ) {
|
||||||
char line[MAX_LINE_SIZE];
|
char line[MAX_LINE_SIZE];
|
||||||
yamop *pr_beg, *pr_end;
|
yamop *pr_beg, *pr_end;
|
||||||
PredEntry *pr_pp;
|
PredEntry *pr_pp;
|
||||||
long int pr_count;
|
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 */
|
/* 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) {
|
if (oldpc>(void *) &Yap_absmi && oldpc <= (void *) &Yap_absmiEND) {
|
||||||
|
CACHE_REGS
|
||||||
/* we are running emulator code */
|
/* we are running emulator code */
|
||||||
#if BP_FREE
|
#if BP_FREE
|
||||||
current_p =(yamop *) CONTEXT_BP(scv);
|
current_p =(yamop *) CONTEXT_BP(scv);
|
||||||
@ -966,6 +968,7 @@ prof_alrm(int signo, siginfo_t *si, void *scv)
|
|||||||
current_p = P;
|
current_p = P;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
CACHE_REGS
|
||||||
op_numbers oop = Yap_op_from_opcode(PREVOP(P,Osbpp)->opc);
|
op_numbers oop = Yap_op_from_opcode(PREVOP(P,Osbpp)->opc);
|
||||||
|
|
||||||
if (oop == _call_cpred || oop == _call_usercpred) {
|
if (oop == _call_cpred || oop == _call_usercpred) {
|
||||||
@ -1014,10 +1017,10 @@ Yap_InformOfRemoval(CODEADDR clau)
|
|||||||
ProfOn = FALSE;
|
ProfOn = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int profend(void);
|
static Int profend( USES_REGS1 );
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
profnode(void) {
|
profnode( USES_REGS1 ) {
|
||||||
Term t1 = Deref(ARG1), tleft, tright;
|
Term t1 = Deref(ARG1), tleft, tright;
|
||||||
rb_red_blk_node *node;
|
rb_red_blk_node *node;
|
||||||
|
|
||||||
@ -1053,7 +1056,7 @@ profnode(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
profglobs(void) {
|
profglobs( USES_REGS1 ) {
|
||||||
return
|
return
|
||||||
Yap_unify(ARG1,MkIntegerTerm(ProfCalls)) &&
|
Yap_unify(ARG1,MkIntegerTerm(ProfCalls)) &&
|
||||||
Yap_unify(ARG2,MkIntegerTerm(ProfGCs)) &&
|
Yap_unify(ARG2,MkIntegerTerm(ProfGCs)) &&
|
||||||
@ -1064,7 +1067,7 @@ profglobs(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
do_profinit(void)
|
do_profinit( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (Yap_OffLineProfiler) {
|
if (Yap_OffLineProfiler) {
|
||||||
// FPreds=fopen(profile_names(PROFPREDS_FILE),"w+");
|
// FPreds=fopen(profile_names(PROFPREDS_FILE),"w+");
|
||||||
@ -1080,18 +1083,18 @@ do_profinit(void)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int profinit(void)
|
static Int profinit( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (ProfilerOn!=0) return (FALSE);
|
if (ProfilerOn!=0) return (FALSE);
|
||||||
|
|
||||||
if (!do_profinit())
|
if (!do_profinit( PASS_REGS1 ))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
ProfilerOn = -1; /* Inited but not yet started */
|
ProfilerOn = -1; /* Inited but not yet started */
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int profinit1(void)
|
static Int profinit1( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
@ -1114,11 +1117,11 @@ static Int profinit1(void)
|
|||||||
Yap_Error(TYPE_ERROR_ATOM,t,"profinit only allows offline,online");
|
Yap_Error(TYPE_ERROR_ATOM,t,"profinit only allows offline,online");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return profinit();
|
return profinit( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int proftype(void)
|
static Int proftype( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (Yap_OffLineProfiler)
|
if (Yap_OffLineProfiler)
|
||||||
return Yap_unify(ARG1,MkAtomTerm(AtomOffline));
|
return Yap_unify(ARG1,MkAtomTerm(AtomOffline));
|
||||||
@ -1135,7 +1138,8 @@ static Int start_profilers(int msec)
|
|||||||
if (Yap_OffLineProfiler) {
|
if (Yap_OffLineProfiler) {
|
||||||
return FALSE; /* have to go through profinit */
|
return FALSE; /* have to go through profinit */
|
||||||
} else {
|
} else {
|
||||||
if (!do_profinit())
|
CACHE_REGS
|
||||||
|
if (!do_profinit( PASS_REGS1 ))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1156,7 +1160,7 @@ static Int start_profilers(int msec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int profoff(void) {
|
static Int profoff( USES_REGS1 ) {
|
||||||
if (ProfilerOn>0) {
|
if (ProfilerOn>0) {
|
||||||
setitimer(ITIMER_PROF,NULL,NULL);
|
setitimer(ITIMER_PROF,NULL,NULL);
|
||||||
ProfilerOn = -1;
|
ProfilerOn = -1;
|
||||||
@ -1165,32 +1169,32 @@ static Int profoff(void) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int profon(void) {
|
static Int profon( USES_REGS1 ) {
|
||||||
Term p;
|
Term p;
|
||||||
profoff();
|
profoff( PASS_REGS1 );
|
||||||
p=Deref(ARG1);
|
p=Deref(ARG1);
|
||||||
return(start_profilers(IntOfTerm(p)));
|
return(start_profilers(IntOfTerm(p)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int profon0(void) {
|
static Int profon0( USES_REGS1 ) {
|
||||||
profoff();
|
profoff( PASS_REGS1 );
|
||||||
return(start_profilers(TIMER_DEFAULT));
|
return(start_profilers(TIMER_DEFAULT));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int profison(void) {
|
static Int profison( USES_REGS1 ) {
|
||||||
return (ProfilerOn > 0);
|
return (ProfilerOn > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int profalt(void) {
|
static Int profalt( USES_REGS1 ) {
|
||||||
if (ProfilerOn==0) return(FALSE);
|
if (ProfilerOn==0) return(FALSE);
|
||||||
if (ProfilerOn==-1) return profon();
|
if (ProfilerOn==-1) return profon( PASS_REGS1 );
|
||||||
return profoff();
|
return profoff( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int profend(void)
|
static Int profend( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (ProfilerOn==0) return(FALSE);
|
if (ProfilerOn==0) return(FALSE);
|
||||||
profoff(); /* Make sure profiler is off */
|
profoff( PASS_REGS1 ); /* Make sure profiler is off */
|
||||||
ProfilerOn=0;
|
ProfilerOn=0;
|
||||||
if (Yap_OffLineProfiler) {
|
if (Yap_OffLineProfiler) {
|
||||||
fclose(FProf);
|
fclose(FProf);
|
||||||
@ -1198,7 +1202,7 @@ static Int profend(void)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int getpredinfo(void)
|
static Int getpredinfo( USES_REGS1 )
|
||||||
{
|
{
|
||||||
PredEntry *pp = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
PredEntry *pp = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
||||||
Term mod, name;
|
Term mod, name;
|
||||||
@ -1234,8 +1238,8 @@ static Int getpredinfo(void)
|
|||||||
Yap_unify(ARG4, MkIntegerTerm(arity));
|
Yap_unify(ARG4, MkIntegerTerm(arity));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int profres0(void) {
|
static Int profres0( USES_REGS1 ) {
|
||||||
return(showprofres());
|
return(showprofres( PASS_REGS1 ));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* LOW_PROF */
|
#endif /* LOW_PROF */
|
||||||
|
295
C/grow.c
295
C/grow.c
@ -57,36 +57,37 @@ static Int total_trail_overflow_time = 0;
|
|||||||
static int atom_table_overflows = 0;
|
static int atom_table_overflows = 0;
|
||||||
static Int total_atom_table_overflow_time = 0;
|
static Int total_atom_table_overflow_time = 0;
|
||||||
|
|
||||||
STATIC_PROTO(Int p_growheap, (void));
|
STATIC_PROTO(Int p_growheap, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_growstack, (void));
|
STATIC_PROTO(Int p_growstack, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_inform_trail_overflows, (void));
|
STATIC_PROTO(Int p_inform_trail_overflows, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_inform_heap_overflows, (void));
|
STATIC_PROTO(Int p_inform_heap_overflows, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_inform_stack_overflows, (void));
|
STATIC_PROTO(Int p_inform_stack_overflows, ( USES_REGS1 ));
|
||||||
|
|
||||||
/* #define undf7 */
|
/* #define undf7 */
|
||||||
/* #define undf5 */
|
/* #define undf5 */
|
||||||
|
|
||||||
STATIC_PROTO(int growstack, (long));
|
STATIC_PROTO(int growstack, (long CACHE_TYPE));
|
||||||
STATIC_PROTO(void MoveGlobal, (void));
|
STATIC_PROTO(void MoveGlobal, ( CACHE_TYPE1 ));
|
||||||
STATIC_PROTO(void MoveLocalAndTrail, (void));
|
STATIC_PROTO(void MoveLocalAndTrail, ( CACHE_TYPE1 ));
|
||||||
STATIC_PROTO(void SetHeapRegs, (int));
|
STATIC_PROTO(void SetHeapRegs, (int CACHE_TYPE));
|
||||||
STATIC_PROTO(void AdjustTrail, (int, int));
|
STATIC_PROTO(void AdjustTrail, (int, int CACHE_TYPE));
|
||||||
STATIC_PROTO(void AdjustLocal, (int));
|
STATIC_PROTO(void AdjustLocal, (int CACHE_TYPE));
|
||||||
STATIC_PROTO(void AdjustGlobal, (long, int));
|
STATIC_PROTO(void AdjustGlobal, (long, int CACHE_TYPE));
|
||||||
STATIC_PROTO(void AdjustGrowStack, (void));
|
STATIC_PROTO(void AdjustGrowStack, ( CACHE_TYPE1 ));
|
||||||
STATIC_PROTO(int static_growheap, (long,int,struct intermediates *,tr_fr_ptr *, TokEntry **, VarEntry **));
|
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(void cpcellsd, (CELL *, CELL *, CELL));
|
||||||
STATIC_PROTO(CELL AdjustAppl, (CELL));
|
STATIC_PROTO(CELL AdjustAppl, (CELL CACHE_TYPE));
|
||||||
STATIC_PROTO(CELL AdjustPair, (CELL));
|
STATIC_PROTO(CELL AdjustPair, (CELL CACHE_TYPE));
|
||||||
STATIC_PROTO(void AdjustStacksAndTrail, (long, int));
|
STATIC_PROTO(void AdjustStacksAndTrail, (long, int CACHE_TYPE));
|
||||||
STATIC_PROTO(void AdjustRegs, (int));
|
STATIC_PROTO(void AdjustRegs, (int CACHE_TYPE));
|
||||||
STATIC_PROTO(Term AdjustGlobTerm, (Term));
|
STATIC_PROTO(Term AdjustGlobTerm, (Term CACHE_TYPE));
|
||||||
|
|
||||||
static void
|
static void
|
||||||
LeaveGrowMode(prolog_exec_mode grow_mode)
|
LeaveGrowMode(prolog_exec_mode grow_mode)
|
||||||
{
|
{
|
||||||
Yap_PrologMode &= ~grow_mode;
|
Yap_PrologMode &= ~grow_mode;
|
||||||
if (Yap_PrologMode & AbortMode) {
|
if (Yap_PrologMode & AbortMode) {
|
||||||
|
CACHE_REGS
|
||||||
Yap_PrologMode &= ~AbortMode;
|
Yap_PrologMode &= ~AbortMode;
|
||||||
Yap_Error(PURE_ABORT, TermNil, "");
|
Yap_Error(PURE_ABORT, TermNil, "");
|
||||||
/* in case someone mangles the P register */
|
/* in case someone mangles the P register */
|
||||||
@ -117,7 +118,7 @@ cpcellsd(register CELL *Dest, register CELL *Org, CELL NOf)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SetHeapRegs(int copying_threads)
|
SetHeapRegs(int copying_threads USES_REGS)
|
||||||
{
|
{
|
||||||
#ifdef undf7
|
#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);
|
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
|
static void
|
||||||
MoveLocalAndTrail(void)
|
MoveLocalAndTrail( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/* cpcellsd(To,From,NOfCells) - copy the cells downwards */
|
/* cpcellsd(To,From,NOfCells) - copy the cells downwards */
|
||||||
#if USE_SYSTEM_MALLOC
|
#if USE_SYSTEM_MALLOC
|
||||||
@ -216,7 +217,7 @@ MoveLocalAndTrail(void)
|
|||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CopyLocalAndTrail(void)
|
CopyLocalAndTrail( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/* cpcellsd(To,From,NOfCells) - copy the cells downwards */
|
/* cpcellsd(To,From,NOfCells) - copy the cells downwards */
|
||||||
#if USE_SYSTEM_MALLOC
|
#if USE_SYSTEM_MALLOC
|
||||||
@ -225,7 +226,7 @@ CopyLocalAndTrail(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
IncrementalCopyStacksFromWorker(void)
|
IncrementalCopyStacksFromWorker( USES_REGS1 )
|
||||||
{
|
{
|
||||||
memcpy((void *) PtoGloAdjust((CELL *)LOCAL_start_global_copy),
|
memcpy((void *) PtoGloAdjust((CELL *)LOCAL_start_global_copy),
|
||||||
(void *) (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) {
|
if (aux_ptr > H) {
|
||||||
CELL reg = FOREIGN_ThreadHandle(worker_p).current_yaam_regs->LCL0_[aux_ptr-LCL0];
|
CELL reg = FOREIGN_ThreadHandle(worker_p).current_yaam_regs->LCL0_[aux_ptr-LCL0];
|
||||||
reg = AdjustGlobTerm(reg);
|
reg = AdjustGlobTerm(reg PASS_REGS);
|
||||||
return reg;
|
return reg;
|
||||||
} else {
|
} else {
|
||||||
CELL reg = FOREIGN_ThreadHandle(worker_p).current_yaam_regs-> H0_[aux_ptr-H0];
|
CELL reg = FOREIGN_ThreadHandle(worker_p).current_yaam_regs-> H0_[aux_ptr-H0];
|
||||||
reg = AdjustGlobTerm(reg);
|
reg = AdjustGlobTerm(reg PASS_REGS);
|
||||||
return reg;
|
return reg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreTrail(int worker_p)
|
RestoreTrail(int worker_p USES_REGS)
|
||||||
{
|
{
|
||||||
tr_fr_ptr aux_tr;
|
tr_fr_ptr aux_tr;
|
||||||
|
|
||||||
@ -311,7 +312,7 @@ RestoreTrail(int worker_p)
|
|||||||
#endif /* YAPOR && THREADS */
|
#endif /* YAPOR && THREADS */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
MoveGlobal(void)
|
MoveGlobal( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
|
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
|
||||||
@ -321,7 +322,7 @@ MoveGlobal(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
MoveExpandedGlobal(void)
|
MoveExpandedGlobal( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
|
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
|
||||||
@ -331,7 +332,7 @@ MoveExpandedGlobal(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
MoveGlobalWithHole(void)
|
MoveGlobalWithHole( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
|
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
|
||||||
@ -345,7 +346,7 @@ MoveGlobalWithHole(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
MoveHalfGlobal(CELL *OldPt)
|
MoveHalfGlobal(CELL *OldPt USES_REGS)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
|
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
|
||||||
@ -358,7 +359,7 @@ MoveHalfGlobal(CELL *OldPt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline CELL
|
static inline CELL
|
||||||
AdjustAppl(register CELL t0)
|
AdjustAppl(register CELL t0 USES_REGS)
|
||||||
{
|
{
|
||||||
register CELL *t = RepAppl(t0);
|
register CELL *t = RepAppl(t0);
|
||||||
|
|
||||||
@ -378,7 +379,7 @@ AdjustAppl(register CELL t0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline CELL
|
static inline CELL
|
||||||
AdjustPair(register CELL t0)
|
AdjustPair(register CELL t0 USES_REGS)
|
||||||
{
|
{
|
||||||
register CELL *t = RepPair(t0);
|
register CELL *t = RepPair(t0);
|
||||||
|
|
||||||
@ -395,7 +396,7 @@ AdjustPair(register CELL t0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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;
|
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));
|
RESET_VARIABLE(&TrailTerm(ptt));
|
||||||
}
|
}
|
||||||
} else if (IsPairTerm(reg)) {
|
} else if (IsPairTerm(reg)) {
|
||||||
TrailTerm(ptt) = AdjustPair(reg);
|
TrailTerm(ptt) = AdjustPair(reg PASS_REGS);
|
||||||
#ifdef MULTI_ASSIGNMENT_VARIABLES /* does not work with new structures */
|
#ifdef MULTI_ASSIGNMENT_VARIABLES /* does not work with new structures */
|
||||||
/* check it whether we are protecting a
|
/* check it whether we are protecting a
|
||||||
multi-assignment */
|
multi-assignment */
|
||||||
} else if (IsApplTerm(reg)) {
|
} else if (IsApplTerm(reg)) {
|
||||||
TrailTerm(ptt) = AdjustAppl(reg);
|
TrailTerm(ptt) = AdjustAppl(reg PASS_REGS);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef FROZEN_STACKS
|
#ifdef FROZEN_STACKS
|
||||||
@ -445,9 +446,9 @@ AdjustTrail(int adjusting_heap, int thread_copying)
|
|||||||
else if (IsOldTrail(reg2))
|
else if (IsOldTrail(reg2))
|
||||||
TrailVal(ptt) = TrailAdjust(reg2);
|
TrailVal(ptt) = TrailAdjust(reg2);
|
||||||
} else if (IsApplTerm(reg2)) {
|
} else if (IsApplTerm(reg2)) {
|
||||||
TrailVal(ptt) = AdjustAppl(reg2);
|
TrailVal(ptt) = AdjustAppl(reg2 PASS_REGS);
|
||||||
} else if (IsPairTerm(reg2)) {
|
} else if (IsPairTerm(reg2)) {
|
||||||
TrailVal(ptt) = AdjustPair(reg2);
|
TrailVal(ptt) = AdjustPair(reg2 PASS_REGS);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -455,7 +456,7 @@ AdjustTrail(int adjusting_heap, int thread_copying)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
AdjustLocal(int thread_copying)
|
AdjustLocal(int thread_copying USES_REGS)
|
||||||
{
|
{
|
||||||
register CELL reg, *pt, *pt_bot;
|
register CELL reg, *pt, *pt_bot;
|
||||||
|
|
||||||
@ -483,16 +484,16 @@ AdjustLocal(int thread_copying)
|
|||||||
else if (IsOldCode(reg))
|
else if (IsOldCode(reg))
|
||||||
*pt = CodeAdjust(reg);
|
*pt = CodeAdjust(reg);
|
||||||
} else if (IsApplTerm(reg)) {
|
} else if (IsApplTerm(reg)) {
|
||||||
*pt = AdjustAppl(reg);
|
*pt = AdjustAppl(reg PASS_REGS);
|
||||||
} else if (IsPairTerm(reg)) {
|
} else if (IsPairTerm(reg)) {
|
||||||
*pt = AdjustPair(reg);
|
*pt = AdjustPair(reg PASS_REGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
AdjustGlobTerm(Term reg)
|
AdjustGlobTerm(Term reg USES_REGS)
|
||||||
{
|
{
|
||||||
if (IsVarTerm(reg)) {
|
if (IsVarTerm(reg)) {
|
||||||
if (IsOldGlobal(reg))
|
if (IsOldGlobal(reg))
|
||||||
@ -504,16 +505,16 @@ AdjustGlobTerm(Term reg)
|
|||||||
return TrailAdjust(reg);
|
return TrailAdjust(reg);
|
||||||
#endif
|
#endif
|
||||||
} else if (IsApplTerm(reg))
|
} else if (IsApplTerm(reg))
|
||||||
return AdjustAppl(reg);
|
return AdjustAppl(reg PASS_REGS);
|
||||||
else if (IsPairTerm(reg))
|
else if (IsPairTerm(reg))
|
||||||
return AdjustPair(reg);
|
return AdjustPair(reg PASS_REGS);
|
||||||
return AtomTermAdjust(reg);
|
return AtomTermAdjust(reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static volatile CELL *cpt=NULL;
|
static volatile CELL *cpt=NULL;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
AdjustGlobal(long sz, int thread_copying)
|
AdjustGlobal(long sz, int thread_copying USES_REGS)
|
||||||
{
|
{
|
||||||
CELL *pt, *pt_max;
|
CELL *pt, *pt_max;
|
||||||
ArrayEntry *al = DynamicArrays;
|
ArrayEntry *al = DynamicArrays;
|
||||||
@ -521,13 +522,13 @@ AdjustGlobal(long sz, int thread_copying)
|
|||||||
GlobalEntry *gl = GlobalVariables;
|
GlobalEntry *gl = GlobalVariables;
|
||||||
|
|
||||||
while (al) {
|
while (al) {
|
||||||
al->ValueOfVE = AdjustGlobTerm(al->ValueOfVE);
|
al->ValueOfVE = AdjustGlobTerm(al->ValueOfVE PASS_REGS);
|
||||||
al = al->NextAE;
|
al = al->NextAE;
|
||||||
}
|
}
|
||||||
while (gl) {
|
while (gl) {
|
||||||
if (IsVarTerm(gl->global) ||
|
if (IsVarTerm(gl->global) ||
|
||||||
!IsAtomOrIntTerm(gl->global)) {
|
!IsAtomOrIntTerm(gl->global)) {
|
||||||
gl->global = AdjustGlobTerm(gl->global);
|
gl->global = AdjustGlobTerm(gl->global PASS_REGS);
|
||||||
}
|
}
|
||||||
gl = gl->NextGE;
|
gl = gl->NextGE;
|
||||||
}
|
}
|
||||||
@ -538,7 +539,7 @@ AdjustGlobal(long sz, int thread_copying)
|
|||||||
/* sal->ValueOfVE.lterms[i].tlive = AdjustGlobTerm(sal->ValueOfVE.lterms[i].tlive); */
|
/* sal->ValueOfVE.lterms[i].tlive = AdjustGlobTerm(sal->ValueOfVE.lterms[i].tlive); */
|
||||||
Term tlive = sal->ValueOfVE.lterms[i].tlive;
|
Term tlive = sal->ValueOfVE.lterms[i].tlive;
|
||||||
if (!IsVarTerm(tlive) || !IsUnboundVar(&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);
|
*pt = TrailAdjust(reg);
|
||||||
#endif
|
#endif
|
||||||
} else if (IsApplTerm(reg))
|
} else if (IsApplTerm(reg))
|
||||||
*pt = AdjustAppl(reg);
|
*pt = AdjustAppl(reg PASS_REGS);
|
||||||
else if (IsPairTerm(reg))
|
else if (IsPairTerm(reg))
|
||||||
*pt = AdjustPair(reg);
|
*pt = AdjustPair(reg PASS_REGS);
|
||||||
else if (IsAtomTerm(reg))
|
else if (IsAtomTerm(reg))
|
||||||
*pt = AtomTermAdjust(reg);
|
*pt = AtomTermAdjust(reg);
|
||||||
pt++;
|
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
|
* (just once) the trail cells pointing both to the global and to the local
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AdjustStacksAndTrail(long sz, int copying_threads)
|
AdjustStacksAndTrail(long sz, int copying_threads USES_REGS)
|
||||||
{
|
{
|
||||||
AdjustTrail(TRUE, copying_threads);
|
AdjustTrail(TRUE, copying_threads PASS_REGS);
|
||||||
AdjustLocal(copying_threads);
|
AdjustLocal(copying_threads PASS_REGS);
|
||||||
AdjustGlobal(sz, copying_threads);
|
AdjustGlobal(sz, copying_threads PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Yap_AdjustStacksAndTrail(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
|
* local; the trail cells pointing to the local
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AdjustGrowStack(void)
|
AdjustGrowStack( USES_REGS1 )
|
||||||
{
|
{
|
||||||
AdjustTrail(FALSE, STACK_SHIFTING);
|
AdjustTrail(FALSE, STACK_SHIFTING PASS_REGS);
|
||||||
AdjustLocal(STACK_SHIFTING);
|
AdjustLocal(STACK_SHIFTING PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
AdjustRegs(int n)
|
AdjustRegs(int n USES_REGS)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
CELL reg;
|
CELL reg;
|
||||||
@ -664,28 +666,28 @@ AdjustRegs(int n)
|
|||||||
else if (IsOldCode(reg))
|
else if (IsOldCode(reg))
|
||||||
reg = CodeAdjust(reg);
|
reg = CodeAdjust(reg);
|
||||||
} else if (IsApplTerm(reg))
|
} else if (IsApplTerm(reg))
|
||||||
reg = AdjustAppl(reg);
|
reg = AdjustAppl(reg PASS_REGS);
|
||||||
else if (IsPairTerm(reg))
|
else if (IsPairTerm(reg))
|
||||||
reg = AdjustPair(reg);
|
reg = AdjustPair(reg PASS_REGS);
|
||||||
XREGS[i] = (Term) reg;
|
XREGS[i] = (Term) reg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
AdjustVarTable(VarEntry *ves)
|
AdjustVarTable(VarEntry *ves USES_REGS)
|
||||||
{
|
{
|
||||||
ves->VarAdr = TermNil;
|
ves->VarAdr = TermNil;
|
||||||
if (ves->VarRight != NULL) {
|
if (ves->VarRight != NULL) {
|
||||||
if (IsOldVarTableTrailPtr(ves->VarRight)) {
|
if (IsOldVarTableTrailPtr(ves->VarRight)) {
|
||||||
ves->VarRight = (VarEntry *)TrailAddrAdjust((ADDR)(ves->VarRight));
|
ves->VarRight = (VarEntry *)TrailAddrAdjust((ADDR)(ves->VarRight));
|
||||||
}
|
}
|
||||||
AdjustVarTable(ves->VarRight);
|
AdjustVarTable(ves->VarRight PASS_REGS);
|
||||||
}
|
}
|
||||||
if (ves->VarLeft != NULL) {
|
if (ves->VarLeft != NULL) {
|
||||||
if (IsOldVarTableTrailPtr(ves->VarLeft)) {
|
if (IsOldVarTableTrailPtr(ves->VarLeft)) {
|
||||||
ves->VarLeft = (VarEntry *)TrailAddrAdjust((ADDR)(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)
|
pointers created by the scanner (Tokens and Variables)
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AdjustScannerStacks(TokEntry **tksp, VarEntry **vep)
|
AdjustScannerStacks(TokEntry **tksp, VarEntry **vep USES_REGS)
|
||||||
{
|
{
|
||||||
TokEntry *tks = *tksp;
|
TokEntry *tks = *tksp;
|
||||||
VarEntry *ves = *vep;
|
VarEntry *ves = *vep;
|
||||||
@ -731,7 +733,7 @@ AdjustScannerStacks(TokEntry **tksp, VarEntry **vep)
|
|||||||
if (ves != NULL) {
|
if (ves != NULL) {
|
||||||
if (IsOldVarTableTrailPtr(ves))
|
if (IsOldVarTableTrailPtr(ves))
|
||||||
ves = *vep = (VarEntry *)TrailAddrAdjust((ADDR)ves);
|
ves = *vep = (VarEntry *)TrailAddrAdjust((ADDR)ves);
|
||||||
AdjustVarTable(ves);
|
AdjustVarTable(ves PASS_REGS);
|
||||||
}
|
}
|
||||||
ves = Yap_AnonVarTable;
|
ves = Yap_AnonVarTable;
|
||||||
if (ves != NULL) {
|
if (ves != NULL) {
|
||||||
@ -754,12 +756,13 @@ AdjustScannerStacks(TokEntry **tksp, VarEntry **vep)
|
|||||||
void
|
void
|
||||||
Yap_AdjustRegs(int n)
|
Yap_AdjustRegs(int n)
|
||||||
{
|
{
|
||||||
AdjustRegs(n);
|
CACHE_REGS
|
||||||
|
AdjustRegs(n PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Used by do_goal() when we're short of heap space */
|
/* Used by do_goal() when we're short of heap space */
|
||||||
static int
|
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;
|
UInt start_growth_time, growth_time;
|
||||||
int gc_verbose;
|
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;
|
TrDiff = LDiff = GDiff = GDiff0 = DelayDiff = BaseDiff = size;
|
||||||
XDiff = HDiff = 0;
|
XDiff = HDiff = 0;
|
||||||
GSplit = NULL;
|
GSplit = NULL;
|
||||||
SetHeapRegs(FALSE);
|
SetHeapRegs(FALSE PASS_REGS);
|
||||||
MoveLocalAndTrail();
|
MoveLocalAndTrail( PASS_REGS1 );
|
||||||
if (fix_code) {
|
if (fix_code) {
|
||||||
CELL *SaveOldH = OldH;
|
CELL *SaveOldH = OldH;
|
||||||
OldH = (CELL *)cip->freep;
|
OldH = (CELL *)cip->freep;
|
||||||
MoveGlobal();
|
MoveGlobal( PASS_REGS1 );
|
||||||
OldH = SaveOldH;
|
OldH = SaveOldH;
|
||||||
} else {
|
} else {
|
||||||
MoveGlobal();
|
MoveGlobal( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
if (old_trp) {
|
if (old_trp) {
|
||||||
tr_fr_ptr nTR;
|
tr_fr_ptr nTR;
|
||||||
|
|
||||||
AdjustScannerStacks(tksp, vep);
|
AdjustScannerStacks(tksp, vep PASS_REGS);
|
||||||
nTR = TR;
|
nTR = TR;
|
||||||
*old_trp = PtoTRAdjust(*old_trp);
|
*old_trp = PtoTRAdjust(*old_trp);
|
||||||
TR = *old_trp;
|
TR = *old_trp;
|
||||||
AdjustStacksAndTrail(0, FALSE);
|
AdjustStacksAndTrail(0, FALSE PASS_REGS);
|
||||||
TR = nTR;
|
TR = nTR;
|
||||||
} else {
|
} else {
|
||||||
AdjustStacksAndTrail(0, FALSE);
|
AdjustStacksAndTrail(0, FALSE PASS_REGS);
|
||||||
}
|
}
|
||||||
AdjustRegs(MaxTemps);
|
AdjustRegs(MaxTemps PASS_REGS);
|
||||||
YAPLeaveCriticalSection();
|
YAPLeaveCriticalSection();
|
||||||
ASP += 256;
|
ASP += 256;
|
||||||
if (minimal_request)
|
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
|
/* Used when we're short of heap, usually because of an overflow in
|
||||||
the attributed stack, but also because we allocated a zone */
|
the attributed stack, but also because we allocated a zone */
|
||||||
static int
|
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;
|
UInt start_growth_time, growth_time;
|
||||||
int gc_verbose;
|
int gc_verbose;
|
||||||
@ -980,24 +983,24 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit)
|
|||||||
GSplit = hsplit;
|
GSplit = hsplit;
|
||||||
XDiff = HDiff = 0;
|
XDiff = HDiff = 0;
|
||||||
Yap_GlobalBase = old_GlobalBase;
|
Yap_GlobalBase = old_GlobalBase;
|
||||||
SetHeapRegs(FALSE);
|
SetHeapRegs(FALSE PASS_REGS);
|
||||||
if (do_grow) {
|
if (do_grow) {
|
||||||
MoveLocalAndTrail();
|
MoveLocalAndTrail( PASS_REGS1 );
|
||||||
if (hsplit) {
|
if (hsplit) {
|
||||||
MoveGlobalWithHole();
|
MoveGlobalWithHole( PASS_REGS1 );
|
||||||
} else {
|
} else {
|
||||||
MoveExpandedGlobal();
|
MoveExpandedGlobal( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
} else if (!hsplit) {
|
} else if (!hsplit) {
|
||||||
MoveExpandedGlobal();
|
MoveExpandedGlobal( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
/* don't run through garbage */
|
/* don't run through garbage */
|
||||||
if (hsplit && (OldH != hsplit)) {
|
if (hsplit && (OldH != hsplit)) {
|
||||||
AdjustStacksAndTrail(request, FALSE);
|
AdjustStacksAndTrail(request, FALSE PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
AdjustStacksAndTrail(0, FALSE);
|
AdjustStacksAndTrail(0, FALSE PASS_REGS);
|
||||||
}
|
}
|
||||||
AdjustRegs(MaxTemps);
|
AdjustRegs(MaxTemps PASS_REGS);
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
*ptr = PtoLocAdjust(*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 */
|
/* we have things not quite where we want to have them */
|
||||||
cpcellsd((CELL *)(omax+DelayDiff), (CELL *)(omax+GDiff0), (ADDR)hsplit-omax);
|
cpcellsd((CELL *)(omax+DelayDiff), (CELL *)(omax+GDiff0), (ADDR)hsplit-omax);
|
||||||
} else {
|
} else {
|
||||||
MoveHalfGlobal(hsplit);
|
MoveHalfGlobal(hsplit PASS_REGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
YAPLeaveCriticalSection();
|
YAPLeaveCriticalSection();
|
||||||
@ -1028,7 +1031,7 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fix_compiler_instructions(PInstr *pcpc)
|
fix_compiler_instructions(PInstr *pcpc USES_REGS)
|
||||||
{
|
{
|
||||||
while (pcpc != NULL) {
|
while (pcpc != NULL) {
|
||||||
PInstr *ncpc = pcpc->nextInst;
|
PInstr *ncpc = pcpc->nextInst;
|
||||||
@ -1071,7 +1074,7 @@ fix_compiler_instructions(PInstr *pcpc)
|
|||||||
case unify_last_float_op:
|
case unify_last_float_op:
|
||||||
case write_float_op:
|
case write_float_op:
|
||||||
/* floats might be in the global */
|
/* floats might be in the global */
|
||||||
pcpc->rnd1 = AdjustAppl(pcpc->rnd1);
|
pcpc->rnd1 = AdjustAppl(pcpc->rnd1 PASS_REGS);
|
||||||
break;
|
break;
|
||||||
/* hopefully nothing to do */
|
/* hopefully nothing to do */
|
||||||
case nop_op:
|
case nop_op:
|
||||||
@ -1215,7 +1218,7 @@ fix_compiler_instructions(PInstr *pcpc)
|
|||||||
|
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
static void
|
static void
|
||||||
fix_tabling_info(void)
|
fix_tabling_info( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/* we must fix the dependency frames and the subgoal frames, as they are
|
/* we must fix the dependency frames and the subgoal frames, as they are
|
||||||
pointing back to the global stack. */
|
pointing back to the global stack. */
|
||||||
@ -1239,7 +1242,7 @@ fix_tabling_info(void)
|
|||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
|
|
||||||
static int
|
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;
|
unsigned long size = sizeof(CELL) * K16;
|
||||||
int shift_factor = (heap_overflows > 8 ? 8 : heap_overflows);
|
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;
|
size = YAP_ALLOC_SIZE;
|
||||||
sz = AdjustPageSize(SizeOfOverflow);
|
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;
|
size = size/2;
|
||||||
sz = size << shift_factor;
|
sz = size << shift_factor;
|
||||||
if (sz < in_size) {
|
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) {
|
if (pcpc != NULL) {
|
||||||
cip->CodeStart = pcpc = (PInstr *)GlobalAddrAdjust((ADDR)pcpc);
|
cip->CodeStart = pcpc = (PInstr *)GlobalAddrAdjust((ADDR)pcpc);
|
||||||
}
|
}
|
||||||
fix_compiler_instructions(pcpc);
|
fix_compiler_instructions(pcpc PASS_REGS);
|
||||||
pcpc = cip->BlobsStart;
|
pcpc = cip->BlobsStart;
|
||||||
if (pcpc != NULL) {
|
if (pcpc != NULL) {
|
||||||
cip->BlobsStart = pcpc = (PInstr *)GlobalAddrAdjust((ADDR)pcpc);
|
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->freep = (char *)GlobalAddrAdjust((ADDR)cip->freep);
|
||||||
cip->label_offset = (Int *)GlobalAddrAdjust((ADDR)cip->label_offset);
|
cip->label_offset = (Int *)GlobalAddrAdjust((ADDR)cip->label_offset);
|
||||||
}
|
}
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
fix_tabling_info();
|
fix_tabling_info( PASS_REGS1 );
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
if (sz >= sizeof(CELL) * K16) {
|
if (sz >= sizeof(CELL) * K16) {
|
||||||
LOCK(SignalLock);
|
LOCK(SignalLock);
|
||||||
@ -1331,7 +1334,7 @@ cp_atom_table(AtomHashEntry *ntb, UInt nsize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
growatomtable(void)
|
growatomtable( USES_REGS1 )
|
||||||
{
|
{
|
||||||
AtomHashEntry *ntb;
|
AtomHashEntry *ntb;
|
||||||
UInt nsize = 4*AtomHashTableSize-1;
|
UInt nsize = 4*AtomHashTableSize-1;
|
||||||
@ -1379,7 +1382,7 @@ growatomtable(void)
|
|||||||
/* make sure there is no heap overflow */
|
/* make sure there is no heap overflow */
|
||||||
int res;
|
int res;
|
||||||
YAPEnterCriticalSection();
|
YAPEnterCriticalSection();
|
||||||
res = do_growheap(FALSE, 0, NULL, NULL, NULL, NULL);
|
res = do_growheap(FALSE, 0, NULL, NULL, NULL, NULL PASS_REGS);
|
||||||
YAPLeaveCriticalSection();
|
YAPLeaveCriticalSection();
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
@ -1392,16 +1395,17 @@ growatomtable(void)
|
|||||||
int
|
int
|
||||||
Yap_growheap(int fix_code, UInt in_size, void *cip)
|
Yap_growheap(int fix_code, UInt in_size, void *cip)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (NOfAtoms > 2*AtomHashTableSize) {
|
if (NOfAtoms > 2*AtomHashTableSize) {
|
||||||
UInt n = NOfAtoms;
|
UInt n = NOfAtoms;
|
||||||
if (AGcThreshold)
|
if (AGcThreshold)
|
||||||
Yap_atom_gc();
|
Yap_atom_gc( PASS_REGS1 );
|
||||||
/* check if we have a significant improvement from agc */
|
/* check if we have a significant improvement from agc */
|
||||||
if (n > NOfAtoms+ NOfAtoms/10 ||
|
if (n > NOfAtoms+ NOfAtoms/10 ||
|
||||||
NOfAtoms > 2*AtomHashTableSize) {
|
NOfAtoms > 2*AtomHashTableSize) {
|
||||||
res = growatomtable();
|
res = growatomtable( PASS_REGS1 );
|
||||||
} else {
|
} else {
|
||||||
LOCK(SignalLock);
|
LOCK(SignalLock);
|
||||||
if (ActiveSignals == YAP_CDOVF_SIGNAL) {
|
if (ActiveSignals == YAP_CDOVF_SIGNAL) {
|
||||||
@ -1414,7 +1418,7 @@ Yap_growheap(int fix_code, UInt in_size, void *cip)
|
|||||||
LeaveGrowMode(GrowHeapMode);
|
LeaveGrowMode(GrowHeapMode);
|
||||||
return res;
|
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);
|
LeaveGrowMode(GrowHeapMode);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -1422,9 +1426,10 @@ Yap_growheap(int fix_code, UInt in_size, void *cip)
|
|||||||
int
|
int
|
||||||
Yap_growheap_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
Yap_growheap_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
int res;
|
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);
|
LeaveGrowMode(GrowHeapMode);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -1432,6 +1437,7 @@ Yap_growheap_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
|||||||
int
|
int
|
||||||
Yap_growglobal(CELL **ptr)
|
Yap_growglobal(CELL **ptr)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
unsigned long sz = sizeof(CELL) * K16;
|
unsigned long sz = sizeof(CELL) * K16;
|
||||||
|
|
||||||
#if defined(YAPOR) && !defined(THREADS)
|
#if defined(YAPOR) && !defined(THREADS)
|
||||||
@ -1445,10 +1451,10 @@ Yap_growglobal(CELL **ptr)
|
|||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if ( static_growglobal(sz, ptr, NULL) == 0)
|
if ( static_growglobal(sz, ptr, NULL PASS_REGS) == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
fix_tabling_info();
|
fix_tabling_info( PASS_REGS1 );
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1457,10 +1463,11 @@ Yap_growglobal(CELL **ptr)
|
|||||||
UInt
|
UInt
|
||||||
Yap_InsertInGlobal(CELL *where, UInt howmuch)
|
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;
|
return 0;
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
fix_tabling_info();
|
fix_tabling_info( PASS_REGS1 );
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
return howmuch;
|
return howmuch;
|
||||||
}
|
}
|
||||||
@ -1469,16 +1476,17 @@ Yap_InsertInGlobal(CELL *where, UInt howmuch)
|
|||||||
int
|
int
|
||||||
Yap_growstack(long size)
|
Yap_growstack(long size)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
Yap_PrologMode |= GrowStackMode;
|
Yap_PrologMode |= GrowStackMode;
|
||||||
res=growstack(size);
|
res=growstack(size PASS_REGS);
|
||||||
LeaveGrowMode(GrowStackMode);
|
LeaveGrowMode(GrowStackMode);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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;
|
UInt minimal_request = 0L;
|
||||||
long size = size0;
|
long size = size0;
|
||||||
@ -1526,50 +1534,50 @@ execute_growstack(long size0, int from_trail, int in_parser, tr_fr_ptr *old_trp,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ASP -= 256;
|
ASP -= 256;
|
||||||
SetHeapRegs(FALSE);
|
SetHeapRegs(FALSE PASS_REGS);
|
||||||
if (from_trail) {
|
if (from_trail) {
|
||||||
Yap_TrailTop += size0;
|
Yap_TrailTop += size0;
|
||||||
}
|
}
|
||||||
if (LDiff) {
|
if (LDiff) {
|
||||||
MoveLocalAndTrail();
|
MoveLocalAndTrail( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
if (GDiff) {
|
if (GDiff) {
|
||||||
#if !USE_SYSTEM_MALLOC
|
#if !USE_SYSTEM_MALLOC
|
||||||
/* That is done by realloc */
|
/* That is done by realloc */
|
||||||
MoveGlobal();
|
MoveGlobal( PASS_REGS1 );
|
||||||
#endif
|
#endif
|
||||||
if (in_parser) {
|
if (in_parser) {
|
||||||
tr_fr_ptr nTR;
|
tr_fr_ptr nTR;
|
||||||
|
|
||||||
AdjustScannerStacks(tksp, vep);
|
AdjustScannerStacks(tksp, vep PASS_REGS);
|
||||||
nTR = TR;
|
nTR = TR;
|
||||||
*old_trp = PtoTRAdjust(*old_trp);
|
*old_trp = PtoTRAdjust(*old_trp);
|
||||||
TR = *old_trp;
|
TR = *old_trp;
|
||||||
AdjustStacksAndTrail(0, FALSE);
|
AdjustStacksAndTrail(0, FALSE PASS_REGS);
|
||||||
TR = nTR;
|
TR = nTR;
|
||||||
} else {
|
} else {
|
||||||
AdjustStacksAndTrail(0, FALSE);
|
AdjustStacksAndTrail(0, FALSE PASS_REGS);
|
||||||
}
|
}
|
||||||
AdjustRegs(MaxTemps);
|
AdjustRegs(MaxTemps PASS_REGS);
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
fix_tabling_info();
|
fix_tabling_info( PASS_REGS1 );
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
} else if (LDiff) {
|
} else if (LDiff) {
|
||||||
if (in_parser) {
|
if (in_parser) {
|
||||||
tr_fr_ptr nTR;
|
tr_fr_ptr nTR;
|
||||||
|
|
||||||
AdjustScannerStacks(tksp, vep);
|
AdjustScannerStacks(tksp, vep PASS_REGS);
|
||||||
nTR = TR;
|
nTR = TR;
|
||||||
*old_trp = PtoTRAdjust(*old_trp);
|
*old_trp = PtoTRAdjust(*old_trp);
|
||||||
TR = *old_trp;
|
TR = *old_trp;
|
||||||
AdjustGrowStack();
|
AdjustGrowStack( PASS_REGS1 );
|
||||||
TR = nTR;
|
TR = nTR;
|
||||||
} else {
|
} else {
|
||||||
AdjustGrowStack();
|
AdjustGrowStack( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
AdjustRegs(MaxTemps);
|
AdjustRegs(MaxTemps PASS_REGS);
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
fix_tabling_info();
|
fix_tabling_info( PASS_REGS1 );
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
}
|
}
|
||||||
YAPLeaveCriticalSection();
|
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 */
|
/* Used by do_goal() when we're short of stack space */
|
||||||
static int
|
static int
|
||||||
growstack(long size)
|
growstack(long size USES_REGS)
|
||||||
{
|
{
|
||||||
UInt start_growth_time, growth_time;
|
UInt start_growth_time, growth_time;
|
||||||
int gc_verbose;
|
int gc_verbose;
|
||||||
@ -1605,7 +1613,7 @@ growstack(long size)
|
|||||||
(unsigned long int)(TR-(tr_fr_ptr)Yap_TrailBase),Yap_TrailBase,TR);
|
(unsigned long int)(TR-(tr_fr_ptr)Yap_TrailBase),Yap_TrailBase,TR);
|
||||||
fprintf(Yap_stderr, "%% Growing the stacks %ld bytes\n", size);
|
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;
|
return FALSE;
|
||||||
growth_time = Yap_cputime()-start_growth_time;
|
growth_time = Yap_cputime()-start_growth_time;
|
||||||
total_stack_overflow_time += growth_time;
|
total_stack_overflow_time += growth_time;
|
||||||
@ -1620,6 +1628,7 @@ growstack(long size)
|
|||||||
int
|
int
|
||||||
Yap_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
Yap_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
UInt size;
|
UInt size;
|
||||||
UInt start_growth_time, growth_time;
|
UInt start_growth_time, growth_time;
|
||||||
int gc_verbose;
|
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);
|
(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);
|
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);
|
LeaveGrowMode(GrowStackMode);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1656,7 +1665,7 @@ Yap_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
|||||||
return TRUE;
|
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;
|
UInt start_growth_time = Yap_cputime(), growth_time;
|
||||||
int gc_verbose = Yap_is_gc_verbose();
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#if USE_SYSTEM_MALLOC
|
#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
|
#else
|
||||||
if (!Yap_ExtendWorkSpace(size)) {
|
if (!Yap_ExtendWorkSpace(size)) {
|
||||||
Yap_ErrorMessage = NULL;
|
Yap_ErrorMessage = NULL;
|
||||||
@ -1707,12 +1716,12 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr
|
|||||||
trail_overflows--;
|
trail_overflows--;
|
||||||
return FALSE;
|
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 {
|
} else {
|
||||||
YAPEnterCriticalSection();
|
YAPEnterCriticalSection();
|
||||||
if (in_parser) {
|
if (in_parser) {
|
||||||
TrDiff = LDiff = GDiff = BaseDiff = DelayDiff = XDiff = HDiff = GDiff0 = 0;
|
TrDiff = LDiff = GDiff = BaseDiff = DelayDiff = XDiff = HDiff = GDiff0 = 0;
|
||||||
AdjustScannerStacks(tksp, vep);
|
AdjustScannerStacks(tksp, vep PASS_REGS);
|
||||||
}
|
}
|
||||||
Yap_TrailTop += size;
|
Yap_TrailTop += size;
|
||||||
YAPLeaveCriticalSection();
|
YAPLeaveCriticalSection();
|
||||||
@ -1738,18 +1747,21 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr
|
|||||||
int
|
int
|
||||||
Yap_growtrail(long size, int contiguous_only)
|
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
|
int
|
||||||
Yap_growtrail_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
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 **
|
CELL **
|
||||||
Yap_shift_visit(CELL **to_visit, CELL ***to_visit_maxp)
|
Yap_shift_visit(CELL **to_visit, CELL ***to_visit_maxp)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
CELL **to_visit_max = *to_visit_maxp;
|
CELL **to_visit_max = *to_visit_maxp;
|
||||||
/* relative position of top of stack */
|
/* relative position of top of stack */
|
||||||
Int off = (ADDR)to_visit-AuxBase;
|
Int off = (ADDR)to_visit-AuxBase;
|
||||||
@ -1786,7 +1798,7 @@ Yap_shift_visit(CELL **to_visit, CELL ***to_visit_maxp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_inform_trail_overflows(void)
|
p_inform_trail_overflows( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term tn = MkIntTerm(trail_overflows);
|
Term tn = MkIntTerm(trail_overflows);
|
||||||
Term tt = MkIntegerTerm(total_trail_overflow_time);
|
Term tt = MkIntegerTerm(total_trail_overflow_time);
|
||||||
@ -1796,7 +1808,7 @@ p_inform_trail_overflows(void)
|
|||||||
|
|
||||||
/* :- grow_heap(Size) */
|
/* :- grow_heap(Size) */
|
||||||
static Int
|
static Int
|
||||||
p_growheap(void)
|
p_growheap( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Int diff;
|
Int diff;
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
@ -1812,11 +1824,11 @@ p_growheap(void)
|
|||||||
if (diff < 0) {
|
if (diff < 0) {
|
||||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t1, "grow_heap/1");
|
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
|
static Int
|
||||||
p_inform_heap_overflows(void)
|
p_inform_heap_overflows( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term tn = MkIntTerm(heap_overflows);
|
Term tn = MkIntTerm(heap_overflows);
|
||||||
Term tt = MkIntegerTerm(total_heap_overflow_time);
|
Term tt = MkIntegerTerm(total_heap_overflow_time);
|
||||||
@ -1828,6 +1840,7 @@ p_inform_heap_overflows(void)
|
|||||||
void
|
void
|
||||||
Yap_CopyThreadStacks(int worker_q, int worker_p, int incremental)
|
Yap_CopyThreadStacks(int worker_q, int worker_p, int incremental)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Int size;
|
Int size;
|
||||||
|
|
||||||
/* make sure both stacks have same size */
|
/* make sure both stacks have same size */
|
||||||
@ -1865,9 +1878,9 @@ Yap_CopyThreadStacks(int worker_q, int worker_p, int incremental)
|
|||||||
DynamicArrays = NULL;
|
DynamicArrays = NULL;
|
||||||
StaticArrays = NULL;
|
StaticArrays = NULL;
|
||||||
GlobalVariables = NULL;
|
GlobalVariables = NULL;
|
||||||
SetHeapRegs(TRUE);
|
SetHeapRegs(TRUE PASS_REGS);
|
||||||
if (incremental) {
|
if (incremental) {
|
||||||
IncrementalCopyStacksFromWorker();
|
IncrementalCopyStacksFromWorker( PASS_REGS1 );
|
||||||
LOCAL_start_global_copy =
|
LOCAL_start_global_copy =
|
||||||
(CELL)PtoGloAdjust((CELL *)LOCAL_start_global_copy);
|
(CELL)PtoGloAdjust((CELL *)LOCAL_start_global_copy);
|
||||||
LOCAL_end_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);
|
(CELL)PtoTRAdjust((tr_fr_ptr)LOCAL_start_trail_copy);
|
||||||
LOCAL_end_trail_copy =
|
LOCAL_end_trail_copy =
|
||||||
(CELL)PtoTRAdjust((tr_fr_ptr)LOCAL_end_trail_copy);
|
(CELL)PtoTRAdjust((tr_fr_ptr)LOCAL_end_trail_copy);
|
||||||
AdjustStacksAndTrail(0, STACK_INCREMENTAL_COPYING);
|
AdjustStacksAndTrail(0, STACK_INCREMENTAL_COPYING PASS_REGS);
|
||||||
RestoreTrail(worker_p);
|
RestoreTrail(worker_p PASS_REGS);
|
||||||
TR = (tr_fr_ptr) LOCAL_end_trail_copy;
|
TR = (tr_fr_ptr) LOCAL_end_trail_copy;
|
||||||
} else {
|
} else {
|
||||||
CopyLocalAndTrail();
|
CopyLocalAndTrail( PASS_REGS1 );
|
||||||
MoveGlobal();
|
MoveGlobal( PASS_REGS1 );
|
||||||
AdjustStacksAndTrail(0, STACK_COPYING);
|
AdjustStacksAndTrail(0, STACK_COPYING PASS_REGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* :- grow_stack(Size) */
|
/* :- grow_stack(Size) */
|
||||||
static Int
|
static Int
|
||||||
p_growstack(void)
|
p_growstack( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Int diff;
|
Int diff;
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
@ -1909,11 +1922,11 @@ p_growstack(void)
|
|||||||
if (diff < 0) {
|
if (diff < 0) {
|
||||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t1, "grow_stack/1");
|
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t1, "grow_stack/1");
|
||||||
}
|
}
|
||||||
return(growstack(diff));
|
return(growstack(diff PASS_REGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_inform_stack_overflows(void)
|
p_inform_stack_overflows( USES_REGS1 )
|
||||||
{ /* */
|
{ /* */
|
||||||
Term tn = MkIntTerm(stack_overflows);
|
Term tn = MkIntTerm(stack_overflows);
|
||||||
Term tt = MkIntegerTerm(total_stack_overflow_time);
|
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 USE_SYSTEM_MALLOC
|
||||||
if (!(base = (CELL *)Yap_AllocCodeSpace(2*max*sizeof(CELL)))) {
|
if (!(base = (CELL *)Yap_AllocCodeSpace(2*max*sizeof(CELL)))) {
|
||||||
|
CACHE_REGS
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
Yap_Error_Size = 2*max*sizeof(CELL);
|
Yap_Error_Size = 2*max*sizeof(CELL);
|
||||||
siglongjmp(cint->CompilerBotch,2);
|
siglongjmp(cint->CompilerBotch,2);
|
||||||
@ -2003,6 +2004,7 @@ skip_to_arg(ClauseDef *clause, PredEntry *ap, UInt argno, int at_point)
|
|||||||
static UInt
|
static UInt
|
||||||
groups_in(ClauseDef *min, ClauseDef *max, GroupDef *grp, struct intermediates *cint)
|
groups_in(ClauseDef *min, ClauseDef *max, GroupDef *grp, struct intermediates *cint)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
UInt groups = 0;
|
UInt groups = 0;
|
||||||
|
|
||||||
while(min <= max) {
|
while(min <= max) {
|
||||||
@ -3000,6 +3002,7 @@ cls_head_info(ClauseDef *min, ClauseDef *max, UInt argno, int in_idb)
|
|||||||
static UInt
|
static UInt
|
||||||
do_index(ClauseDef *min, ClauseDef* max, struct intermediates *cint, UInt argno, UInt fail_l, int first, int clleft, CELL *top)
|
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 ngroups, found_pvar = FALSE;
|
||||||
UInt i = 0;
|
UInt i = 0;
|
||||||
GroupDef *group = (GroupDef *)top;
|
GroupDef *group = (GroupDef *)top;
|
||||||
@ -3137,6 +3140,7 @@ do_index(ClauseDef *min, ClauseDef* max, struct intermediates *cint, UInt argno,
|
|||||||
static ClauseDef *
|
static ClauseDef *
|
||||||
copy_clauses(ClauseDef *max0, ClauseDef *min0, CELL *top, struct intermediates *cint)
|
copy_clauses(ClauseDef *max0, ClauseDef *min0, CELL *top, struct intermediates *cint)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
UInt sz = ((max0+1)-min0)*sizeof(ClauseDef);
|
UInt sz = ((max0+1)-min0)*sizeof(ClauseDef);
|
||||||
if ((char *)top + sz >= Yap_TrailTop-4096) {
|
if ((char *)top + sz >= Yap_TrailTop-4096) {
|
||||||
Yap_Error_Size = sz;
|
Yap_Error_Size = sz;
|
||||||
@ -3319,6 +3323,7 @@ init_log_upd_clauses(ClauseDef *cl, PredEntry *ap)
|
|||||||
static UInt
|
static UInt
|
||||||
compile_index(struct intermediates *cint)
|
compile_index(struct intermediates *cint)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
PredEntry *ap = cint->CurrentPred;
|
PredEntry *ap = cint->CurrentPred;
|
||||||
int NClauses = ap->cs.p_code.NOfClauses;
|
int NClauses = ap->cs.p_code.NOfClauses;
|
||||||
CELL *top = (CELL *) TR;
|
CELL *top = (CELL *) TR;
|
||||||
@ -3382,6 +3387,7 @@ CleanCls(struct intermediates *cint)
|
|||||||
yamop *
|
yamop *
|
||||||
Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc)
|
Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
yamop *indx_out;
|
yamop *indx_out;
|
||||||
int setjres;
|
int setjres;
|
||||||
struct intermediates cint;
|
struct intermediates cint;
|
||||||
@ -3471,6 +3477,7 @@ Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc)
|
|||||||
static istack_entry *
|
static istack_entry *
|
||||||
push_stack(istack_entry *sp, Int arg, Term Tag, Term extra, struct intermediates *cint)
|
push_stack(istack_entry *sp, Int arg, Term Tag, Term extra, struct intermediates *cint)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (sp+1 > (istack_entry *)Yap_TrailTop) {
|
if (sp+1 > (istack_entry *)Yap_TrailTop) {
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
siglongjmp(cint->CompilerBotch,4);
|
siglongjmp(cint->CompilerBotch,4);
|
||||||
@ -3917,6 +3924,7 @@ code_to_indexcl(yamop *ipc, int is_lu)
|
|||||||
|
|
||||||
static yamop **
|
static yamop **
|
||||||
expand_index(struct intermediates *cint) {
|
expand_index(struct intermediates *cint) {
|
||||||
|
CACHE_REGS
|
||||||
/* first clause */
|
/* first clause */
|
||||||
PredEntry *ap = cint->CurrentPred;
|
PredEntry *ap = cint->CurrentPred;
|
||||||
yamop *first, *last = NULL, *alt = NULL;
|
yamop *first, *last = NULL, *alt = NULL;
|
||||||
@ -4485,7 +4493,7 @@ expand_index(struct intermediates *cint) {
|
|||||||
|
|
||||||
|
|
||||||
static yamop *
|
static yamop *
|
||||||
ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop) {
|
ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop USES_REGS) {
|
||||||
yamop *indx_out, *expand_clauses;
|
yamop *indx_out, *expand_clauses;
|
||||||
yamop **labp;
|
yamop **labp;
|
||||||
int cb;
|
int cb;
|
||||||
@ -4496,6 +4504,7 @@ ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop) {
|
|||||||
cint.code_addr = NULL;
|
cint.code_addr = NULL;
|
||||||
cint.label_offset = NULL;
|
cint.label_offset = NULL;
|
||||||
if ((cb = sigsetjmp(cint.CompilerBotch, 0)) == 3) {
|
if ((cb = sigsetjmp(cint.CompilerBotch, 0)) == 3) {
|
||||||
|
CACHE_REGS
|
||||||
restore_machine_regs();
|
restore_machine_regs();
|
||||||
/* grow stack */
|
/* grow stack */
|
||||||
recover_from_failed_susp_on_cls(&cint, 0);
|
recover_from_failed_susp_on_cls(&cint, 0);
|
||||||
@ -4692,12 +4701,14 @@ ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop) {
|
|||||||
|
|
||||||
yamop *
|
yamop *
|
||||||
Yap_ExpandIndex(PredEntry *ap, UInt nargs) {
|
Yap_ExpandIndex(PredEntry *ap, UInt nargs) {
|
||||||
return ExpandIndex(ap, nargs, CP);
|
CACHE_REGS
|
||||||
|
return ExpandIndex(ap, nargs, CP PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static path_stack_entry *
|
static path_stack_entry *
|
||||||
push_path(path_stack_entry *sp, yamop **pipc, ClauseDef *clp, struct intermediates *cint)
|
push_path(path_stack_entry *sp, yamop **pipc, ClauseDef *clp, struct intermediates *cint)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (sp+1 > (path_stack_entry *)Yap_TrailTop) {
|
if (sp+1 > (path_stack_entry *)Yap_TrailTop) {
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
siglongjmp(cint->CompilerBotch,4);
|
siglongjmp(cint->CompilerBotch,4);
|
||||||
@ -4714,6 +4725,7 @@ push_path(path_stack_entry *sp, yamop **pipc, ClauseDef *clp, struct intermediat
|
|||||||
static path_stack_entry *
|
static path_stack_entry *
|
||||||
fetch_new_block(path_stack_entry *sp, yamop **pipc, PredEntry *ap, struct intermediates *cint)
|
fetch_new_block(path_stack_entry *sp, yamop **pipc, PredEntry *ap, struct intermediates *cint)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (sp+1 > (path_stack_entry *)Yap_TrailTop) {
|
if (sp+1 > (path_stack_entry *)Yap_TrailTop) {
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
siglongjmp(cint->CompilerBotch,4);
|
siglongjmp(cint->CompilerBotch,4);
|
||||||
@ -5993,6 +6005,7 @@ add_to_index(struct intermediates *cint, int first, path_stack_entry *sp, Clause
|
|||||||
|
|
||||||
void
|
void
|
||||||
Yap_AddClauseToIndex(PredEntry *ap, yamop *beg, int first) {
|
Yap_AddClauseToIndex(PredEntry *ap, yamop *beg, int first) {
|
||||||
|
CACHE_REGS
|
||||||
ClauseDef cl;
|
ClauseDef cl;
|
||||||
/* first clause */
|
/* first clause */
|
||||||
path_stack_entry *stack, *sp;
|
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 */
|
/* clause is locked */
|
||||||
void
|
void
|
||||||
Yap_RemoveClauseFromIndex(PredEntry *ap, yamop *beg) {
|
Yap_RemoveClauseFromIndex(PredEntry *ap, yamop *beg) {
|
||||||
|
CACHE_REGS
|
||||||
ClauseDef cl;
|
ClauseDef cl;
|
||||||
/* first clause */
|
/* first clause */
|
||||||
path_stack_entry *stack, *sp;
|
path_stack_entry *stack, *sp;
|
||||||
@ -6578,7 +6592,7 @@ Yap_RemoveClauseFromIndex(PredEntry *ap, yamop *beg) {
|
|||||||
|
|
||||||
|
|
||||||
static void
|
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 tpc = MkIntegerTerm((Int)ipc);
|
||||||
Term tpe = MkIntegerTerm((Int)pe);
|
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
|
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);
|
Term tpc = MkIntegerTerm((Int)ipc);
|
||||||
B->cp_args[1] = tpc;
|
B->cp_args[1] = tpc;
|
||||||
@ -6632,6 +6646,7 @@ to_clause(yamop *ipc, PredEntry *ap)
|
|||||||
LogUpdClause *
|
LogUpdClause *
|
||||||
Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, yamop *cp_pc)
|
Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, yamop *cp_pc)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
CELL *s_reg = NULL;
|
CELL *s_reg = NULL;
|
||||||
Term t = TermNil;
|
Term t = TermNil;
|
||||||
yamop *start_pc = ipc;
|
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);
|
op_numbers op = Yap_op_from_opcode(ipc->opc);
|
||||||
switch(op) {
|
switch(op) {
|
||||||
case _try_in:
|
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)
|
if (lu_pred)
|
||||||
return lu_clause(ipc->u.l.l, ap);
|
return lu_clause(ipc->u.l.l, ap);
|
||||||
else
|
else
|
||||||
@ -6666,11 +6681,11 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
|||||||
case _table_try:
|
case _table_try:
|
||||||
#endif
|
#endif
|
||||||
if (b0 == NULL)
|
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 {
|
else {
|
||||||
B = b0;
|
B = b0;
|
||||||
b0 = NULL;
|
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)
|
if (lu_pred)
|
||||||
return lu_clause(ipc->u.Otapl.d, ap);
|
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_clause3:
|
||||||
case _try_clause4:
|
case _try_clause4:
|
||||||
if (b0 == NULL)
|
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 {
|
else {
|
||||||
B = b0;
|
B = b0;
|
||||||
b0 = NULL;
|
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)
|
if (lu_pred)
|
||||||
return lu_clause(ipc->u.l.l, ap);
|
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:
|
case _table_try_me:
|
||||||
#endif
|
#endif
|
||||||
if (b0 == NULL)
|
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 {
|
else {
|
||||||
B = b0;
|
B = b0;
|
||||||
b0 = NULL;
|
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);
|
ipc = NEXTOP(ipc,Otapl);
|
||||||
break;
|
break;
|
||||||
@ -6711,7 +6726,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
|||||||
#if TABLING
|
#if TABLING
|
||||||
case _table_retry:
|
case _table_retry:
|
||||||
#endif
|
#endif
|
||||||
update_clause_choice_point(NEXTOP(ipc,Otapl),ap_pc);
|
update_clause_choice_point(NEXTOP(ipc,Otapl),ap_pc PASS_REGS);
|
||||||
if (lu_pred)
|
if (lu_pred)
|
||||||
return lu_clause(ipc->u.Otapl.d, ap);
|
return lu_clause(ipc->u.Otapl.d, ap);
|
||||||
else
|
else
|
||||||
@ -6719,13 +6734,13 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
|||||||
case _retry2:
|
case _retry2:
|
||||||
case _retry3:
|
case _retry3:
|
||||||
case _retry4:
|
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)
|
if (lu_pred)
|
||||||
return lu_clause(ipc->u.l.l, ap);
|
return lu_clause(ipc->u.l.l, ap);
|
||||||
else
|
else
|
||||||
return (LogUpdClause *)static_clause(ipc->u.l.l, ap, TRUE);
|
return (LogUpdClause *)static_clause(ipc->u.l.l, ap, TRUE);
|
||||||
case _retry_me:
|
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);
|
ipc = NEXTOP(ipc,Otapl);
|
||||||
break;
|
break;
|
||||||
case _trust:
|
case _trust:
|
||||||
@ -6815,11 +6830,11 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
|||||||
break;
|
break;
|
||||||
case _try_logical:
|
case _try_logical:
|
||||||
if (b0 == NULL)
|
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 {
|
else {
|
||||||
B = b0;
|
B = b0;
|
||||||
b0 = NULL;
|
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]);
|
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;
|
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;
|
return ipc->u.OtILl.d;
|
||||||
#if TABLING
|
#if TABLING
|
||||||
case _table_try_single:
|
case _table_try_single:
|
||||||
@ -7103,7 +7118,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ipc = ExpandIndex(ap, 5, cp_pc);
|
ipc = ExpandIndex(ap, 5, cp_pc PASS_REGS);
|
||||||
s_reg = (CELL *)XREGS[ap->ArityOfPE+1];
|
s_reg = (CELL *)XREGS[ap->ArityOfPE+1];
|
||||||
t = XREGS[ap->ArityOfPE+2];
|
t = XREGS[ap->ArityOfPE+2];
|
||||||
Terms[0] = XREGS[ap->ArityOfPE+3];
|
Terms[0] = XREGS[ap->ArityOfPE+3];
|
||||||
@ -7117,7 +7132,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
|||||||
break;
|
break;
|
||||||
#if THREADS
|
#if THREADS
|
||||||
case _thread_local:
|
case _thread_local:
|
||||||
ap = Yap_GetThreadPred(ap);
|
ap = Yap_GetThreadPred(ap PASS_REGS);
|
||||||
ipc = ap->CodeOfPred;
|
ipc = ap->CodeOfPred;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@ -7202,6 +7217,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
|||||||
LogUpdClause *
|
LogUpdClause *
|
||||||
Yap_NthClause(PredEntry *ap, Int ncls)
|
Yap_NthClause(PredEntry *ap, Int ncls)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
yamop
|
yamop
|
||||||
*ipc = ap->cs.p_code.TrueCodeOfPred,
|
*ipc = ap->cs.p_code.TrueCodeOfPred,
|
||||||
*alt = NULL;
|
*alt = NULL;
|
||||||
@ -7378,7 +7394,7 @@ Yap_NthClause(PredEntry *ap, Int ncls)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ipc = ExpandIndex(ap, 0, CP);
|
ipc = ExpandIndex(ap, 0, CP PASS_REGS);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case _op_fail:
|
case _op_fail:
|
||||||
|
9
C/init.c
9
C/init.c
@ -505,6 +505,7 @@ update_flags_from_prolog(UInt flags, PredEntry *pe)
|
|||||||
void
|
void
|
||||||
Yap_InitCPred(char *Name, unsigned long int Arity, CPredicate code, UInt flags)
|
Yap_InitCPred(char *Name, unsigned long int Arity, CPredicate code, UInt flags)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Atom atom = NIL;
|
Atom atom = NIL;
|
||||||
PredEntry *pe = NULL;
|
PredEntry *pe = NULL;
|
||||||
yamop *p_code;
|
yamop *p_code;
|
||||||
@ -604,6 +605,7 @@ Yap_InitCPred(char *Name, unsigned long int Arity, CPredicate code, UInt flags)
|
|||||||
void
|
void
|
||||||
Yap_InitCmpPred(char *Name, unsigned long int Arity, CmpPredicate cmp_code, UInt flags)
|
Yap_InitCmpPred(char *Name, unsigned long int Arity, CmpPredicate cmp_code, UInt flags)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Atom atom = NIL;
|
Atom atom = NIL;
|
||||||
PredEntry *pe = NULL;
|
PredEntry *pe = NULL;
|
||||||
yamop *p_code = NULL;
|
yamop *p_code = NULL;
|
||||||
@ -681,6 +683,7 @@ Yap_InitCmpPred(char *Name, unsigned long int Arity, CmpPredicate cmp_code, UInt
|
|||||||
void
|
void
|
||||||
Yap_InitAsmPred(char *Name, unsigned long int Arity, int code, CPredicate def, UInt flags)
|
Yap_InitAsmPred(char *Name, unsigned long int Arity, int code, CPredicate def, UInt flags)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Atom atom = NIL;
|
Atom atom = NIL;
|
||||||
PredEntry *pe = NULL;
|
PredEntry *pe = NULL;
|
||||||
Functor f = NULL;
|
Functor f = NULL;
|
||||||
@ -852,6 +855,7 @@ Yap_InitCPredBack(char *Name, unsigned long int Arity,
|
|||||||
CPredicate Cont, UInt flags)
|
CPredicate Cont, UInt flags)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
PredEntry *pe = NULL;
|
PredEntry *pe = NULL;
|
||||||
Atom atom = NIL;
|
Atom atom = NIL;
|
||||||
Functor f = NULL;
|
Functor f = NULL;
|
||||||
@ -1181,6 +1185,7 @@ InitThreadHandle(int wid)
|
|||||||
static void
|
static void
|
||||||
InitFirstWorkerThreadHandle(void)
|
InitFirstWorkerThreadHandle(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
ThreadHandle.id = 0;
|
ThreadHandle.id = 0;
|
||||||
ThreadHandle.in_use = TRUE;
|
ThreadHandle.in_use = TRUE;
|
||||||
@ -1204,6 +1209,7 @@ InitScratchPad(int wid)
|
|||||||
void
|
void
|
||||||
Yap_CloseScratchPad(void)
|
Yap_CloseScratchPad(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Yap_FreeCodeSpace(ScratchPad.ptr);
|
Yap_FreeCodeSpace(ScratchPad.ptr);
|
||||||
ScratchPad.sz = SCRATCH_START_SIZE;
|
ScratchPad.sz = SCRATCH_START_SIZE;
|
||||||
ScratchPad.msz = SCRATCH_START_SIZE;
|
ScratchPad.msz = SCRATCH_START_SIZE;
|
||||||
@ -1234,6 +1240,7 @@ struct worker_local Yap_WLocal;
|
|||||||
static void
|
static void
|
||||||
InitCodes(void)
|
InitCodes(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
int wid;
|
int wid;
|
||||||
#include "ihstruct.h"
|
#include "ihstruct.h"
|
||||||
InitGlobal();
|
InitGlobal();
|
||||||
@ -1274,6 +1281,7 @@ void
|
|||||||
Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_size,
|
Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_size,
|
||||||
int n_workers, int sch_loop, int delay_load)
|
int n_workers, int sch_loop, int delay_load)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* initialise system stuff */
|
/* initialise system stuff */
|
||||||
@ -1291,6 +1299,7 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
|
|||||||
#endif /* PUSH_REGS */
|
#endif /* PUSH_REGS */
|
||||||
|
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
|
Yap_regp = ((REGSTORE *)pthread_getspecific(Yap_yaamregs_key));
|
||||||
Yap_regp->worker_id_ = 0;
|
Yap_regp->worker_id_ = 0;
|
||||||
#endif
|
#endif
|
||||||
/* Init signal handling and time */
|
/* Init signal handling and time */
|
||||||
|
78
C/inlines.c
78
C/inlines.c
@ -23,25 +23,25 @@
|
|||||||
#include "cut_c.h"
|
#include "cut_c.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC_PROTO(Int p_atom, (void));
|
STATIC_PROTO(Int p_atom, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_atomic, (void));
|
STATIC_PROTO(Int p_atomic, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_integer, (void));
|
STATIC_PROTO(Int p_integer, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_nonvar, (void));
|
STATIC_PROTO(Int p_nonvar, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_number, (void));
|
STATIC_PROTO(Int p_number, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_var, (void));
|
STATIC_PROTO(Int p_var, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_db_ref, (void));
|
STATIC_PROTO(Int p_db_ref, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_primitive, (void));
|
STATIC_PROTO(Int p_primitive, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_compound, (void));
|
STATIC_PROTO(Int p_compound, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_float, (void));
|
STATIC_PROTO(Int p_float, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_equal, (void));
|
STATIC_PROTO(Int p_equal, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_dif, (void));
|
STATIC_PROTO(Int p_dif, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_eq, (void));
|
STATIC_PROTO(Int p_eq, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_arg, (void));
|
STATIC_PROTO(Int p_arg, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_functor, (void));
|
STATIC_PROTO(Int p_functor, ( USES_REGS1 ));
|
||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_atom(void)
|
p_atom( USES_REGS1 )
|
||||||
{ /* atom(?) */
|
{ /* atom(?) */
|
||||||
BEGD(d0);
|
BEGD(d0);
|
||||||
d0 = ARG1;
|
d0 = ARG1;
|
||||||
@ -62,7 +62,7 @@ p_atom(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_atomic(void)
|
p_atomic( USES_REGS1 )
|
||||||
{ /* atomic(?) */
|
{ /* atomic(?) */
|
||||||
BEGD(d0);
|
BEGD(d0);
|
||||||
d0 = ARG1;
|
d0 = ARG1;
|
||||||
@ -83,7 +83,7 @@ p_atomic(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_integer(void)
|
p_integer( USES_REGS1 )
|
||||||
{ /* integer(?,?) */
|
{ /* integer(?,?) */
|
||||||
BEGD(d0);
|
BEGD(d0);
|
||||||
d0 = ARG1;
|
d0 = ARG1;
|
||||||
@ -118,7 +118,7 @@ p_integer(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_number(void)
|
p_number( USES_REGS1 )
|
||||||
{ /* number(?) */
|
{ /* number(?) */
|
||||||
BEGD(d0);
|
BEGD(d0);
|
||||||
d0 = ARG1;
|
d0 = ARG1;
|
||||||
@ -154,7 +154,7 @@ p_number(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_db_ref(void)
|
p_db_ref( USES_REGS1 )
|
||||||
{ /* db_reference(?,?) */
|
{ /* db_reference(?,?) */
|
||||||
BEGD(d0);
|
BEGD(d0);
|
||||||
d0 = ARG1;
|
d0 = ARG1;
|
||||||
@ -175,7 +175,7 @@ p_db_ref(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_primitive(void)
|
p_primitive( USES_REGS1 )
|
||||||
{ /* primitive(?) */
|
{ /* primitive(?) */
|
||||||
BEGD(d0);
|
BEGD(d0);
|
||||||
d0 = ARG1;
|
d0 = ARG1;
|
||||||
@ -196,7 +196,7 @@ p_primitive(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_float(void)
|
p_float( USES_REGS1 )
|
||||||
{ /* float(?) */
|
{ /* float(?) */
|
||||||
BEGD(d0);
|
BEGD(d0);
|
||||||
d0 = ARG1;
|
d0 = ARG1;
|
||||||
@ -217,7 +217,7 @@ p_float(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_compound(void)
|
p_compound( USES_REGS1 )
|
||||||
{ /* compound(?) */
|
{ /* compound(?) */
|
||||||
BEGD(d0);
|
BEGD(d0);
|
||||||
d0 = ARG1;
|
d0 = ARG1;
|
||||||
@ -244,7 +244,7 @@ p_compound(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nonvar(void)
|
p_nonvar( USES_REGS1 )
|
||||||
{ /* nonvar(?) */
|
{ /* nonvar(?) */
|
||||||
BEGD(d0);
|
BEGD(d0);
|
||||||
d0 = ARG1;
|
d0 = ARG1;
|
||||||
@ -260,7 +260,7 @@ p_nonvar(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_var(void)
|
p_var( USES_REGS1 )
|
||||||
{ /* var(?) */
|
{ /* var(?) */
|
||||||
BEGD(d0);
|
BEGD(d0);
|
||||||
d0 = ARG1;
|
d0 = ARG1;
|
||||||
@ -276,13 +276,13 @@ p_var(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_equal(void)
|
p_equal( USES_REGS1 )
|
||||||
{ /* ?=? */
|
{ /* ?=? */
|
||||||
return(Yap_IUnify(ARG1, ARG2));
|
return(Yap_IUnify(ARG1, ARG2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
eq(Term t1, Term t2)
|
eq(Term t1, Term t2 USES_REGS)
|
||||||
{ /* ? == ? */
|
{ /* ? == ? */
|
||||||
BEGD(d0);
|
BEGD(d0);
|
||||||
d0 = t1;
|
d0 = t1;
|
||||||
@ -366,19 +366,20 @@ eq(Term t1, Term t2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_eq(void)
|
p_eq( USES_REGS1 )
|
||||||
{ /* ? == ? */
|
{ /* ? == ? */
|
||||||
return eq(ARG1,ARG2);
|
return eq(ARG1,ARG2 PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Yap_eq(Term t1, Term t2)
|
Yap_eq(Term t1, Term t2)
|
||||||
{ /* ? == ? */
|
{ /* ? == ? */
|
||||||
return eq(t1,t2);
|
CACHE_REGS
|
||||||
|
return eq(t1,t2 PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_dif(void)
|
p_dif( USES_REGS1 )
|
||||||
{ /* ? \= ? */
|
{ /* ? \= ? */
|
||||||
#if SHADOW_HB
|
#if SHADOW_HB
|
||||||
register CELL *HBREG = HB;
|
register CELL *HBREG = HB;
|
||||||
@ -486,7 +487,7 @@ p_dif(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_arg(void)
|
p_arg( USES_REGS1 )
|
||||||
{ /* arg(?,?,?) */
|
{ /* arg(?,?,?) */
|
||||||
#if SHADOW_HB
|
#if SHADOW_HB
|
||||||
register CELL *HBREG = HB;
|
register CELL *HBREG = HB;
|
||||||
@ -581,7 +582,7 @@ p_arg(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_functor(void) /* functor(?,?,?) */
|
p_functor( USES_REGS1 ) /* functor(?,?,?) */
|
||||||
{
|
{
|
||||||
#if SHADOW_HB
|
#if SHADOW_HB
|
||||||
register CELL *HBREG;
|
register CELL *HBREG;
|
||||||
@ -776,7 +777,7 @@ p_functor(void) /* functor(?,?,?) */
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_cut_by( void)
|
p_cut_by( USES_REGS1 )
|
||||||
{
|
{
|
||||||
BEGD(d0);
|
BEGD(d0);
|
||||||
d0 = ARG1;
|
d0 = ARG1;
|
||||||
@ -832,14 +833,14 @@ p_cut_by( void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_erroneous_call(void)
|
p_erroneous_call( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, "bad call to internal built-in");
|
Yap_Error(SYSTEM_ERROR, TermNil, "bad call to internal built-in");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
init_genarg(void)
|
init_genarg( USES_REGS1 )
|
||||||
{ /* getarg(?Atom) */
|
{ /* getarg(?Atom) */
|
||||||
Term t0 = Deref(ARG1);
|
Term t0 = Deref(ARG1);
|
||||||
Term t1 = Deref(ARG2);
|
Term t1 = Deref(ARG2);
|
||||||
@ -848,7 +849,7 @@ init_genarg(void)
|
|||||||
UInt arity;
|
UInt arity;
|
||||||
|
|
||||||
if (!IsVarTerm(t0)) {
|
if (!IsVarTerm(t0)) {
|
||||||
res = p_arg();
|
res = p_arg( PASS_REGS1 );
|
||||||
if (res) {
|
if (res) {
|
||||||
cut_succeed();
|
cut_succeed();
|
||||||
} else {
|
} else {
|
||||||
@ -889,7 +890,7 @@ init_genarg(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
cont_genarg(void)
|
cont_genarg( USES_REGS1 )
|
||||||
{ /* genarg(?Atom) */
|
{ /* genarg(?Atom) */
|
||||||
CELL *pt, *end;
|
CELL *pt, *end;
|
||||||
int res;
|
int res;
|
||||||
@ -916,6 +917,7 @@ cont_genarg(void)
|
|||||||
void
|
void
|
||||||
Yap_InitInlines(void)
|
Yap_InitInlines(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term cm = CurrentModule;
|
Term cm = CurrentModule;
|
||||||
Yap_InitAsmPred("$$cut_by", 1, _cut_by, p_cut_by, SafePredFlag);
|
Yap_InitAsmPred("$$cut_by", 1, _cut_by, p_cut_by, SafePredFlag);
|
||||||
Yap_InitAsmPred("atom", 1, _atom, p_atom, 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
|
#endif
|
||||||
#include "iopreds.h"
|
#include "iopreds.h"
|
||||||
|
|
||||||
STATIC_PROTO (Int p_set_read_error_handler, (void));
|
STATIC_PROTO (Int p_set_read_error_handler, ( USES_REGS1 ));
|
||||||
STATIC_PROTO (Int p_get_read_error_handler, (void));
|
STATIC_PROTO (Int p_get_read_error_handler, ( USES_REGS1 ));
|
||||||
STATIC_PROTO (Int p_read, (void));
|
STATIC_PROTO (Int p_read, ( USES_REGS1 ));
|
||||||
STATIC_PROTO (Int p_startline, (void));
|
STATIC_PROTO (Int p_startline, ( USES_REGS1 ));
|
||||||
STATIC_PROTO (Int p_change_type_of_char, (void));
|
STATIC_PROTO (Int p_change_type_of_char, ( USES_REGS1 ));
|
||||||
STATIC_PROTO (Int p_type_of_char, (void));
|
STATIC_PROTO (Int p_type_of_char, ( USES_REGS1 ));
|
||||||
STATIC_PROTO (Term StreamPosition, (IOSTREAM *));
|
STATIC_PROTO (Term StreamPosition, (IOSTREAM *));
|
||||||
|
|
||||||
extern Atom Yap_FileName(IOSTREAM *s);
|
extern Atom Yap_FileName(IOSTREAM *s);
|
||||||
@ -206,6 +206,7 @@ Yap_DebugPlWrite(Term t)
|
|||||||
void
|
void
|
||||||
Yap_DebugErrorPutc(int c)
|
Yap_DebugErrorPutc(int c)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Yap_DebugPutc (Yap_c_error_stream, c);
|
Yap_DebugPutc (Yap_c_error_stream, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +216,7 @@ Yap_DebugErrorPutc(int c)
|
|||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_has_readline(void)
|
p_has_readline( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#if HAVE_LIBREADLINE && HAVE_READLINE_READLINE_H
|
#if HAVE_LIBREADLINE && HAVE_READLINE_READLINE_H
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -273,6 +274,7 @@ clean_vars(VarEntry *p)
|
|||||||
static Term
|
static Term
|
||||||
syntax_error (TokEntry * tokptr, IOSTREAM *st, Term *outp)
|
syntax_error (TokEntry * tokptr, IOSTREAM *st, Term *outp)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term info;
|
Term info;
|
||||||
int count = 0, out = 0;
|
int count = 0, out = 0;
|
||||||
Int start, err = 0, end;
|
Int start, err = 0, end;
|
||||||
@ -388,7 +390,7 @@ syntax_error (TokEntry * tokptr, IOSTREAM *st, Term *outp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
GenerateSyntaxError(Term *tp, TokEntry *tokstart, IOSTREAM *sno)
|
GenerateSyntaxError(Term *tp, TokEntry *tokstart, IOSTREAM *sno USES_REGS)
|
||||||
{
|
{
|
||||||
if (tp) {
|
if (tp) {
|
||||||
Term et[2];
|
Term et[2];
|
||||||
@ -402,6 +404,7 @@ GenerateSyntaxError(Term *tp, TokEntry *tokstart, IOSTREAM *sno)
|
|||||||
Term
|
Term
|
||||||
Yap_StringToTerm(char *s,Term *tp)
|
Yap_StringToTerm(char *s,Term *tp)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
IOSTREAM *sno = Sopenmem(&s, NULL, "r");
|
IOSTREAM *sno = Sopenmem(&s, NULL, "r");
|
||||||
Term t;
|
Term t;
|
||||||
TokEntry *tokstart;
|
TokEntry *tokstart;
|
||||||
@ -430,7 +433,7 @@ Yap_StringToTerm(char *s,Term *tp)
|
|||||||
t = Yap_Parse();
|
t = Yap_Parse();
|
||||||
TR = TR_before_parse;
|
TR = TR_before_parse;
|
||||||
if (!t || Yap_ErrorMessage) {
|
if (!t || Yap_ErrorMessage) {
|
||||||
GenerateSyntaxError(tp, tokstart, sno);
|
GenerateSyntaxError(tp, tokstart, sno PASS_REGS);
|
||||||
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
|
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
|
||||||
Sclose(sno);
|
Sclose(sno);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -444,18 +447,19 @@ Yap_StringToTerm(char *s,Term *tp)
|
|||||||
Int
|
Int
|
||||||
Yap_FirstLineInParse (void)
|
Yap_FirstLineInParse (void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
return StartLine;
|
return StartLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_startline (void)
|
p_startline ( USES_REGS1 )
|
||||||
{
|
{
|
||||||
return (Yap_unify_constant (ARG1, MkIntegerTerm (StartLine)));
|
return (Yap_unify_constant (ARG1, MkIntegerTerm (StartLine)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* control the parser error handler */
|
/* control the parser error handler */
|
||||||
static Int
|
static Int
|
||||||
p_set_read_error_handler(void)
|
p_set_read_error_handler( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
char *s;
|
char *s;
|
||||||
@ -485,7 +489,7 @@ p_set_read_error_handler(void)
|
|||||||
|
|
||||||
/* return the status for the parser error handler */
|
/* return the status for the parser error handler */
|
||||||
static Int
|
static Int
|
||||||
p_get_read_error_handler(void)
|
p_get_read_error_handler( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t;
|
Term t;
|
||||||
|
|
||||||
@ -512,6 +516,7 @@ p_get_read_error_handler(void)
|
|||||||
int
|
int
|
||||||
Yap_readTerm(void *st0, Term *tp, Term *varnames, Term *terror, Term *tpos)
|
Yap_readTerm(void *st0, Term *tp, Term *varnames, Term *terror, Term *tpos)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
TokEntry *tokstart;
|
TokEntry *tokstart;
|
||||||
Term pt;
|
Term pt;
|
||||||
IOSTREAM *st = (IOSTREAM *)st0;
|
IOSTREAM *st = (IOSTREAM *)st0;
|
||||||
@ -530,7 +535,7 @@ Yap_readTerm(void *st0, Term *tp, Term *varnames, Term *terror, Term *tpos)
|
|||||||
}
|
}
|
||||||
pt = Yap_Parse();
|
pt = Yap_Parse();
|
||||||
if (Yap_ErrorMessage || pt == (CELL)0) {
|
if (Yap_ErrorMessage || pt == (CELL)0) {
|
||||||
GenerateSyntaxError(terror, tokstart, st);
|
GenerateSyntaxError(terror, tokstart, st PASS_REGS);
|
||||||
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
|
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -557,7 +562,7 @@ Yap_readTerm(void *st0, Term *tp, Term *varnames, Term *terror, Term *tpos)
|
|||||||
Err: ARG6
|
Err: ARG6
|
||||||
*/
|
*/
|
||||||
static Int
|
static Int
|
||||||
do_read(IOSTREAM *inp_stream, int nargs)
|
do_read(IOSTREAM *inp_stream, int nargs USES_REGS)
|
||||||
{
|
{
|
||||||
Term t, v;
|
Term t, v;
|
||||||
TokEntry *tokstart;
|
TokEntry *tokstart;
|
||||||
@ -746,23 +751,23 @@ static Int
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_read (void)
|
p_read ( USES_REGS1 )
|
||||||
{ /* '$read'(+Flag,?Term,?Module,?Vars,-Pos,-Err) */
|
{ /* '$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 **);
|
extern int Yap_getInputStream(Int, IOSTREAM **);
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_read2 (void)
|
p_read2 ( USES_REGS1 )
|
||||||
{ /* '$read2'(+Flag,?Term,?Module,?Vars,-Pos,-Err,+Stream) */
|
{ /* '$read2'(+Flag,?Term,?Module,?Vars,-Pos,-Err,+Stream) */
|
||||||
IOSTREAM *inp_stream;
|
IOSTREAM *inp_stream;
|
||||||
Int out;
|
Int out;
|
||||||
|
|
||||||
if (!Yap_getInputStream(Yap_InitSlot(Deref(ARG7)), &inp_stream)) {
|
if (!Yap_getInputStream(Yap_InitSlot(Deref(ARG7) PASS_REGS), &inp_stream)) {
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
out = do_read(inp_stream, 7);
|
out = do_read(inp_stream, 7 PASS_REGS);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -787,7 +792,7 @@ Yap_StreamPosition(IOSTREAM *st)
|
|||||||
#if HAVE_SELECT && FALSE
|
#if HAVE_SELECT && FALSE
|
||||||
/* stream_select(+Streams,+TimeOut,-Result) */
|
/* stream_select(+Streams,+TimeOut,-Result) */
|
||||||
static Int
|
static Int
|
||||||
p_stream_select(void)
|
p_stream_select( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1 = Deref(ARG1), t2;
|
Term t1 = Deref(ARG1), t2;
|
||||||
fd_set readfds, writefds, exceptfds;
|
fd_set readfds, writefds, exceptfds;
|
||||||
@ -912,7 +917,7 @@ p_stream_select(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_change_type_of_char (void)
|
p_change_type_of_char ( USES_REGS1 )
|
||||||
{ /* change_type_of_char(+char,+type) */
|
{ /* change_type_of_char(+char,+type) */
|
||||||
Term t1 = Deref (ARG1);
|
Term t1 = Deref (ARG1);
|
||||||
Term t2 = Deref (ARG2);
|
Term t2 = Deref (ARG2);
|
||||||
@ -925,7 +930,7 @@ p_change_type_of_char (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_type_of_char (void)
|
p_type_of_char ( USES_REGS1 )
|
||||||
{ /* type_of_char(+char,-type) */
|
{ /* type_of_char(+char,-type) */
|
||||||
Term t;
|
Term t;
|
||||||
|
|
||||||
@ -938,7 +943,7 @@ p_type_of_char (void)
|
|||||||
|
|
||||||
|
|
||||||
static Int
|
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 */
|
/* don't actually enable it until someone tries to add a conversion */
|
||||||
if (CharConversionTable2 == NULL)
|
if (CharConversionTable2 == NULL)
|
||||||
@ -948,7 +953,7 @@ p_force_char_conversion(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_disable_char_conversion(void)
|
p_disable_char_conversion( USES_REGS1 )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -961,7 +966,7 @@ p_disable_char_conversion(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_char_conversion(void)
|
p_char_conversion( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t0 = Deref(ARG1), t1 = Deref(ARG2);
|
Term t0 = Deref(ARG1), t1 = Deref(ARG2);
|
||||||
char *s0, *s1;
|
char *s0, *s1;
|
||||||
@ -1007,7 +1012,7 @@ p_char_conversion(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (yap_flags[CHAR_CONVERSION_FLAG] != 0) {
|
if (yap_flags[CHAR_CONVERSION_FLAG] != 0) {
|
||||||
if (p_force_char_conversion() == FALSE)
|
if (p_force_char_conversion( PASS_REGS1 ) == FALSE)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
for (i = 0; i < NUMBER_OF_CHARS; i++)
|
for (i = 0; i < NUMBER_OF_CHARS; i++)
|
||||||
@ -1020,7 +1025,7 @@ p_char_conversion(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_current_char_conversion(void)
|
p_current_char_conversion( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t0, t1;
|
Term t0, t1;
|
||||||
char *s0, *s1;
|
char *s0, *s1;
|
||||||
@ -1065,7 +1070,7 @@ p_current_char_conversion(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_all_char_conversions(void)
|
p_all_char_conversions( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term out = TermNil;
|
Term out = TermNil;
|
||||||
int i;
|
int i;
|
||||||
@ -1091,7 +1096,7 @@ p_all_char_conversions(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_float_format(void)
|
p_float_format( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term in = Deref(ARG1);
|
Term in = Deref(ARG1);
|
||||||
if (IsVarTerm(in))
|
if (IsVarTerm(in))
|
||||||
@ -1105,18 +1110,18 @@ extern void Yap_SetDefaultEncoding(IOENC);
|
|||||||
extern int PL_get_stream_handle(Int, IOSTREAM **);
|
extern int PL_get_stream_handle(Int, IOSTREAM **);
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_get_default_encoding(void)
|
p_get_default_encoding( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term out = MkIntegerTerm(Yap_DefaultEncoding());
|
Term out = MkIntegerTerm(Yap_DefaultEncoding());
|
||||||
return Yap_unify(ARG1, out);
|
return Yap_unify(ARG1, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_encoding (void)
|
p_encoding ( USES_REGS1 )
|
||||||
{ /* '$encoding'(Stream,N) */
|
{ /* '$encoding'(Stream,N) */
|
||||||
IOSTREAM *st;
|
IOSTREAM *st;
|
||||||
Term t = Deref(ARG2);
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
|
@ -53,6 +53,7 @@ Yap_LoadForeignFile(char *file, int flags)
|
|||||||
|
|
||||||
out = (void *)dlopen(file,dlflag);
|
out = (void *)dlopen(file,dlflag);
|
||||||
if (!out) {
|
if (!out) {
|
||||||
|
CACHE_REGS
|
||||||
Yap_Error(SYSTEM_ERROR, ARG1, "dlopen error %s\n", dlerror());
|
Yap_Error(SYSTEM_ERROR, ARG1, "dlopen error %s\n", dlerror());
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
@ -74,6 +75,7 @@ int
|
|||||||
Yap_CloseForeignFile(void *handle)
|
Yap_CloseForeignFile(void *handle)
|
||||||
{
|
{
|
||||||
if ( dlclose(handle) < 0) {
|
if ( dlclose(handle) < 0) {
|
||||||
|
CACHE_REGS
|
||||||
Yap_Error(SYSTEM_ERROR, ARG1, "dlclose error %s\n", dlerror());
|
Yap_Error(SYSTEM_ERROR, ARG1, "dlclose error %s\n", dlerror());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -89,9 +91,9 @@ static Int
|
|||||||
LoadForeign(StringList ofiles, StringList libs,
|
LoadForeign(StringList ofiles, StringList libs,
|
||||||
char *proc_name, YapInitProc *init_proc)
|
char *proc_name, YapInitProc *init_proc)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
|
|
||||||
while (libs) {
|
while (libs) {
|
||||||
|
|
||||||
if (!Yap_TrueFileName(AtomName(libs->name), Yap_FileNameBuf, TRUE)) {
|
if (!Yap_TrueFileName(AtomName(libs->name), Yap_FileNameBuf, TRUE)) {
|
||||||
/* use LD_LIBRARY_PATH */
|
/* use LD_LIBRARY_PATH */
|
||||||
strncpy(Yap_FileNameBuf, AtomName(libs->name), YAP_FILENAME_MAX);
|
strncpy(Yap_FileNameBuf, AtomName(libs->name), YAP_FILENAME_MAX);
|
||||||
|
@ -34,10 +34,10 @@ static char SccsId[] = "%W% %G%.2";
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STD_PROTO(Int p_load_foreign, (void));
|
STD_PROTO(Int p_load_foreign, ( USES_REGS1 ));
|
||||||
|
|
||||||
Int
|
Int
|
||||||
p_load_foreign(void)
|
p_load_foreign( USES_REGS1 )
|
||||||
{
|
{
|
||||||
StringList ofiles = NULL;
|
StringList ofiles = NULL;
|
||||||
StringList libs = NULL;
|
StringList libs = NULL;
|
||||||
@ -110,7 +110,7 @@ p_load_foreign(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_open_shared_object(void) {
|
p_open_shared_object( USES_REGS1 ) {
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Term tflags = Deref(ARG2);
|
Term tflags = Deref(ARG2);
|
||||||
char *s;
|
char *s;
|
||||||
@ -143,7 +143,7 @@ p_open_shared_object(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_close_shared_object(void) {
|
p_close_shared_object( USES_REGS1 ) {
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
void *handle;
|
void *handle;
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ p_close_shared_object(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_call_shared_object_function(void) {
|
p_call_shared_object_function( USES_REGS1 ) {
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Term tfunc = Deref(ARG2);
|
Term tfunc = Deref(ARG2);
|
||||||
Term tmod;
|
Term tmod;
|
||||||
@ -209,12 +209,12 @@ p_call_shared_object_function(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_obj_suffix(void) {
|
p_obj_suffix( USES_REGS1 ) {
|
||||||
return Yap_unify(Yap_StringToList(YAP_SHLIB_SUFFIX),ARG1);
|
return Yap_unify(Yap_StringToList(YAP_SHLIB_SUFFIX),ARG1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_open_shared_objects(void) {
|
p_open_shared_objects( USES_REGS1 ) {
|
||||||
#ifdef YAP_SHLIB_SUFFIX
|
#ifdef YAP_SHLIB_SUFFIX
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#else
|
#else
|
||||||
@ -223,7 +223,7 @@ p_open_shared_objects(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Yap_InitLoadForeign(void)
|
Yap_InitLoadForeign( void )
|
||||||
{
|
{
|
||||||
if (Yap_argv == NULL)
|
if (Yap_argv == NULL)
|
||||||
Yap_FindExecutable("yap");
|
Yap_FindExecutable("yap");
|
||||||
@ -240,6 +240,7 @@ Yap_InitLoadForeign(void)
|
|||||||
void
|
void
|
||||||
Yap_ReOpenLoadForeign(void)
|
Yap_ReOpenLoadForeign(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
ForeignObj *f_code = ForeignCodeLoaded;
|
ForeignObj *f_code = ForeignCodeLoaded;
|
||||||
Term OldModule = CurrentModule;
|
Term OldModule = CurrentModule;
|
||||||
|
|
||||||
|
37
C/mavar.c
37
C/mavar.c
@ -23,14 +23,14 @@
|
|||||||
#include "YapHeap.h"
|
#include "YapHeap.h"
|
||||||
#include "eval.h"
|
#include "eval.h"
|
||||||
|
|
||||||
STD_PROTO(static Int p_setarg, (void));
|
STD_PROTO(static Int p_setarg, ( USES_REGS1 ));
|
||||||
STD_PROTO(static Int p_create_mutable, (void));
|
STD_PROTO(static Int p_create_mutable, ( USES_REGS1 ));
|
||||||
STD_PROTO(static Int p_get_mutable, (void));
|
STD_PROTO(static Int p_get_mutable, ( USES_REGS1 ));
|
||||||
STD_PROTO(static Int p_update_mutable, (void));
|
STD_PROTO(static Int p_update_mutable, ( USES_REGS1 ));
|
||||||
STD_PROTO(static Int p_is_mutable, (void));
|
STD_PROTO(static Int p_is_mutable, ( USES_REGS1 ));
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_setarg(void)
|
p_setarg( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL ti = Deref(ARG1), ts = Deref(ARG2), t3 = Deref(ARG3);
|
CELL ti = Deref(ARG1), ts = Deref(ARG2), t3 = Deref(ARG3);
|
||||||
Int i;
|
Int i;
|
||||||
@ -119,7 +119,7 @@ p_setarg(void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
NewTimedVar(CELL val)
|
NewTimedVar(CELL val USES_REGS)
|
||||||
{
|
{
|
||||||
Term out;
|
Term out;
|
||||||
timed_var *tv;
|
timed_var *tv;
|
||||||
@ -141,12 +141,14 @@ NewTimedVar(CELL val)
|
|||||||
Term
|
Term
|
||||||
Yap_NewTimedVar(CELL val)
|
Yap_NewTimedVar(CELL val)
|
||||||
{
|
{
|
||||||
return NewTimedVar(val);
|
CACHE_REGS
|
||||||
|
return NewTimedVar(val PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
Term
|
Term
|
||||||
Yap_NewEmptyTimedVar(void)
|
Yap_NewEmptyTimedVar( void )
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term out = AbsAppl(H);
|
Term out = AbsAppl(H);
|
||||||
timed_var *tv;
|
timed_var *tv;
|
||||||
*H++ = (CELL)FunctorMutable;
|
*H++ = (CELL)FunctorMutable;
|
||||||
@ -173,7 +175,7 @@ Yap_ReadTimedVar(Term inv)
|
|||||||
|
|
||||||
/* update a timed var with a new value */
|
/* update a timed var with a new value */
|
||||||
static Term
|
static Term
|
||||||
UpdateTimedVar(Term inv, Term new)
|
UpdateTimedVar(Term inv, Term new USES_REGS)
|
||||||
{
|
{
|
||||||
timed_var *tv = (timed_var *)(RepAppl(inv)+1);
|
timed_var *tv = (timed_var *)(RepAppl(inv)+1);
|
||||||
CELL t = tv->value;
|
CELL t = tv->value;
|
||||||
@ -210,18 +212,19 @@ UpdateTimedVar(Term inv, Term new)
|
|||||||
Term
|
Term
|
||||||
Yap_UpdateTimedVar(Term inv, Term new)
|
Yap_UpdateTimedVar(Term inv, Term new)
|
||||||
{
|
{
|
||||||
return UpdateTimedVar(inv, new);
|
CACHE_REGS
|
||||||
|
return UpdateTimedVar(inv, new PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
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));
|
return(Yap_unify(ARG2,t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_get_mutable(void)
|
p_get_mutable( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG2);
|
Term t = Deref(ARG2);
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
@ -241,7 +244,7 @@ p_get_mutable(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_update_mutable(void)
|
p_update_mutable( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG2);
|
Term t = Deref(ARG2);
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
@ -256,12 +259,12 @@ p_update_mutable(void)
|
|||||||
Yap_Error(DOMAIN_ERROR_MUTABLE,t,"update_mutable/3");
|
Yap_Error(DOMAIN_ERROR_MUTABLE,t,"update_mutable/3");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
UpdateTimedVar(t, Deref(ARG1));
|
UpdateTimedVar(t, Deref(ARG1) PASS_REGS);
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_is_mutable(void)
|
p_is_mutable( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
|
23
C/modules.c
23
C/modules.c
@ -22,8 +22,8 @@ static char SccsId[] = "%W% %G%";
|
|||||||
#include "Yatom.h"
|
#include "Yatom.h"
|
||||||
#include "YapHeap.h"
|
#include "YapHeap.h"
|
||||||
|
|
||||||
STATIC_PROTO(Int p_current_module, (void));
|
STATIC_PROTO(Int p_current_module, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_current_module1, (void));
|
STATIC_PROTO(Int p_current_module1, ( USES_REGS1 ));
|
||||||
|
|
||||||
|
|
||||||
inline static ModEntry *
|
inline static ModEntry *
|
||||||
@ -82,6 +82,7 @@ GetModuleEntry(Atom at)
|
|||||||
Term
|
Term
|
||||||
Yap_Module_Name(PredEntry *ap)
|
Yap_Module_Name(PredEntry *ap)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term mod;
|
Term mod;
|
||||||
if (!ap->ModuleOfPred)
|
if (!ap->ModuleOfPred)
|
||||||
/* If the system predicate is a metacall I should return the
|
/* 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
|
static Int
|
||||||
p_current_module(void)
|
p_current_module( USES_REGS1 )
|
||||||
{ /* $current_module(Old,New) */
|
{ /* $current_module(Old,New) */
|
||||||
Term t;
|
Term t;
|
||||||
|
|
||||||
@ -167,7 +168,7 @@ p_current_module(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_current_module1(void)
|
p_current_module1( USES_REGS1 )
|
||||||
{ /* $current_module(Old) */
|
{ /* $current_module(Old) */
|
||||||
if (CurrentModule)
|
if (CurrentModule)
|
||||||
return Yap_unify_constant(ARG1, CurrentModule);
|
return Yap_unify_constant(ARG1, CurrentModule);
|
||||||
@ -175,7 +176,7 @@ p_current_module1(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_change_module(void)
|
p_change_module( USES_REGS1 )
|
||||||
{ /* $change_module(New) */
|
{ /* $change_module(New) */
|
||||||
Term mod = Deref(ARG1);
|
Term mod = Deref(ARG1);
|
||||||
LookupModule(mod);
|
LookupModule(mod);
|
||||||
@ -184,7 +185,7 @@ p_change_module(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
cont_current_module(void)
|
cont_current_module( USES_REGS1 )
|
||||||
{
|
{
|
||||||
ModEntry *imod = (ModEntry *)IntegerOfTerm(EXTRA_CBACK_ARG(1,1)), *next;
|
ModEntry *imod = (ModEntry *)IntegerOfTerm(EXTRA_CBACK_ARG(1,1)), *next;
|
||||||
Term t = MkAtomTerm(imod->AtomOfME);
|
Term t = MkAtomTerm(imod->AtomOfME);
|
||||||
@ -199,7 +200,7 @@ cont_current_module(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
init_current_module(void)
|
init_current_module( USES_REGS1 )
|
||||||
{ /* current_module(?ModuleName) */
|
{ /* current_module(?ModuleName) */
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
if (!IsVarTerm(t)) {
|
if (!IsVarTerm(t)) {
|
||||||
@ -212,11 +213,11 @@ init_current_module(void)
|
|||||||
cut_fail();
|
cut_fail();
|
||||||
}
|
}
|
||||||
EXTRA_CBACK_ARG(1,1) = MkIntegerTerm((Int)CurrentModules);
|
EXTRA_CBACK_ARG(1,1) = MkIntegerTerm((Int)CurrentModules);
|
||||||
return cont_current_module();
|
return cont_current_module( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_strip_module(void)
|
p_strip_module( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1 = Deref(ARG1), t2, tmod = CurrentModule;
|
Term t1 = Deref(ARG1), t2, tmod = CurrentModule;
|
||||||
if (tmod == PROLOG_MODULE) {
|
if (tmod == PROLOG_MODULE) {
|
||||||
@ -243,7 +244,7 @@ p_strip_module(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_context_module(void)
|
p_context_module( USES_REGS1 )
|
||||||
{
|
{
|
||||||
yamop *parentcp = P;
|
yamop *parentcp = P;
|
||||||
CELL *yenv;
|
CELL *yenv;
|
||||||
@ -267,6 +268,7 @@ p_context_module(void)
|
|||||||
Term
|
Term
|
||||||
Yap_StripModule(Term t, Term *modp)
|
Yap_StripModule(Term t, Term *modp)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term tmod;
|
Term tmod;
|
||||||
|
|
||||||
tmod = CurrentModule;
|
tmod = CurrentModule;
|
||||||
@ -313,6 +315,7 @@ Yap_InitModulesC(void)
|
|||||||
void
|
void
|
||||||
Yap_InitModules(void)
|
Yap_InitModules(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
LookupModule(MkAtomTerm(AtomProlog));
|
LookupModule(MkAtomTerm(AtomProlog));
|
||||||
LookupModule(USER_MODULE);
|
LookupModule(USER_MODULE);
|
||||||
LookupModule(IDB_MODULE);
|
LookupModule(IDB_MODULE);
|
||||||
|
@ -51,6 +51,7 @@ REGSTORE Yap_REGS;
|
|||||||
Term
|
Term
|
||||||
Yap_MkNewPairTerm(void)
|
Yap_MkNewPairTerm(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
register CELL *p = H;
|
register CELL *p = H;
|
||||||
|
|
||||||
RESET_VARIABLE(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
|
/* build compound term with functor f and n
|
||||||
* args a */
|
* args a */
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
CELL *t = H;
|
CELL *t = H;
|
||||||
|
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return (MkAtomTerm(NameOfFunctor(f)));
|
return (MkAtomTerm(NameOfFunctor(f)));
|
||||||
if (f == FunctorList)
|
if (f == FunctorList)
|
||||||
return (MkPairTerm(a[0], a[1]));
|
return MkPairTerm(a[0], a[1]);
|
||||||
*H++ = (CELL) f;
|
*H++ = (CELL) f;
|
||||||
while (n--)
|
while (n--)
|
||||||
*H++ = (CELL) * a++;
|
*H++ = (CELL) * a++;
|
||||||
@ -81,6 +83,7 @@ Yap_MkNewApplTerm(Functor f, unsigned int n)
|
|||||||
/* build compound term with functor f and n
|
/* build compound term with functor f and n
|
||||||
* args a */
|
* args a */
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
CELL *t = H;
|
CELL *t = H;
|
||||||
|
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
@ -103,6 +106,7 @@ Yap_MkNewApplTerm(Functor f, unsigned int n)
|
|||||||
Term
|
Term
|
||||||
Yap_Globalise(Term t)
|
Yap_Globalise(Term t)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
CELL *vt;
|
CELL *vt;
|
||||||
Term tn;
|
Term tn;
|
||||||
|
|
||||||
|
94
C/parser.c
94
C/parser.c
@ -68,11 +68,11 @@ typedef struct jmp_buff_struct {
|
|||||||
sigjmp_buf JmpBuff;
|
sigjmp_buf JmpBuff;
|
||||||
} JMPBUFF;
|
} JMPBUFF;
|
||||||
|
|
||||||
STATIC_PROTO(void GNextToken, (void));
|
STATIC_PROTO(void GNextToken, ( CACHE_TYPE1 ));
|
||||||
STATIC_PROTO(void checkfor, (Term, JMPBUFF *));
|
STATIC_PROTO(void checkfor, (Term, JMPBUFF * CACHE_TYPE));
|
||||||
STATIC_PROTO(Term ParseArgs, (Atom, JMPBUFF *));
|
STATIC_PROTO(Term ParseArgs, (Atom, JMPBUFF * CACHE_TYPE));
|
||||||
STATIC_PROTO(Term ParseList, (JMPBUFF *));
|
STATIC_PROTO(Term ParseList, (JMPBUFF * CACHE_TYPE));
|
||||||
STATIC_PROTO(Term ParseTerm, (int, JMPBUFF *));
|
STATIC_PROTO(Term ParseTerm, (int, JMPBUFF * CACHE_TYPE));
|
||||||
|
|
||||||
|
|
||||||
#define TRY(S,P) \
|
#define TRY(S,P) \
|
||||||
@ -118,6 +118,7 @@ STATIC_PROTO(Term ParseTerm, (int, JMPBUFF *));
|
|||||||
VarEntry *
|
VarEntry *
|
||||||
Yap_LookupVar(char *var) /* lookup variable in variables table */
|
Yap_LookupVar(char *var) /* lookup variable in variables table */
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
VarEntry *p;
|
VarEntry *p;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -172,20 +173,20 @@ Yap_LookupVar(char *var) /* lookup variable in variables table */
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
VarNames(VarEntry *p,Term l)
|
VarNames(VarEntry *p,Term l USES_REGS)
|
||||||
{
|
{
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
if (strcmp(p->VarRep, "_") != 0) {
|
if (strcmp(p->VarRep, "_") != 0) {
|
||||||
Term o = MkPairTerm(MkPairTerm(Yap_StringToList(p->VarRep), p->VarAdr),
|
Term o = MkPairTerm(MkPairTerm(Yap_StringToList(p->VarRep), p->VarAdr),
|
||||||
VarNames(p->VarRight,
|
VarNames(p->VarRight,
|
||||||
VarNames(p->VarLeft,l)));
|
VarNames(p->VarLeft,l PASS_REGS) PASS_REGS));
|
||||||
if (H > ASP-4096) {
|
if (H > ASP-4096) {
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
siglongjmp(Yap_IOBotch,1);
|
siglongjmp(Yap_IOBotch,1);
|
||||||
}
|
}
|
||||||
return(o);
|
return(o);
|
||||||
} else {
|
} else {
|
||||||
return(VarNames(p->VarRight,VarNames(p->VarLeft,l)));
|
return VarNames(p->VarRight,VarNames(p->VarLeft,l PASS_REGS) PASS_REGS);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return (l);
|
return (l);
|
||||||
@ -195,15 +196,16 @@ VarNames(VarEntry *p,Term l)
|
|||||||
Term
|
Term
|
||||||
Yap_VarNames(VarEntry *p,Term l)
|
Yap_VarNames(VarEntry *p,Term l)
|
||||||
{
|
{
|
||||||
return VarNames(p,l);
|
CACHE_REGS
|
||||||
|
return VarNames(p,l PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
IsPrefixOp(Atom op,int *pptr, int *rpptr)
|
IsPrefixOp(Atom op,int *pptr, int *rpptr USES_REGS)
|
||||||
{
|
{
|
||||||
int p;
|
int p;
|
||||||
|
|
||||||
OpEntry *opp = Yap_GetOpProp(op, PREFIX_OP);
|
OpEntry *opp = Yap_GetOpProp(op, PREFIX_OP PASS_REGS);
|
||||||
if (!opp)
|
if (!opp)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (opp->OpModule &&
|
if (opp->OpModule &&
|
||||||
@ -224,15 +226,16 @@ IsPrefixOp(Atom op,int *pptr, int *rpptr)
|
|||||||
int
|
int
|
||||||
Yap_IsPrefixOp(Atom op,int *pptr, int *rpptr)
|
Yap_IsPrefixOp(Atom op,int *pptr, int *rpptr)
|
||||||
{
|
{
|
||||||
return IsPrefixOp(op,pptr,rpptr);
|
CACHE_REGS
|
||||||
|
return IsPrefixOp(op,pptr,rpptr PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr)
|
IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr USES_REGS)
|
||||||
{
|
{
|
||||||
int p;
|
int p;
|
||||||
|
|
||||||
OpEntry *opp = Yap_GetOpProp(op, INFIX_OP);
|
OpEntry *opp = Yap_GetOpProp(op, INFIX_OP PASS_REGS);
|
||||||
if (!opp)
|
if (!opp)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (opp->OpModule &&
|
if (opp->OpModule &&
|
||||||
@ -255,15 +258,16 @@ IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr)
|
|||||||
int
|
int
|
||||||
Yap_IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr)
|
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
|
static int
|
||||||
IsPosfixOp(Atom op, int *pptr, int *lpptr)
|
IsPosfixOp(Atom op, int *pptr, int *lpptr USES_REGS)
|
||||||
{
|
{
|
||||||
int p;
|
int p;
|
||||||
|
|
||||||
OpEntry *opp = Yap_GetOpProp(op, INFIX_OP);
|
OpEntry *opp = Yap_GetOpProp(op, INFIX_OP PASS_REGS);
|
||||||
if (!opp)
|
if (!opp)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (opp->OpModule &&
|
if (opp->OpModule &&
|
||||||
@ -284,11 +288,12 @@ IsPosfixOp(Atom op, int *pptr, int *lpptr)
|
|||||||
int
|
int
|
||||||
Yap_IsPosfixOp(Atom op, int *pptr, int *lpptr)
|
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
|
inline static void
|
||||||
GNextToken(void)
|
GNextToken( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (Yap_tokptr->Tok == Ord(eot_tok))
|
if (Yap_tokptr->Tok == Ord(eot_tok))
|
||||||
return;
|
return;
|
||||||
@ -304,7 +309,7 @@ GNextToken(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline static void
|
inline static void
|
||||||
checkfor(Term c, JMPBUFF *FailBuff)
|
checkfor(Term c, JMPBUFF *FailBuff USES_REGS)
|
||||||
{
|
{
|
||||||
if (Yap_tokptr->Tok != Ord(Ponctuation_tok)
|
if (Yap_tokptr->Tok != Ord(Ponctuation_tok)
|
||||||
|| Yap_tokptr->TokInfo != c)
|
|| Yap_tokptr->TokInfo != c)
|
||||||
@ -313,7 +318,7 @@ checkfor(Term c, JMPBUFF *FailBuff)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
ParseArgs(Atom a, JMPBUFF *FailBuff)
|
ParseArgs(Atom a, JMPBUFF *FailBuff USES_REGS)
|
||||||
{
|
{
|
||||||
int nargs = 0;
|
int nargs = 0;
|
||||||
Term *p, t;
|
Term *p, t;
|
||||||
@ -330,7 +335,7 @@ ParseArgs(Atom a, JMPBUFF *FailBuff)
|
|||||||
Yap_ErrorMessage = "Trail Overflow";
|
Yap_ErrorMessage = "Trail Overflow";
|
||||||
FAIL;
|
FAIL;
|
||||||
}
|
}
|
||||||
*tp++ = Unsigned(ParseTerm(999, FailBuff));
|
*tp++ = Unsigned(ParseTerm(999, FailBuff PASS_REGS));
|
||||||
ParserAuxSp = (char *)tp;
|
ParserAuxSp = (char *)tp;
|
||||||
++nargs;
|
++nargs;
|
||||||
if (Yap_tokptr->Tok != Ord(Ponctuation_tok))
|
if (Yap_tokptr->Tok != Ord(Ponctuation_tok))
|
||||||
@ -369,13 +374,13 @@ ParseArgs(Atom a, JMPBUFF *FailBuff)
|
|||||||
return TermNil;
|
return TermNil;
|
||||||
}
|
}
|
||||||
/* check for possible overflow against local stack */
|
/* check for possible overflow against local stack */
|
||||||
checkfor((Term) ')', FailBuff);
|
checkfor((Term) ')', FailBuff PASS_REGS);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
ParseList(JMPBUFF *FailBuff)
|
ParseList(JMPBUFF *FailBuff USES_REGS)
|
||||||
{
|
{
|
||||||
Term o;
|
Term o;
|
||||||
CELL *to_store;
|
CELL *to_store;
|
||||||
@ -383,14 +388,14 @@ ParseList(JMPBUFF *FailBuff)
|
|||||||
loop:
|
loop:
|
||||||
to_store = H;
|
to_store = H;
|
||||||
H+=2;
|
H+=2;
|
||||||
to_store[0] = ParseTerm(999, FailBuff);
|
to_store[0] = ParseTerm(999, FailBuff PASS_REGS);
|
||||||
if (Yap_tokptr->Tok == Ord(Ponctuation_tok)) {
|
if (Yap_tokptr->Tok == Ord(Ponctuation_tok)) {
|
||||||
if (((int) Yap_tokptr->TokInfo) == ',') {
|
if (((int) Yap_tokptr->TokInfo) == ',') {
|
||||||
NextToken;
|
NextToken;
|
||||||
if (Yap_tokptr->Tok == Ord(Name_tok)
|
if (Yap_tokptr->Tok == Ord(Name_tok)
|
||||||
&& strcmp(RepAtom((Atom)(Yap_tokptr->TokInfo))->StrOfAE, "..") == 0) {
|
&& strcmp(RepAtom((Atom)(Yap_tokptr->TokInfo))->StrOfAE, "..") == 0) {
|
||||||
NextToken;
|
NextToken;
|
||||||
to_store[1] = ParseTerm(999, FailBuff);
|
to_store[1] = ParseTerm(999, FailBuff PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
/* check for possible overflow against local stack */
|
/* check for possible overflow against local stack */
|
||||||
if (H > ASP-4096) {
|
if (H > ASP-4096) {
|
||||||
@ -404,7 +409,7 @@ ParseList(JMPBUFF *FailBuff)
|
|||||||
}
|
}
|
||||||
} else if (((int) Yap_tokptr->TokInfo) == '|') {
|
} else if (((int) Yap_tokptr->TokInfo) == '|') {
|
||||||
NextToken;
|
NextToken;
|
||||||
to_store[1] = ParseTerm(999, FailBuff);
|
to_store[1] = ParseTerm(999, FailBuff PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
to_store[1] = MkAtomTerm(AtomNil);
|
to_store[1] = MkAtomTerm(AtomNil);
|
||||||
}
|
}
|
||||||
@ -422,7 +427,7 @@ ParseList(JMPBUFF *FailBuff)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
ParseTerm(int prio, JMPBUFF *FailBuff)
|
ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
|
||||||
{
|
{
|
||||||
/* parse term with priority prio */
|
/* parse term with priority prio */
|
||||||
Volatile Term t;
|
Volatile Term t;
|
||||||
@ -437,7 +442,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
|||||||
NextToken;
|
NextToken;
|
||||||
if ((Yap_tokptr->Tok != Ord(Ponctuation_tok)
|
if ((Yap_tokptr->Tok != Ord(Ponctuation_tok)
|
||||||
|| Unsigned(Yap_tokptr->TokInfo) != 'l')
|
|| 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... */
|
/* special rules apply for +1, -2.3, etc... */
|
||||||
if (Yap_tokptr->Tok == Number_tok) {
|
if (Yap_tokptr->Tok == Number_tok) {
|
||||||
@ -492,7 +497,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
|||||||
Yap_ErrorMessage = "Heap Overflow";
|
Yap_ErrorMessage = "Heap Overflow";
|
||||||
FAIL;
|
FAIL;
|
||||||
}
|
}
|
||||||
t = ParseTerm(oprprio, FailBuff);
|
t = ParseTerm(oprprio, FailBuff PASS_REGS);
|
||||||
t = Yap_MkApplTerm(func, 1, &t);
|
t = Yap_MkApplTerm(func, 1, &t);
|
||||||
/* check for possible overflow against local stack */
|
/* check for possible overflow against local stack */
|
||||||
if (H > ASP-4096) {
|
if (H > ASP-4096) {
|
||||||
@ -507,7 +512,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
|||||||
}
|
}
|
||||||
if (Yap_tokptr->Tok == Ord(Ponctuation_tok)
|
if (Yap_tokptr->Tok == Ord(Ponctuation_tok)
|
||||||
&& Unsigned(Yap_tokptr->TokInfo) == 'l')
|
&& Unsigned(Yap_tokptr->TokInfo) == 'l')
|
||||||
t = ParseArgs((Atom) t, FailBuff);
|
t = ParseArgs((Atom) t, FailBuff PASS_REGS);
|
||||||
else
|
else
|
||||||
t = MkAtomTerm((Atom)t);
|
t = MkAtomTerm((Atom)t);
|
||||||
break;
|
break;
|
||||||
@ -568,24 +573,24 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
|||||||
case '(':
|
case '(':
|
||||||
case 'l': /* non solo ( */
|
case 'l': /* non solo ( */
|
||||||
NextToken;
|
NextToken;
|
||||||
t = ParseTerm(1200, FailBuff);
|
t = ParseTerm(1200, FailBuff PASS_REGS);
|
||||||
checkfor((Term) ')', FailBuff);
|
checkfor((Term) ')', FailBuff PASS_REGS);
|
||||||
break;
|
break;
|
||||||
case '[':
|
case '[':
|
||||||
NextToken;
|
NextToken;
|
||||||
t = ParseList(FailBuff);
|
t = ParseList(FailBuff PASS_REGS);
|
||||||
checkfor((Term) ']', FailBuff);
|
checkfor((Term) ']', FailBuff PASS_REGS);
|
||||||
break;
|
break;
|
||||||
case '{':
|
case '{':
|
||||||
NextToken;
|
NextToken;
|
||||||
t = ParseTerm(1200, FailBuff);
|
t = ParseTerm(1200, FailBuff PASS_REGS);
|
||||||
t = Yap_MkApplTerm(FunctorBraces, 1, &t);
|
t = Yap_MkApplTerm(FunctorBraces, 1, &t);
|
||||||
/* check for possible overflow against local stack */
|
/* check for possible overflow against local stack */
|
||||||
if (H > ASP-4096) {
|
if (H > ASP-4096) {
|
||||||
Yap_ErrorMessage = "Stack Overflow";
|
Yap_ErrorMessage = "Stack Overflow";
|
||||||
FAIL;
|
FAIL;
|
||||||
}
|
}
|
||||||
checkfor((Term) '}', FailBuff);
|
checkfor((Term) '}', FailBuff PASS_REGS);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FAIL;
|
FAIL;
|
||||||
@ -602,7 +607,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
|||||||
if (Yap_tokptr->Tok == Ord(Name_tok)
|
if (Yap_tokptr->Tok == Ord(Name_tok)
|
||||||
&& Yap_HasOp((Atom)(Yap_tokptr->TokInfo))) {
|
&& Yap_HasOp((Atom)(Yap_tokptr->TokInfo))) {
|
||||||
Atom save_opinfo = opinfo = (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) {
|
&& opprio <= prio && oplprio >= curprio) {
|
||||||
/* try parsing as infix operator */
|
/* try parsing as infix operator */
|
||||||
Volatile int oldprio = curprio;
|
Volatile int oldprio = curprio;
|
||||||
@ -616,7 +621,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
|||||||
{
|
{
|
||||||
Term args[2];
|
Term args[2];
|
||||||
args[0] = t;
|
args[0] = t;
|
||||||
args[1] = ParseTerm(oprprio, FailBuff);
|
args[1] = ParseTerm(oprprio, FailBuff PASS_REGS);
|
||||||
t = Yap_MkApplTerm(func, 2, args);
|
t = Yap_MkApplTerm(func, 2, args);
|
||||||
/* check for possible overflow against local stack */
|
/* check for possible overflow against local stack */
|
||||||
if (H > ASP-4096) {
|
if (H > ASP-4096) {
|
||||||
@ -632,7 +637,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
|||||||
curprio = oldprio;
|
curprio = oldprio;
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (IsPosfixOp(opinfo, &opprio, &oplprio)
|
if (IsPosfixOp(opinfo, &opprio, &oplprio PASS_REGS)
|
||||||
&& opprio <= prio && oplprio >= curprio) {
|
&& opprio <= prio && oplprio >= curprio) {
|
||||||
/* parse as posfix operator */
|
/* parse as posfix operator */
|
||||||
Functor func = Yap_MkFunctor((Atom) Yap_tokptr->TokInfo, 1);
|
Functor func = Yap_MkFunctor((Atom) Yap_tokptr->TokInfo, 1);
|
||||||
@ -658,7 +663,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
|||||||
Volatile Term args[2];
|
Volatile Term args[2];
|
||||||
NextToken;
|
NextToken;
|
||||||
args[0] = t;
|
args[0] = t;
|
||||||
args[1] = ParseTerm(1000, FailBuff);
|
args[1] = ParseTerm(1000, FailBuff PASS_REGS);
|
||||||
t = Yap_MkApplTerm(FunctorComma, 2, args);
|
t = Yap_MkApplTerm(FunctorComma, 2, args);
|
||||||
/* check for possible overflow against local stack */
|
/* check for possible overflow against local stack */
|
||||||
if (H > ASP-4096) {
|
if (H > ASP-4096) {
|
||||||
@ -668,12 +673,12 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
|||||||
curprio = 1000;
|
curprio = 1000;
|
||||||
continue;
|
continue;
|
||||||
} else if (Unsigned(Yap_tokptr->TokInfo) == '|' &&
|
} else if (Unsigned(Yap_tokptr->TokInfo) == '|' &&
|
||||||
IsInfixOp(AtomVBar, &opprio, &oplprio, &oprprio)
|
IsInfixOp(AtomVBar, &opprio, &oplprio, &oprprio PASS_REGS)
|
||||||
&& opprio <= prio && oplprio >= curprio) {
|
&& opprio <= prio && oplprio >= curprio) {
|
||||||
Volatile Term args[2];
|
Volatile Term args[2];
|
||||||
NextToken;
|
NextToken;
|
||||||
args[0] = t;
|
args[0] = t;
|
||||||
args[1] = ParseTerm(oprprio, FailBuff);
|
args[1] = ParseTerm(oprprio, FailBuff PASS_REGS);
|
||||||
t = Yap_MkApplTerm(FunctorVBar, 2, args);
|
t = Yap_MkApplTerm(FunctorVBar, 2, args);
|
||||||
/* check for possible overflow against local stack */
|
/* check for possible overflow against local stack */
|
||||||
if (H > ASP-4096) {
|
if (H > ASP-4096) {
|
||||||
@ -703,11 +708,12 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
|||||||
Term
|
Term
|
||||||
Yap_Parse(void)
|
Yap_Parse(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Volatile Term t;
|
Volatile Term t;
|
||||||
JMPBUFF FailBuff;
|
JMPBUFF FailBuff;
|
||||||
|
|
||||||
if (!sigsetjmp(FailBuff.JmpBuff, 0)) {
|
if (!sigsetjmp(FailBuff.JmpBuff, 0)) {
|
||||||
t = ParseTerm(1200, &FailBuff);
|
t = ParseTerm(1200, &FailBuff PASS_REGS);
|
||||||
if (Yap_tokptr->Tok != Ord(eot_tok))
|
if (Yap_tokptr->Tok != Ord(eot_tok))
|
||||||
return (0L);
|
return (0L);
|
||||||
return (t);
|
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(Int putcellptr, (CELL *));
|
||||||
STATIC_PROTO(CELL get_cell, (void));
|
STATIC_PROTO(CELL get_cell, (void));
|
||||||
STATIC_PROTO(CELL *get_cellptr, ( /* CELL * */ void));
|
STATIC_PROTO(CELL *get_cellptr, ( /* CELL * */ void));
|
||||||
STATIC_PROTO(int put_info, (int, int));
|
STATIC_PROTO(int put_info, (int, int CACHE_TYPE));
|
||||||
STATIC_PROTO(int save_regs, (int));
|
STATIC_PROTO(int save_regs, (int CACHE_TYPE));
|
||||||
STATIC_PROTO(int save_code_info, (void));
|
STATIC_PROTO(int save_code_info, (void));
|
||||||
STATIC_PROTO(int save_heap, (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 save_crc, (void));
|
||||||
STATIC_PROTO(Int do_save, (int));
|
STATIC_PROTO(Int do_save, (int CACHE_TYPE));
|
||||||
STATIC_PROTO(Int p_save2, (void));
|
STATIC_PROTO(Int p_save2, ( CACHE_TYPE1 ));
|
||||||
STATIC_PROTO(Int p_save_program, (void));
|
STATIC_PROTO(Int p_save_program, ( CACHE_TYPE1 ));
|
||||||
STATIC_PROTO(int check_header, (CELL *, CELL *, CELL *, CELL *));
|
STATIC_PROTO(int check_header, (CELL *, CELL *, CELL *, CELL * CACHE_TYPE));
|
||||||
STATIC_PROTO(int get_heap_info, (void));
|
STATIC_PROTO(int get_heap_info, (CACHE_TYPE1));
|
||||||
STATIC_PROTO(int get_regs, (int));
|
STATIC_PROTO(int get_regs, (int CACHE_TYPE));
|
||||||
STATIC_PROTO(int get_insts, (OPCODE []));
|
STATIC_PROTO(int get_insts, (OPCODE []));
|
||||||
STATIC_PROTO(int get_hash, (void));
|
STATIC_PROTO(int get_hash, (void));
|
||||||
STATIC_PROTO(int CopyCode, (void));
|
STATIC_PROTO(int CopyCode, ( CACHE_TYPE1 ));
|
||||||
STATIC_PROTO(int CopyStacks, (void));
|
STATIC_PROTO(int CopyStacks, ( CACHE_TYPE1 ));
|
||||||
STATIC_PROTO(int get_coded, (int, OPCODE []));
|
STATIC_PROTO(int get_coded, (int, OPCODE [] CACHE_TYPE));
|
||||||
STATIC_PROTO(void restore_codes, (void));
|
STATIC_PROTO(void restore_codes, (void));
|
||||||
STATIC_PROTO(Term AdjustDBTerm, (Term, Term *));
|
STATIC_PROTO(void RestoreDB, (DBEntry * CACHE_TYPE));
|
||||||
STATIC_PROTO(void RestoreDB, (DBEntry *));
|
STATIC_PROTO(void RestoreDBTerm, (DBTerm *, int CACHE_TYPE));
|
||||||
STATIC_PROTO(void RestoreDBTerm, (DBTerm *, int));
|
STATIC_PROTO(void CleanClauses, (yamop *, yamop *,PredEntry * CACHE_TYPE));
|
||||||
STATIC_PROTO(void CleanClauses, (yamop *, yamop *,PredEntry *));
|
STATIC_PROTO(void rehash, (CELL *, int, int CACHE_TYPE));
|
||||||
STATIC_PROTO(void rehash, (CELL *, int, int));
|
STATIC_PROTO(void CleanCode, (PredEntry * CACHE_TYPE));
|
||||||
STATIC_PROTO(void CleanCode, (PredEntry *));
|
STATIC_PROTO(void RestoreEntries, (PropEntry *, int CACHE_TYPE));
|
||||||
STATIC_PROTO(void RestoreEntries, (PropEntry *, int));
|
STATIC_PROTO(void RestoreFreeSpace, ( CACHE_TYPE1 ));
|
||||||
STATIC_PROTO(void RestoreFreeSpace, (void));
|
|
||||||
STATIC_PROTO(void restore_heap, (void));
|
STATIC_PROTO(void restore_heap, (void));
|
||||||
#ifdef DEBUG_RESTORE3
|
#ifdef DEBUG_RESTORE3
|
||||||
STATIC_PROTO(void ShowAtoms, (void));
|
STATIC_PROTO(void ShowAtoms, (void));
|
||||||
@ -128,10 +127,10 @@ STATIC_PROTO(void CloseRestore, (void));
|
|||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
STATIC_PROTO(int check_opcodes, (OPCODE []));
|
STATIC_PROTO(int check_opcodes, (OPCODE []));
|
||||||
#endif
|
#endif
|
||||||
STATIC_PROTO(void RestoreHeap, (OPCODE []));
|
STATIC_PROTO(void RestoreHeap, (OPCODE [] CACHE_TYPE));
|
||||||
STATIC_PROTO(Int p_restore, (void));
|
STATIC_PROTO(Int p_restore, ( CACHE_TYPE1 ));
|
||||||
STATIC_PROTO(void restore_heap_regs, (void));
|
STATIC_PROTO(void restore_heap_regs, ( CACHE_TYPE1 ));
|
||||||
STATIC_PROTO(void restore_regs, (int));
|
STATIC_PROTO(void restore_regs, (int CACHE_TYPE));
|
||||||
#ifdef MACYAP
|
#ifdef MACYAP
|
||||||
STATIC_PROTO(void NewFileInfo, (long, long));
|
STATIC_PROTO(void NewFileInfo, (long, long));
|
||||||
extern int DefVol;
|
extern int DefVol;
|
||||||
@ -162,6 +161,7 @@ LightBug(s)
|
|||||||
static Int
|
static Int
|
||||||
do_system_error(yap_error_number etype, const char *msg)
|
do_system_error(yap_error_number etype, const char *msg)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
#if HAVE_SNPRINTF
|
#if HAVE_SNPRINTF
|
||||||
#if HAVE_STRERROR
|
#if HAVE_STRERROR
|
||||||
snprintf(Yap_ErrorSay,MAX_ERROR_MSG_SIZE,"%s (%s when reading %s)", msg, strerror(errno), Yap_FileNameBuf);
|
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
|
* set, the work size, and the space ocuppied
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
put_info(int info, int mode)
|
put_info(int info, int mode USES_REGS)
|
||||||
{
|
{
|
||||||
char msg[256];
|
char msg[256];
|
||||||
|
|
||||||
@ -373,7 +373,7 @@ put_info(int info, int mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
save_regs(int mode)
|
save_regs(int mode USES_REGS)
|
||||||
{
|
{
|
||||||
/* save all registers */
|
/* save all registers */
|
||||||
if (putout((CELL)compile_arrays) < 0)
|
if (putout((CELL)compile_arrays) < 0)
|
||||||
@ -516,7 +516,7 @@ save_heap(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
save_stacks(int mode)
|
save_stacks(int mode USES_REGS)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
@ -572,7 +572,7 @@ save_crc(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
do_save(int mode) {
|
do_save(int mode USES_REGS) {
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
|
|
||||||
if (Yap_HoleSize) {
|
if (Yap_HoleSize) {
|
||||||
@ -590,15 +590,15 @@ do_save(int mode) {
|
|||||||
"restore/1, open(%s)", strerror(errno));
|
"restore/1, open(%s)", strerror(errno));
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
if (put_info(FullSaved, mode) < 0)
|
if (put_info(FullSaved, mode PASS_REGS) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (save_regs(mode) < 0)
|
if (save_regs(mode PASS_REGS) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (save_code_info() < 0)
|
if (save_code_info() < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (save_heap() < 0)
|
if (save_heap() < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (save_stacks(mode) < 0)
|
if (save_stacks(mode PASS_REGS) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (save_crc() < 0)
|
if (save_crc() < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -608,7 +608,7 @@ do_save(int mode) {
|
|||||||
|
|
||||||
/* Saves a complete prolog environment */
|
/* Saves a complete prolog environment */
|
||||||
static Int
|
static Int
|
||||||
p_save2(void)
|
p_save2( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Int res;
|
Int res;
|
||||||
|
|
||||||
@ -632,25 +632,25 @@ p_save2(void)
|
|||||||
if (!Yap_unify(ARG2,MkIntTerm(1)))
|
if (!Yap_unify(ARG2,MkIntTerm(1)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
which_save = 2;
|
which_save = 2;
|
||||||
Yap_StartSlots();
|
Yap_StartSlots( PASS_REGS1 );
|
||||||
res = do_save(DO_EVERYTHING);
|
res = do_save(DO_EVERYTHING PASS_REGS);
|
||||||
Yap_CloseSlots();
|
Yap_CloseSlots( PASS_REGS1 );
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Just save the program, not the stacks */
|
/* Just save the program, not the stacks */
|
||||||
static Int
|
static Int
|
||||||
p_save_program(void)
|
p_save_program( USES_REGS1 )
|
||||||
{
|
{
|
||||||
which_save = 0;
|
which_save = 0;
|
||||||
return do_save(DO_ONLY_CODE);
|
return do_save(DO_ONLY_CODE PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now, to restore the saved code */
|
/* Now, to restore the saved code */
|
||||||
|
|
||||||
/* First check out if we are dealing with a valid file */
|
/* First check out if we are dealing with a valid file */
|
||||||
static int
|
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 pp[256];
|
||||||
char msg[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 */
|
/* Gets the state of the heap, and evaluates the related variables */
|
||||||
static int
|
static int
|
||||||
get_heap_info(void)
|
get_heap_info(USES_REGS1)
|
||||||
{
|
{
|
||||||
OldHeapBase = (ADDR) get_cellptr();
|
OldHeapBase = (ADDR) get_cellptr();
|
||||||
if (Yap_ErrorMessage)
|
if (Yap_ErrorMessage)
|
||||||
@ -797,7 +797,7 @@ get_heap_info(void)
|
|||||||
/* Saves the old bases for the work areas */
|
/* Saves the old bases for the work areas */
|
||||||
/* and evaluates the difference from the old areas to the new ones */
|
/* and evaluates the difference from the old areas to the new ones */
|
||||||
static int
|
static int
|
||||||
get_regs(int flag)
|
get_regs(int flag USES_REGS)
|
||||||
{
|
{
|
||||||
CELL *NewGlobalBase = (CELL *)Yap_GlobalBase;
|
CELL *NewGlobalBase = (CELL *)Yap_GlobalBase;
|
||||||
CELL *NewLCL0 = LCL0;
|
CELL *NewLCL0 = LCL0;
|
||||||
@ -897,7 +897,7 @@ get_regs(int flag)
|
|||||||
XDiff = (CELL)XREGS - (CELL)OldXREGS;
|
XDiff = (CELL)XREGS - (CELL)OldXREGS;
|
||||||
if (Yap_ErrorMessage)
|
if (Yap_ErrorMessage)
|
||||||
return -1;
|
return -1;
|
||||||
if (get_heap_info() < 0)
|
if (get_heap_info( PASS_REGS1 ) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (flag == DO_EVERYTHING) {
|
if (flag == DO_EVERYTHING) {
|
||||||
ARG1 = get_cell();
|
ARG1 = get_cell();
|
||||||
@ -944,7 +944,7 @@ get_hash(void)
|
|||||||
|
|
||||||
/* Copy all of the old code to the new Heap */
|
/* Copy all of the old code to the new Heap */
|
||||||
static int
|
static int
|
||||||
CopyCode(void)
|
CopyCode( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (myread(splfild, (char *) Yap_HeapBase, (Unsigned(OldHeapTop) - Unsigned(OldHeapBase))) < 0) {
|
if (myread(splfild, (char *) Yap_HeapBase, (Unsigned(OldHeapTop) - Unsigned(OldHeapBase))) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -955,7 +955,7 @@ CopyCode(void)
|
|||||||
/* Copy the local and global stack and also the trail to their new home */
|
/* Copy the local and global stack and also the trail to their new home */
|
||||||
/* In REGS we still have nonadjusted values !! */
|
/* In REGS we still have nonadjusted values !! */
|
||||||
static int
|
static int
|
||||||
CopyStacks(void)
|
CopyStacks( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Int j;
|
Int j;
|
||||||
char *NewASP;
|
char *NewASP;
|
||||||
@ -976,7 +976,7 @@ CopyStacks(void)
|
|||||||
/* Copy the local and global stack and also the trail to their new home */
|
/* Copy the local and global stack and also the trail to their new home */
|
||||||
/* In REGS we still have nonadjusted values !! */
|
/* In REGS we still have nonadjusted values !! */
|
||||||
static int
|
static int
|
||||||
CopyTrailEntries(void)
|
CopyTrailEntries( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL entry, *Entries;
|
CELL entry, *Entries;
|
||||||
|
|
||||||
@ -991,25 +991,25 @@ CopyTrailEntries(void)
|
|||||||
|
|
||||||
/* get things which are saved in the file */
|
/* get things which are saved in the file */
|
||||||
static int
|
static int
|
||||||
get_coded(int flag, OPCODE old_ops[])
|
get_coded(int flag, OPCODE old_ops[] USES_REGS)
|
||||||
{
|
{
|
||||||
char my_end_msg[256];
|
char my_end_msg[256];
|
||||||
|
|
||||||
if (get_regs(flag) < 0)
|
if (get_regs(flag PASS_REGS) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (get_insts(old_ops) < 0)
|
if (get_insts(old_ops) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (get_hash() < 0)
|
if (get_hash() < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (CopyCode() < 0)
|
if (CopyCode( PASS_REGS1 ) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
switch (flag) {
|
switch (flag) {
|
||||||
case DO_EVERYTHING:
|
case DO_EVERYTHING:
|
||||||
if (CopyStacks() < 0)
|
if (CopyStacks( PASS_REGS1 ) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
case DO_ONLY_CODE:
|
case DO_ONLY_CODE:
|
||||||
if (CopyTrailEntries() < 0)
|
if (CopyTrailEntries( PASS_REGS1 ) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1025,7 +1025,7 @@ get_coded(int flag, OPCODE old_ops[])
|
|||||||
|
|
||||||
/* restore some heap registers */
|
/* restore some heap registers */
|
||||||
static void
|
static void
|
||||||
restore_heap_regs(void)
|
restore_heap_regs( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (HeapTop) {
|
if (HeapTop) {
|
||||||
HeapTop = AddrAdjust(HeapTop);
|
HeapTop = AddrAdjust(HeapTop);
|
||||||
@ -1037,9 +1037,9 @@ restore_heap_regs(void)
|
|||||||
|
|
||||||
/* adjust abstract machine registers */
|
/* adjust abstract machine registers */
|
||||||
static void
|
static void
|
||||||
restore_regs(int flag)
|
restore_regs(int flag USES_REGS)
|
||||||
{
|
{
|
||||||
restore_heap_regs();
|
restore_heap_regs( PASS_REGS1 );
|
||||||
if (CurrentModule) {
|
if (CurrentModule) {
|
||||||
CurrentModule = AtomTermAdjust(CurrentModule);;
|
CurrentModule = AtomTermAdjust(CurrentModule);;
|
||||||
}
|
}
|
||||||
@ -1056,7 +1056,7 @@ restore_regs(int flag)
|
|||||||
S = PtoGloAdjust(S);
|
S = PtoGloAdjust(S);
|
||||||
if (EX) {
|
if (EX) {
|
||||||
EX = DBTermAdjust(EX);
|
EX = DBTermAdjust(EX);
|
||||||
RestoreDBTerm(EX, TRUE);
|
RestoreDBTerm(EX, TRUE PASS_REGS);
|
||||||
}
|
}
|
||||||
WokenGoals = AbsAppl(PtoGloAdjust(RepAppl(WokenGoals)));
|
WokenGoals = AbsAppl(PtoGloAdjust(RepAppl(WokenGoals)));
|
||||||
}
|
}
|
||||||
@ -1124,7 +1124,7 @@ recompute_mask(DBRef dbr)
|
|||||||
* previous "hit" order
|
* previous "hit" order
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rehash(CELL *oldcode, int NOfE, int KindOfEntries)
|
rehash(CELL *oldcode, int NOfE, int KindOfEntries USES_REGS)
|
||||||
{
|
{
|
||||||
register CELL *savep, *basep;
|
register CELL *savep, *basep;
|
||||||
CELL *oldp = oldcode;
|
CELL *oldp = oldcode;
|
||||||
@ -1207,7 +1207,7 @@ RestoreIOStructures(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreFreeSpace(void)
|
RestoreFreeSpace( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#if USE_DL_MALLOC
|
#if USE_DL_MALLOC
|
||||||
Yap_av = (struct malloc_state *)AddrAdjust((ADDR)Yap_av);
|
Yap_av = (struct malloc_state *)AddrAdjust((ADDR)Yap_av);
|
||||||
@ -1255,7 +1255,7 @@ RestoreFreeSpace(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreAtomList(Atom atm)
|
RestoreAtomList(Atom atm USES_REGS)
|
||||||
{
|
{
|
||||||
AtomEntry *at;
|
AtomEntry *at;
|
||||||
|
|
||||||
@ -1263,14 +1263,14 @@ RestoreAtomList(Atom atm)
|
|||||||
if (EndOfPAEntr(at))
|
if (EndOfPAEntr(at))
|
||||||
return;
|
return;
|
||||||
do {
|
do {
|
||||||
RestoreAtom(at);
|
RestoreAtom(at PASS_REGS);
|
||||||
at = RepAtom(at->NextOfAE);
|
at = RepAtom(at->NextOfAE);
|
||||||
} while (!EndOfPAEntr(at));
|
} while (!EndOfPAEntr(at));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreHashPreds(void)
|
RestoreHashPreds( USES_REGS1 )
|
||||||
{
|
{
|
||||||
UInt size = PredHashTableSize;
|
UInt size = PredHashTableSize;
|
||||||
int malloced = FALSE;
|
int malloced = FALSE;
|
||||||
@ -1301,7 +1301,7 @@ RestoreHashPreds(void)
|
|||||||
if (p->NextOfPE)
|
if (p->NextOfPE)
|
||||||
p->NextOfPE = PropAdjust(p->NextOfPE);
|
p->NextOfPE = PropAdjust(p->NextOfPE);
|
||||||
nextp = p->NextOfPE;
|
nextp = p->NextOfPE;
|
||||||
CleanCode(p);
|
CleanCode(p PASS_REGS);
|
||||||
hsh = PRED_HASH(p->FunctorOfPred, p->ModuleOfPred, size);
|
hsh = PRED_HASH(p->FunctorOfPred, p->ModuleOfPred, size);
|
||||||
p->NextOfPE = AbsPredProp(np[hsh]);
|
p->NextOfPE = AbsPredProp(np[hsh]);
|
||||||
np[hsh] = p;
|
np[hsh] = p;
|
||||||
@ -1375,9 +1375,10 @@ ShowAtoms()
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
commit_to_saved_state(char *s, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap) {
|
commit_to_saved_state(char *s, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap) {
|
||||||
|
CACHE_REGS
|
||||||
int mode;
|
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);
|
return(FAIL_RESTORE);
|
||||||
Yap_PrologMode = BootMode;
|
Yap_PrologMode = BootMode;
|
||||||
if (Yap_HeapBase) {
|
if (Yap_HeapBase) {
|
||||||
@ -1418,6 +1419,7 @@ static int try_open(char *inpf, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *
|
|||||||
if (buf[0] == '\0')
|
if (buf[0] == '\0')
|
||||||
strncpy(buf, inpf, YAP_FILENAME_MAX);
|
strncpy(buf, inpf, YAP_FILENAME_MAX);
|
||||||
if ((mode = commit_to_saved_state(inpf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE) {
|
if ((mode = commit_to_saved_state(inpf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE) {
|
||||||
|
CACHE_REGS
|
||||||
Yap_ErrorMessage = NULL;
|
Yap_ErrorMessage = NULL;
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
@ -1427,6 +1429,7 @@ static int try_open(char *inpf, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *
|
|||||||
static int
|
static int
|
||||||
OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap)
|
OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
int mode = FAIL_RESTORE;
|
int mode = FAIL_RESTORE;
|
||||||
char save_buffer[YAP_FILENAME_MAX+1];
|
char save_buffer[YAP_FILENAME_MAX+1];
|
||||||
|
|
||||||
@ -1580,7 +1583,7 @@ check_opcodes(OPCODE old_ops[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreHeap(OPCODE old_ops[])
|
RestoreHeap(OPCODE old_ops[] USES_REGS)
|
||||||
{
|
{
|
||||||
int heap_moved = (OldHeapBase != Yap_HeapBase ||
|
int heap_moved = (OldHeapBase != Yap_HeapBase ||
|
||||||
XDiff), opcodes_moved;
|
XDiff), opcodes_moved;
|
||||||
@ -1597,7 +1600,7 @@ RestoreHeap(OPCODE old_ops[])
|
|||||||
/* opcodes_moved has side-effects and should be tried first */
|
/* opcodes_moved has side-effects and should be tried first */
|
||||||
if (heap_moved) {
|
if (heap_moved) {
|
||||||
opcodes_moved = TRUE;
|
opcodes_moved = TRUE;
|
||||||
RestoreFreeSpace();
|
RestoreFreeSpace( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
if (heap_moved || opcodes_moved) {
|
if (heap_moved || opcodes_moved) {
|
||||||
restore_heap();
|
restore_heap();
|
||||||
@ -1644,7 +1647,7 @@ Yap_SavedInfo(char *FileName, char *YapLibDir, CELL *ATrail, CELL *AStack, CELL
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
UnmarkTrEntries(void)
|
UnmarkTrEntries( USES_REGS1 )
|
||||||
{
|
{
|
||||||
CELL entry, *Entries;
|
CELL entry, *Entries;
|
||||||
|
|
||||||
@ -1713,7 +1716,7 @@ FreeRecords(void) {
|
|||||||
* associated registers
|
* associated registers
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
Restore(char *s, char *lib_dir)
|
Restore(char *s, char *lib_dir USES_REGS)
|
||||||
{
|
{
|
||||||
int restore_mode;
|
int restore_mode;
|
||||||
|
|
||||||
@ -1724,12 +1727,12 @@ Restore(char *s, char *lib_dir)
|
|||||||
return(FALSE);
|
return(FALSE);
|
||||||
Yap_ShutdownLoadForeign();
|
Yap_ShutdownLoadForeign();
|
||||||
in_limbo = TRUE;
|
in_limbo = TRUE;
|
||||||
if (get_coded(restore_mode, old_ops) < 0)
|
if (get_coded(restore_mode, old_ops PASS_REGS) < 0)
|
||||||
return FAIL_RESTORE;
|
return FAIL_RESTORE;
|
||||||
restore_regs(restore_mode);
|
restore_regs(restore_mode PASS_REGS);
|
||||||
in_limbo = FALSE;
|
in_limbo = FALSE;
|
||||||
/*#endif*/
|
/*#endif*/
|
||||||
RestoreHeap(old_ops);
|
RestoreHeap(old_ops PASS_REGS);
|
||||||
switch(restore_mode) {
|
switch(restore_mode) {
|
||||||
case DO_EVERYTHING:
|
case DO_EVERYTHING:
|
||||||
if (OldHeapBase != Yap_HeapBase ||
|
if (OldHeapBase != Yap_HeapBase ||
|
||||||
@ -1749,7 +1752,7 @@ Restore(char *s, char *lib_dir)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DO_ONLY_CODE:
|
case DO_ONLY_CODE:
|
||||||
UnmarkTrEntries();
|
UnmarkTrEntries( PASS_REGS1 );
|
||||||
Yap_InitYaamRegs();
|
Yap_InitYaamRegs();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1777,11 +1780,12 @@ Restore(char *s, char *lib_dir)
|
|||||||
int
|
int
|
||||||
Yap_Restore(char *s, char *lib_dir)
|
Yap_Restore(char *s, char *lib_dir)
|
||||||
{
|
{
|
||||||
return Restore(s, lib_dir);
|
CACHE_REGS
|
||||||
|
return Restore(s, lib_dir PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_restore(void)
|
p_restore( USES_REGS1 )
|
||||||
{
|
{
|
||||||
int mode;
|
int mode;
|
||||||
char s[YAP_FILENAME_MAX+1];
|
char s[YAP_FILENAME_MAX+1];
|
||||||
@ -1802,7 +1806,7 @@ p_restore(void)
|
|||||||
Yap_Error(TYPE_ERROR_LIST,t1,"restore/1");
|
Yap_Error(TYPE_ERROR_LIST,t1,"restore/1");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
if ((mode = Restore(s, NULL)) == DO_ONLY_CODE) {
|
if ((mode = Restore(s, NULL PASS_REGS)) == DO_ONLY_CODE) {
|
||||||
#if PUSH_REGS
|
#if PUSH_REGS
|
||||||
restore_absmi_regs(&Yap_standard_regs);
|
restore_absmi_regs(&Yap_standard_regs);
|
||||||
#endif
|
#endif
|
||||||
|
95
C/scanner.c
95
C/scanner.c
@ -170,6 +170,7 @@ typedef struct scanner_extra_alloc {
|
|||||||
static char *
|
static char *
|
||||||
AllocScannerMemory(unsigned int size)
|
AllocScannerMemory(unsigned int size)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
char *AuxSpScan;
|
char *AuxSpScan;
|
||||||
|
|
||||||
AuxSpScan = ScannerStack;
|
AuxSpScan = ScannerStack;
|
||||||
@ -206,6 +207,7 @@ AllocScannerMemory(unsigned int size)
|
|||||||
static void
|
static void
|
||||||
PopScannerMemory(char *block, unsigned int size)
|
PopScannerMemory(char *block, unsigned int size)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (block == ScannerStack-size) {
|
if (block == ScannerStack-size) {
|
||||||
ScannerStack -= size;
|
ScannerStack -= size;
|
||||||
} else if (block == (char *)(ScannerExtraBlocks+1)) {
|
} else if (block == (char *)(ScannerExtraBlocks+1)) {
|
||||||
@ -232,6 +234,7 @@ float_send(char *s, int sign)
|
|||||||
#if HAVE_FINITE
|
#if HAVE_FINITE
|
||||||
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) { /* iso */
|
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) { /* iso */
|
||||||
if (!finite(f)) {
|
if (!finite(f)) {
|
||||||
|
CACHE_REGS
|
||||||
Yap_ErrorMessage = "Float overflow while scanning";
|
Yap_ErrorMessage = "Float overflow while scanning";
|
||||||
return(MkEvalFl(0.0));
|
return(MkEvalFl(0.0));
|
||||||
}
|
}
|
||||||
@ -261,6 +264,13 @@ read_int_overflow(const char *s, Int base, Int val, int sign)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
send_error_message(char s[])
|
||||||
|
{
|
||||||
|
CACHE_REGS
|
||||||
|
Yap_ErrorMessage = s;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static wchar_t
|
static wchar_t
|
||||||
read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
||||||
@ -285,8 +295,7 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
|||||||
return '\b';
|
return '\b';
|
||||||
case 'c':
|
case 'c':
|
||||||
if (yap_flags[CHARACTER_ESCAPE_FLAG] == ISO_CHARACTER_ESCAPES) {
|
if (yap_flags[CHARACTER_ESCAPE_FLAG] == ISO_CHARACTER_ESCAPES) {
|
||||||
Yap_ErrorMessage = "invalid escape sequence \\c";
|
return send_error_message("invalid escape sequence \\c");
|
||||||
return 0;
|
|
||||||
} else {
|
} else {
|
||||||
/* sicstus */
|
/* sicstus */
|
||||||
ch = getchrq(inp_stream);
|
ch = getchrq(inp_stream);
|
||||||
@ -322,8 +331,7 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
|||||||
} else if (ch>='A' && ch <= 'F') {
|
} else if (ch>='A' && ch <= 'F') {
|
||||||
wc += ((ch-'A')+10)<<((3-i)*4);
|
wc += ((ch-'A')+10)<<((3-i)*4);
|
||||||
} else {
|
} else {
|
||||||
Yap_ErrorMessage = "invalid escape sequence";
|
return send_error_message("invalid escape sequence");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return wc;
|
return wc;
|
||||||
@ -342,8 +350,7 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
|||||||
} else if (ch>='A' && ch <= 'F') {
|
} else if (ch>='A' && ch <= 'F') {
|
||||||
wc += ((ch-'A')+10)<<((7-i)*4);
|
wc += ((ch-'A')+10)<<((7-i)*4);
|
||||||
} else {
|
} else {
|
||||||
Yap_ErrorMessage = "invalid escape sequence";
|
return send_error_message("invalid escape sequence");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return wc;
|
return wc;
|
||||||
@ -360,8 +367,7 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
|||||||
return '`';
|
return '`';
|
||||||
case '^':
|
case '^':
|
||||||
if (yap_flags[CHARACTER_ESCAPE_FLAG] == ISO_CHARACTER_ESCAPES) {
|
if (yap_flags[CHARACTER_ESCAPE_FLAG] == ISO_CHARACTER_ESCAPES) {
|
||||||
Yap_ErrorMessage = "invalid escape sequence";
|
return send_error_message("invalid escape sequence");
|
||||||
return 0;
|
|
||||||
} else {
|
} else {
|
||||||
ch = getchrq(inp_stream);
|
ch = getchrq(inp_stream);
|
||||||
if (ch == '?') {/* delete character */
|
if (ch == '?') {/* delete character */
|
||||||
@ -393,20 +399,17 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
|||||||
so_far = so_far*8+(ch-'0');
|
so_far = so_far*8+(ch-'0');
|
||||||
ch = getchrq(inp_stream);
|
ch = getchrq(inp_stream);
|
||||||
if (ch != '\\') {
|
if (ch != '\\') {
|
||||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
return send_error_message("invalid octal escape sequence");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
} else if (ch == '\\') {
|
} else if (ch == '\\') {
|
||||||
return so_far;
|
return so_far;
|
||||||
} else {
|
} else {
|
||||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
return send_error_message("invalid octal escape sequence");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
} else if (ch == '\\') {
|
} else if (ch == '\\') {
|
||||||
return so_far;
|
return so_far;
|
||||||
} else {
|
} else {
|
||||||
Yap_ErrorMessage = "invalid octal escape sequence";
|
return send_error_message("invalid octal escape sequence");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* sicstus */
|
/* sicstus */
|
||||||
@ -442,20 +445,17 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
|||||||
if (ch == '\\') {
|
if (ch == '\\') {
|
||||||
return so_far;
|
return so_far;
|
||||||
} else {
|
} else {
|
||||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
return send_error_message("invalid hexadecimal escape sequence");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
} else if (ch == '\\') {
|
} else if (ch == '\\') {
|
||||||
return so_far;
|
return so_far;
|
||||||
} else {
|
} else {
|
||||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
return send_error_message("invalid hexadecimal escape sequence");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
} else if (ch == '\\') {
|
} else if (ch == '\\') {
|
||||||
return so_far;
|
return so_far;
|
||||||
} else {
|
} else {
|
||||||
Yap_ErrorMessage = "invalid hexadecimal escape sequence";
|
return send_error_message("invalid hexadecimal escape sequence");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* sicstus mode */
|
/* sicstus mode */
|
||||||
@ -474,8 +474,7 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
|
|||||||
consider this sequence legal, whereas SICStus would
|
consider this sequence legal, whereas SICStus would
|
||||||
eat up the escape sequence. */
|
eat up the escape sequence. */
|
||||||
if (yap_flags[CHARACTER_ESCAPE_FLAG] == ISO_CHARACTER_ESCAPES) {
|
if (yap_flags[CHARACTER_ESCAPE_FLAG] == ISO_CHARACTER_ESCAPES) {
|
||||||
Yap_ErrorMessage = "invalid escape sequence";
|
return send_error_message("invalid escape sequence");
|
||||||
return 0;
|
|
||||||
} else {
|
} else {
|
||||||
/* sicstus */
|
/* sicstus */
|
||||||
if (chtype(ch) == SL) {
|
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 */
|
/* reads a number, either integer or float */
|
||||||
|
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, int sign)
|
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) {
|
if (chtype(ch) == NU) {
|
||||||
*sp++ = ch;
|
*sp++ = ch;
|
||||||
if (--max_size == 0) {
|
if (--max_size == 0) {
|
||||||
Yap_ErrorMessage = "Number Too Long";
|
return num_send_error_message("Number Too Long");
|
||||||
return TermNil;
|
|
||||||
}
|
}
|
||||||
base = 10 * base + ch - '0';
|
base = 10 * base + ch - '0';
|
||||||
ch = getchr(inp_stream);
|
ch = getchr(inp_stream);
|
||||||
}
|
}
|
||||||
if (ch == '\'') {
|
if (ch == '\'') {
|
||||||
if (base > 36) {
|
if (base > 36) {
|
||||||
Yap_ErrorMessage = "Admissible bases are 0..36";
|
return num_send_error_message("Admissible bases are 0..36");
|
||||||
return TermNil;
|
|
||||||
}
|
}
|
||||||
might_be_float = FALSE;
|
might_be_float = FALSE;
|
||||||
if (--max_size == 0) {
|
if (--max_size == 0) {
|
||||||
Yap_ErrorMessage = "Number Too Long";
|
return num_send_error_message("Number Too Long");
|
||||||
return TermNil;
|
|
||||||
}
|
}
|
||||||
*sp++ = ch;
|
*sp++ = ch;
|
||||||
ch = getchr(inp_stream);
|
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' :
|
int chval = (chtype(ch) == NU ? ch - '0' :
|
||||||
(my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
|
(my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
|
||||||
if (--max_size == 0) {
|
if (--max_size == 0) {
|
||||||
Yap_ErrorMessage = "Number Too Long";
|
return num_send_error_message("Number Too Long");
|
||||||
return TermNil;
|
|
||||||
}
|
}
|
||||||
*sp++ = ch;
|
*sp++ = ch;
|
||||||
val = oval * base + chval;
|
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) {
|
} else if (ch == 'x' && base == 0) {
|
||||||
might_be_float = FALSE;
|
might_be_float = FALSE;
|
||||||
if (--max_size == 0) {
|
if (--max_size == 0) {
|
||||||
Yap_ErrorMessage = "Number Too Long";
|
return num_send_error_message("Number Too Long");
|
||||||
return TermNil;
|
|
||||||
}
|
}
|
||||||
*sp++ = ch;
|
*sp++ = ch;
|
||||||
ch = getchr(inp_stream);
|
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' :
|
int chval = (chtype(ch) == NU ? ch - '0' :
|
||||||
(my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
|
(my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
|
||||||
if (--max_size == 0) {
|
if (--max_size == 0) {
|
||||||
Yap_ErrorMessage = "Number Too Long";
|
return num_send_error_message("Number Too Long");
|
||||||
return TermNil;
|
|
||||||
}
|
}
|
||||||
*sp++ = ch;
|
*sp++ = ch;
|
||||||
val = val * 16 + chval;
|
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;
|
Int oval = val;
|
||||||
if (!(val == 0 && ch == '0') || has_overflow) {
|
if (!(val == 0 && ch == '0') || has_overflow) {
|
||||||
if (--max_size == 0) {
|
if (--max_size == 0) {
|
||||||
Yap_ErrorMessage = "Number Too Long";
|
return num_send_error_message("Number Too Long");
|
||||||
return (TermNil);
|
|
||||||
}
|
}
|
||||||
*sp++ = ch;
|
*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 (might_be_float && ( ch == '.' || ch == 'e' || ch == 'E')) {
|
||||||
if (yap_flags[STRICT_ISO_FLAG] && (ch == 'e' || ch == 'E')) {
|
if (yap_flags[STRICT_ISO_FLAG] && (ch == 'e' || ch == 'E')) {
|
||||||
Yap_ErrorMessage = "Float format not allowed in ISO mode";
|
return num_send_error_message("Float format not allowed in ISO mode");
|
||||||
return TermNil;
|
|
||||||
}
|
}
|
||||||
if (ch == '.') {
|
if (ch == '.') {
|
||||||
if (--max_size == 0) {
|
if (--max_size == 0) {
|
||||||
Yap_ErrorMessage = "Number Too Long";
|
return num_send_error_message("Number Too Long");
|
||||||
return TermNil;
|
|
||||||
}
|
}
|
||||||
*sp++ = '.';
|
*sp++ = '.';
|
||||||
if (chtype(ch = getchr(inp_stream)) != NU) {
|
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 {
|
do {
|
||||||
if (--max_size == 0) {
|
if (--max_size == 0) {
|
||||||
Yap_ErrorMessage = "Number Too Long";
|
return num_send_error_message("Number Too Long");
|
||||||
return TermNil;
|
|
||||||
}
|
}
|
||||||
*sp++ = ch;
|
*sp++ = ch;
|
||||||
}
|
}
|
||||||
@ -648,16 +646,14 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
|
|||||||
char cbuff = ch;
|
char cbuff = ch;
|
||||||
|
|
||||||
if (--max_size == 0) {
|
if (--max_size == 0) {
|
||||||
Yap_ErrorMessage = "Number Too Long";
|
return num_send_error_message("Number Too Long");
|
||||||
return TermNil;
|
|
||||||
}
|
}
|
||||||
*sp++ = ch;
|
*sp++ = ch;
|
||||||
ch = getchr(inp_stream);
|
ch = getchr(inp_stream);
|
||||||
if (ch == '-') {
|
if (ch == '-') {
|
||||||
cbuff = '-';
|
cbuff = '-';
|
||||||
if (--max_size == 0) {
|
if (--max_size == 0) {
|
||||||
Yap_ErrorMessage = "Number Too Long";
|
return num_send_error_message("Number Too Long");
|
||||||
return TermNil;
|
|
||||||
}
|
}
|
||||||
*sp++ = '-';
|
*sp++ = '-';
|
||||||
ch = getchr(inp_stream);
|
ch = getchr(inp_stream);
|
||||||
@ -679,8 +675,7 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
|
|||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
if (--max_size == 0) {
|
if (--max_size == 0) {
|
||||||
Yap_ErrorMessage = "Number Too Long";
|
return num_send_error_message("Number Too Long");
|
||||||
return TermNil;
|
|
||||||
}
|
}
|
||||||
*sp++ = ch;
|
*sp++ = ch;
|
||||||
} while (chtype(ch = getchr(inp_stream)) == NU);
|
} 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
|
Term
|
||||||
Yap_scan_num(IOSTREAM *inp)
|
Yap_scan_num(IOSTREAM *inp)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term out;
|
Term out;
|
||||||
int sign = 1;
|
int sign = 1;
|
||||||
int ch, cherr;
|
int ch, cherr;
|
||||||
@ -756,6 +752,7 @@ Yap_scan_num(IOSTREAM *inp)
|
|||||||
static wchar_t *
|
static wchar_t *
|
||||||
ch_to_wide(char *base, char *charp)
|
ch_to_wide(char *base, char *charp)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
int n = charp-base, i;
|
int n = charp-base, i;
|
||||||
wchar_t *nb = (wchar_t *)base;
|
wchar_t *nb = (wchar_t *)base;
|
||||||
|
|
||||||
@ -784,6 +781,7 @@ ch_to_wide(char *base, char *charp)
|
|||||||
TokEntry *
|
TokEntry *
|
||||||
Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
|
Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
TokEntry *t, *l, *p;
|
TokEntry *t, *l, *p;
|
||||||
enum TokenKinds kind;
|
enum TokenKinds kind;
|
||||||
int solo_flag = TRUE;
|
int solo_flag = TRUE;
|
||||||
@ -1269,6 +1267,7 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
|
|||||||
void
|
void
|
||||||
Yap_clean_tokenizer(TokEntry *tokstart, VarEntry *vartable, VarEntry *anonvartable)
|
Yap_clean_tokenizer(TokEntry *tokstart, VarEntry *vartable, VarEntry *anonvartable)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
struct scanner_extra_alloc *ptr = ScannerExtraBlocks;
|
struct scanner_extra_alloc *ptr = ScannerExtraBlocks;
|
||||||
while (ptr) {
|
while (ptr) {
|
||||||
struct scanner_extra_alloc *next = ptr->next;
|
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_EVEN 0
|
||||||
#define M_ODD 1
|
#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(void simple_mergesort, (CELL *, Int, int));
|
||||||
STATIC_PROTO(Int compact_mergesort, (CELL *, Int, int));
|
STATIC_PROTO(Int compact_mergesort, (CELL *, Int, int));
|
||||||
STATIC_PROTO(int key_mergesort, (CELL *, Int, int, Functor));
|
STATIC_PROTO(int key_mergesort, (CELL *, Int, int, Functor));
|
||||||
STATIC_PROTO(void adjust_vector, (CELL *, Int));
|
STATIC_PROTO(void adjust_vector, (CELL *, Int));
|
||||||
STATIC_PROTO(Int p_sort, (void));
|
STATIC_PROTO(Int p_sort, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_msort, (void));
|
STATIC_PROTO(Int p_msort, ( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int p_ksort, (void));
|
STATIC_PROTO(Int p_ksort, ( USES_REGS1 ));
|
||||||
|
|
||||||
/* copy to a new list of terms */
|
/* copy to a new list of terms */
|
||||||
static Int
|
static Int
|
||||||
build_new_list(CELL *pt, Term t)
|
build_new_list(CELL *pt, Term t USES_REGS)
|
||||||
{
|
{
|
||||||
Int out = 0;
|
Int out = 0;
|
||||||
if (IsVarTerm(t))
|
if (IsVarTerm(t))
|
||||||
@ -343,14 +343,14 @@ adjust_vector(CELL *pt, Int size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_sort(void)
|
p_sort( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/* use the heap to build a new list */
|
/* use the heap to build a new list */
|
||||||
CELL *pt = H;
|
CELL *pt = H;
|
||||||
Term out;
|
Term out;
|
||||||
/* list size */
|
/* list size */
|
||||||
Int size;
|
Int size;
|
||||||
size = build_new_list(pt, Deref(ARG1));
|
size = build_new_list(pt, Deref(ARG1) PASS_REGS);
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
if (size < 2)
|
if (size < 2)
|
||||||
@ -368,14 +368,14 @@ p_sort(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_msort(void)
|
p_msort( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/* use the heap to build a new list */
|
/* use the heap to build a new list */
|
||||||
CELL *pt = H;
|
CELL *pt = H;
|
||||||
Term out;
|
Term out;
|
||||||
/* list size */
|
/* list size */
|
||||||
Int size;
|
Int size;
|
||||||
size = build_new_list(pt, Deref(ARG1));
|
size = build_new_list(pt, Deref(ARG1) PASS_REGS);
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
if (size < 2)
|
if (size < 2)
|
||||||
@ -390,14 +390,14 @@ p_msort(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_ksort(void)
|
p_ksort( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/* use the heap to build a new list */
|
/* use the heap to build a new list */
|
||||||
CELL *pt = H;
|
CELL *pt = H;
|
||||||
Term out;
|
Term out;
|
||||||
/* list size */
|
/* list size */
|
||||||
Int size;
|
Int size;
|
||||||
size = build_new_list(pt, Deref(ARG1));
|
size = build_new_list(pt, Deref(ARG1) PASS_REGS);
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
if (size < 2)
|
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 InitPageSize, (void));
|
||||||
STATIC_PROTO (void InitTime, (void));
|
STATIC_PROTO (void InitTime, (void));
|
||||||
STATIC_PROTO (void InitWTime, (void));
|
STATIC_PROTO (void InitWTime, (void));
|
||||||
STATIC_PROTO (Int p_sh, (void));
|
STATIC_PROTO (Int p_sh, ( USES_REGS1 ));
|
||||||
STATIC_PROTO (Int p_shell, (void));
|
STATIC_PROTO (Int p_shell, ( USES_REGS1 ));
|
||||||
STATIC_PROTO (Int p_system, (void));
|
STATIC_PROTO (Int p_system, ( USES_REGS1 ));
|
||||||
STATIC_PROTO (Int p_mv, (void));
|
STATIC_PROTO (Int p_mv, ( USES_REGS1 ));
|
||||||
STATIC_PROTO (Int p_dir_sp, (void));
|
STATIC_PROTO (Int p_dir_sp, ( USES_REGS1 ));
|
||||||
STATIC_PROTO (void InitRandom, (void));
|
STATIC_PROTO (void InitRandom, (void));
|
||||||
STATIC_PROTO (Int p_srandom, (void));
|
STATIC_PROTO (Int p_srandom, ( USES_REGS1 ));
|
||||||
STATIC_PROTO (Int p_alarm, (void));
|
STATIC_PROTO (Int p_alarm, ( USES_REGS1 ));
|
||||||
STATIC_PROTO (Int p_getenv, (void));
|
STATIC_PROTO (Int p_getenv, ( USES_REGS1 ));
|
||||||
STATIC_PROTO (Int p_putenv, (void));
|
STATIC_PROTO (Int p_putenv, ( USES_REGS1 ));
|
||||||
STATIC_PROTO (void set_fpu_exceptions, (int));
|
STATIC_PROTO (void set_fpu_exceptions, (int));
|
||||||
#ifdef MACYAP
|
#ifdef MACYAP
|
||||||
STATIC_PROTO (int chdir, (char *));
|
STATIC_PROTO (int chdir, (char *));
|
||||||
@ -181,6 +181,7 @@ char *libdir = NULL;
|
|||||||
|
|
||||||
void
|
void
|
||||||
Yap_InitSysPath(void) {
|
Yap_InitSysPath(void) {
|
||||||
|
CACHE_REGS
|
||||||
int len;
|
int len;
|
||||||
#if _MSC_VER || defined(__MINGW32__)
|
#if _MSC_VER || defined(__MINGW32__)
|
||||||
int dir_done = FALSE;
|
int dir_done = FALSE;
|
||||||
@ -269,7 +270,7 @@ Yap_InitSysPath(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_dir_sp (void)
|
p_dir_sp ( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#ifdef MAC
|
#ifdef MAC
|
||||||
Term t = MkIntTerm(':');
|
Term t = MkIntTerm(':');
|
||||||
@ -347,6 +348,7 @@ static struct timeval StartOfTimes_sys;
|
|||||||
static void
|
static void
|
||||||
InitTime (void)
|
InitTime (void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
struct rusage rusage;
|
struct rusage rusage;
|
||||||
|
|
||||||
#if THREADS
|
#if THREADS
|
||||||
@ -362,8 +364,9 @@ InitTime (void)
|
|||||||
|
|
||||||
|
|
||||||
UInt
|
UInt
|
||||||
Yap_cputime (void)
|
Yap_cputime ( void )
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
struct rusage rusage;
|
struct rusage rusage;
|
||||||
|
|
||||||
getrusage(RUSAGE_SELF, &rusage);
|
getrusage(RUSAGE_SELF, &rusage);
|
||||||
@ -373,6 +376,7 @@ Yap_cputime (void)
|
|||||||
|
|
||||||
void Yap_cputime_interval(Int *now,Int *interval)
|
void Yap_cputime_interval(Int *now,Int *interval)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
struct rusage rusage;
|
struct rusage rusage;
|
||||||
|
|
||||||
getrusage(RUSAGE_SELF, &rusage);
|
getrusage(RUSAGE_SELF, &rusage);
|
||||||
@ -466,7 +470,7 @@ sub_utime(FILETIME t1, FILETIME t2)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
UInt
|
UInt
|
||||||
Yap_cputime (void)
|
Yap_cputime ( USES_REGS1 )
|
||||||
{
|
{
|
||||||
HANDLE hProcess = GetCurrentProcess();
|
HANDLE hProcess = GetCurrentProcess();
|
||||||
FILETIME CreationTime, ExitTime, KernelTime, UserTime;
|
FILETIME CreationTime, ExitTime, KernelTime, UserTime;
|
||||||
@ -991,7 +995,7 @@ Yap_random (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_srandom (void)
|
p_srandom ( USES_REGS1 )
|
||||||
{
|
{
|
||||||
register Term t0 = Deref (ARG1);
|
register Term t0 = Deref (ARG1);
|
||||||
if (IsVarTerm (t0)) {
|
if (IsVarTerm (t0)) {
|
||||||
@ -1654,6 +1658,7 @@ HandleSIGINT (int sig, siginfo_t *x, ucontext_t *y)
|
|||||||
HandleSIGINT (int sig)
|
HandleSIGINT (int sig)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
my_signal(SIGINT, HandleSIGINT);
|
my_signal(SIGINT, HandleSIGINT);
|
||||||
/* do this before we act */
|
/* do this before we act */
|
||||||
#if HAVE_ISATTY
|
#if HAVE_ISATTY
|
||||||
@ -1866,6 +1871,7 @@ Yap_volume_header(char *file)
|
|||||||
|
|
||||||
int Yap_getcwd(const char *buf, int len)
|
int Yap_getcwd(const char *buf, int len)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
#if __simplescalar__
|
#if __simplescalar__
|
||||||
/* does not implement getcwd */
|
/* does not implement getcwd */
|
||||||
strncpy(Yap_buf,yap_pwd,len);
|
strncpy(Yap_buf,yap_pwd,len);
|
||||||
@ -1897,6 +1903,7 @@ int Yap_getcwd(const char *buf, int len)
|
|||||||
static int
|
static int
|
||||||
TrueFileName (char *source, char *root, char *result, int in_lib)
|
TrueFileName (char *source, char *root, char *result, int in_lib)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
char *work;
|
char *work;
|
||||||
char ares1[YAP_FILENAME_MAX];
|
char ares1[YAP_FILENAME_MAX];
|
||||||
|
|
||||||
@ -2082,7 +2089,7 @@ Yap_TrueFileName (char *source, char *result, int in_lib)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_true_file_name (void)
|
p_true_file_name ( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
@ -2099,7 +2106,7 @@ p_true_file_name (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_true_file_name3 (void)
|
p_true_file_name3 ( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1), t2 = Deref(ARG2);
|
Term t = Deref(ARG1), t2 = Deref(ARG2);
|
||||||
char *root = NULL;
|
char *root = NULL;
|
||||||
@ -2126,7 +2133,7 @@ p_true_file_name3 (void)
|
|||||||
/* Executes $SHELL under Prolog */
|
/* Executes $SHELL under Prolog */
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_sh (void)
|
p_sh ( USES_REGS1 )
|
||||||
{ /* sh */
|
{ /* sh */
|
||||||
#ifdef HAVE_SYSTEM
|
#ifdef HAVE_SYSTEM
|
||||||
char *shell;
|
char *shell;
|
||||||
@ -2156,7 +2163,7 @@ p_sh (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_shell (void)
|
p_shell ( USES_REGS1 )
|
||||||
{ /* '$shell'(+SystCommand) */
|
{ /* '$shell'(+SystCommand) */
|
||||||
#if _MSC_VER || defined(__MINGW32__)
|
#if _MSC_VER || defined(__MINGW32__)
|
||||||
Yap_Error(SYSTEM_ERROR,TermNil,"shell not available in this configuration");
|
Yap_Error(SYSTEM_ERROR,TermNil,"shell not available in this configuration");
|
||||||
@ -2216,7 +2223,7 @@ p_shell (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_system (void)
|
p_system ( USES_REGS1 )
|
||||||
{ /* '$system'(+SystCommand) */
|
{ /* '$system'(+SystCommand) */
|
||||||
#ifdef HAVE_SYSTEM
|
#ifdef HAVE_SYSTEM
|
||||||
Term t1 = Deref (ARG1);
|
Term t1 = Deref (ARG1);
|
||||||
@ -2266,7 +2273,7 @@ p_system (void)
|
|||||||
|
|
||||||
/* Rename a file */
|
/* Rename a file */
|
||||||
static Int
|
static Int
|
||||||
p_mv (void)
|
p_mv ( USES_REGS1 )
|
||||||
{ /* rename(+OldName,+NewName) */
|
{ /* rename(+OldName,+NewName) */
|
||||||
#if HAVE_LINK
|
#if HAVE_LINK
|
||||||
int r;
|
int r;
|
||||||
@ -2333,7 +2340,7 @@ Yap_SetTextFile (name)
|
|||||||
|
|
||||||
|
|
||||||
/* return YAP's environment */
|
/* return YAP's environment */
|
||||||
static Int p_getenv(void)
|
static Int p_getenv( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#if HAVE_GETENV
|
#if HAVE_GETENV
|
||||||
Term t1 = Deref(ARG1), to;
|
Term t1 = Deref(ARG1), to;
|
||||||
@ -2360,7 +2367,7 @@ static Int p_getenv(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* set a variable in YAP's environment */
|
/* set a variable in YAP's environment */
|
||||||
static Int p_putenv(void)
|
static Int p_putenv( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#if HAVE_PUTENV
|
#if HAVE_PUTENV
|
||||||
Term t1 = Deref(ARG1), t2 = Deref(ARG2);
|
Term t1 = Deref(ARG1), t2 = Deref(ARG2);
|
||||||
@ -2443,7 +2450,7 @@ DoTimerThread(LPVOID targ)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_alarm(void)
|
p_alarm( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Term t2 = Deref(ARG2);
|
Term t2 = Deref(ARG2);
|
||||||
@ -2543,7 +2550,7 @@ p_alarm(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_virtual_alarm(void)
|
p_virtual_alarm( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Term t2 = Deref(ARG2);
|
Term t2 = Deref(ARG2);
|
||||||
@ -2679,7 +2686,7 @@ Yap_set_fpu_exceptions(int flag)
|
|||||||
set_fpu_exceptions(flag);
|
set_fpu_exceptions(flag);
|
||||||
}
|
}
|
||||||
static Int
|
static Int
|
||||||
p_set_fpu_exceptions(void) {
|
p_set_fpu_exceptions( USES_REGS1 ) {
|
||||||
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) {
|
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) {
|
||||||
set_fpu_exceptions(FALSE); /* can't make it work right */
|
set_fpu_exceptions(FALSE); /* can't make it work right */
|
||||||
} else {
|
} else {
|
||||||
@ -2689,19 +2696,19 @@ p_set_fpu_exceptions(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_host_type(void) {
|
p_host_type( USES_REGS1 ) {
|
||||||
Term out = MkAtomTerm(Yap_LookupAtom(HOST_ALIAS));
|
Term out = MkAtomTerm(Yap_LookupAtom(HOST_ALIAS));
|
||||||
return(Yap_unify(out,ARG1));
|
return(Yap_unify(out,ARG1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_yap_home(void) {
|
p_yap_home( USES_REGS1 ) {
|
||||||
Term out = MkAtomTerm(Yap_LookupAtom(YAP_ROOTDIR));
|
Term out = MkAtomTerm(Yap_LookupAtom(YAP_ROOTDIR));
|
||||||
return(Yap_unify(out,ARG1));
|
return(Yap_unify(out,ARG1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_env_separator(void) {
|
p_env_separator( USES_REGS1 ) {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
return Yap_unify(MkIntegerTerm(';'),ARG1);
|
return Yap_unify(MkIntegerTerm(';'),ARG1);
|
||||||
#else
|
#else
|
||||||
@ -2745,7 +2752,7 @@ Yap_ReInitWallTime (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_first_signal(void)
|
p_first_signal( USES_REGS1 )
|
||||||
{
|
{
|
||||||
LOCK(SignalLock);
|
LOCK(SignalLock);
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
@ -2891,7 +2898,7 @@ p_first_signal(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_continue_signals(void)
|
p_continue_signals( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/* hack to force the signal anew */
|
/* hack to force the signal anew */
|
||||||
if (ActiveSignals & YAP_ITI_SIGNAL) {
|
if (ActiveSignals & YAP_ITI_SIGNAL) {
|
||||||
@ -2946,7 +2953,7 @@ p_continue_signals(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_unix(void)
|
p_unix( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#ifdef unix
|
#ifdef unix
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -2964,7 +2971,7 @@ p_unix(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_win32(void)
|
p_win32( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -2979,7 +2986,7 @@ p_win32(void)
|
|||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_enable_interrupts(void)
|
p_enable_interrupts( USES_REGS1 )
|
||||||
{
|
{
|
||||||
LOCK(SignalLock);
|
LOCK(SignalLock);
|
||||||
Yap_InterruptsDisabled--;
|
Yap_InterruptsDisabled--;
|
||||||
@ -2991,7 +2998,7 @@ p_enable_interrupts(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_disable_interrupts(void)
|
p_disable_interrupts( USES_REGS1 )
|
||||||
{
|
{
|
||||||
LOCK(SignalLock);
|
LOCK(SignalLock);
|
||||||
Yap_InterruptsDisabled++;
|
Yap_InterruptsDisabled++;
|
||||||
@ -3003,13 +3010,13 @@ p_disable_interrupts(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_ld_path(void)
|
p_ld_path( USES_REGS1 )
|
||||||
{
|
{
|
||||||
return Yap_unify(ARG1,MkAtomTerm(Yap_LookupAtom(YAP_LIBDIR)));
|
return Yap_unify(ARG1,MkAtomTerm(Yap_LookupAtom(YAP_LIBDIR)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_address_bits(void)
|
p_address_bits( USES_REGS1 )
|
||||||
{
|
{
|
||||||
#if SIZEOF_INT_P==4
|
#if SIZEOF_INT_P==4
|
||||||
return Yap_unify(ARG1,MkIntTerm(32));
|
return Yap_unify(ARG1,MkIntTerm(32));
|
||||||
@ -3112,7 +3119,7 @@ WideStringFromAtom(Atom KeyAt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_win_registry_get_value(void)
|
p_win_registry_get_value( USES_REGS1 )
|
||||||
{
|
{
|
||||||
DWORD type;
|
DWORD type;
|
||||||
BYTE data[MAXREGSTRLEN];
|
BYTE data[MAXREGSTRLEN];
|
||||||
@ -3213,6 +3220,7 @@ Yap_RegistryGetString(char *name)
|
|||||||
void
|
void
|
||||||
Yap_InitSysPreds(void)
|
Yap_InitSysPreds(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term cm = CurrentModule;
|
Term cm = CurrentModule;
|
||||||
|
|
||||||
/* can only do after heap is initialised */
|
/* 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
|
static int
|
||||||
store_specs(int new_worker_id, UInt ssize, UInt tsize, UInt sysize, Term *tpgoal, Term *tpdetach, Term *tpexit)
|
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 */
|
UInt pm; /* memory to be requested */
|
||||||
Term tmod;
|
Term tmod;
|
||||||
Term tdetach, tgoal;
|
Term tdetach, tgoal;
|
||||||
@ -111,6 +112,7 @@ store_specs(int new_worker_id, UInt ssize, UInt tsize, UInt sysize, Term *tpgoal
|
|||||||
static void
|
static void
|
||||||
kill_thread_engine (int wid, int always_die)
|
kill_thread_engine (int wid, int always_die)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Prop p0 = AbsPredProp(FOREIGN_ThreadHandle(wid).local_preds);
|
Prop p0 = AbsPredProp(FOREIGN_ThreadHandle(wid).local_preds);
|
||||||
GlobalEntry *gl = GlobalVariables;
|
GlobalEntry *gl = GlobalVariables;
|
||||||
|
|
||||||
@ -159,6 +161,7 @@ thread_die(int wid, int always_die)
|
|||||||
static void
|
static void
|
||||||
setup_engine(int myworker_id, int init_thread)
|
setup_engine(int myworker_id, int init_thread)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
REGSTORE *standard_regs;
|
REGSTORE *standard_regs;
|
||||||
|
|
||||||
standard_regs = (REGSTORE *)calloc(1,sizeof(REGSTORE));
|
standard_regs = (REGSTORE *)calloc(1,sizeof(REGSTORE));
|
||||||
@ -191,6 +194,7 @@ start_thread(int myworker_id)
|
|||||||
static void *
|
static void *
|
||||||
thread_run(void *widp)
|
thread_run(void *widp)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term tgoal, t;
|
Term tgoal, t;
|
||||||
Term tgs[2];
|
Term tgs[2];
|
||||||
int myworker_id = *((int *)widp);
|
int myworker_id = *((int *)widp);
|
||||||
@ -225,7 +229,7 @@ thread_run(void *widp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_new_tid(void)
|
p_thread_new_tid( USES_REGS1 )
|
||||||
{
|
{
|
||||||
int new_worker = allocate_new_tid();
|
int new_worker = allocate_new_tid();
|
||||||
if (new_worker == -1) {
|
if (new_worker == -1) {
|
||||||
@ -242,7 +246,7 @@ init_thread_engine(int new_worker_id, UInt ssize, UInt tsize, UInt sysize, Term
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_create_thread(void)
|
p_create_thread( USES_REGS1 )
|
||||||
{
|
{
|
||||||
UInt ssize;
|
UInt ssize;
|
||||||
UInt tsize;
|
UInt tsize;
|
||||||
@ -279,7 +283,7 @@ p_create_thread(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_sleep(void)
|
p_thread_sleep( USES_REGS1 )
|
||||||
{
|
{
|
||||||
UInt time = IntegerOfTerm(Deref(ARG1));
|
UInt time = IntegerOfTerm(Deref(ARG1));
|
||||||
#if HAVE_NANOSLEEP
|
#if HAVE_NANOSLEEP
|
||||||
@ -314,7 +318,7 @@ p_thread_sleep(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_self(void)
|
p_thread_self( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
|
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
|
||||||
return Yap_unify(MkIntegerTerm(-1), ARG1);
|
return Yap_unify(MkIntegerTerm(-1), ARG1);
|
||||||
@ -323,7 +327,7 @@ p_thread_self(void)
|
|||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_zombie_self(void)
|
p_thread_zombie_self( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/* make sure the lock is available */
|
/* make sure the lock is available */
|
||||||
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
|
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
|
||||||
@ -342,7 +346,7 @@ p_thread_zombie_self(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_status_lock(void)
|
p_thread_status_lock( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/* make sure the lock is available */
|
/* make sure the lock is available */
|
||||||
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
|
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
|
||||||
@ -352,7 +356,7 @@ p_thread_status_lock(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_status_unlock(void)
|
p_thread_status_unlock( USES_REGS1 )
|
||||||
{
|
{
|
||||||
/* make sure the lock is available */
|
/* make sure the lock is available */
|
||||||
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
|
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
|
||||||
@ -364,6 +368,7 @@ p_thread_status_unlock(void)
|
|||||||
Int
|
Int
|
||||||
Yap_thread_self(void)
|
Yap_thread_self(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
|
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
return worker_id;
|
return worker_id;
|
||||||
@ -412,6 +417,7 @@ Yap_thread_create_engine(thread_attr *ops)
|
|||||||
Int
|
Int
|
||||||
Yap_thread_attach_engine(int wid)
|
Yap_thread_attach_engine(int wid)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
/*
|
/*
|
||||||
already locked
|
already locked
|
||||||
pthread_mutex_lock(&(FOREIGN_ThreadHandle(wid).tlock));
|
pthread_mutex_lock(&(FOREIGN_ThreadHandle(wid).tlock));
|
||||||
@ -462,7 +468,7 @@ Yap_thread_destroy_engine(int wid)
|
|||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_join(void)
|
p_thread_join( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Int tid = IntegerOfTerm(Deref(ARG1));
|
Int tid = IntegerOfTerm(Deref(ARG1));
|
||||||
|
|
||||||
@ -487,7 +493,7 @@ p_thread_join(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_destroy(void)
|
p_thread_destroy( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Int tid = IntegerOfTerm(Deref(ARG1));
|
Int tid = IntegerOfTerm(Deref(ARG1));
|
||||||
|
|
||||||
@ -501,7 +507,7 @@ p_thread_destroy(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_detach(void)
|
p_thread_detach( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Int tid = IntegerOfTerm(Deref(ARG1));
|
Int tid = IntegerOfTerm(Deref(ARG1));
|
||||||
pthread_mutex_lock(&(FOREIGN_ThreadHandle(tid).tlock));
|
pthread_mutex_lock(&(FOREIGN_ThreadHandle(tid).tlock));
|
||||||
@ -520,7 +526,7 @@ p_thread_detach(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_detached(void)
|
p_thread_detached( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (MY_ThreadHandle.tdetach)
|
if (MY_ThreadHandle.tdetach)
|
||||||
return Yap_unify(ARG1,MY_ThreadHandle.tdetach);
|
return Yap_unify(ARG1,MY_ThreadHandle.tdetach);
|
||||||
@ -529,7 +535,7 @@ p_thread_detached(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_detached2(void)
|
p_thread_detached2( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Int tid = IntegerOfTerm(Deref(ARG1));
|
Int tid = IntegerOfTerm(Deref(ARG1));
|
||||||
if (FOREIGN_ThreadHandle(tid).tdetach)
|
if (FOREIGN_ThreadHandle(tid).tdetach)
|
||||||
@ -539,7 +545,7 @@ p_thread_detached2(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_exit(void)
|
p_thread_exit( USES_REGS1 )
|
||||||
{
|
{
|
||||||
thread_die(worker_id, FALSE);
|
thread_die(worker_id, FALSE);
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
@ -548,7 +554,7 @@ p_thread_exit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_set_concurrency(void)
|
p_thread_set_concurrency( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term tnew = Deref(ARG2);
|
Term tnew = Deref(ARG2);
|
||||||
int newc, cur;
|
int newc, cur;
|
||||||
@ -569,7 +575,7 @@ p_thread_set_concurrency(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_yield(void)
|
p_thread_yield( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (sched_yield() != 0) {
|
if (sched_yield() != 0) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -578,7 +584,7 @@ p_thread_yield(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_valid_thread(void)
|
p_valid_thread( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Int i = IntegerOfTerm(Deref(ARG1));
|
Int i = IntegerOfTerm(Deref(ARG1));
|
||||||
return FOREIGN_ThreadHandle(i).in_use || FOREIGN_ThreadHandle(i).zombie;
|
return FOREIGN_ThreadHandle(i).in_use || FOREIGN_ThreadHandle(i).zombie;
|
||||||
@ -593,7 +599,7 @@ typedef struct swi_mutex {
|
|||||||
} SWIMutex;
|
} SWIMutex;
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_new_mutex(void)
|
p_new_mutex( USES_REGS1 )
|
||||||
{
|
{
|
||||||
SWIMutex* mutp;
|
SWIMutex* mutp;
|
||||||
pthread_mutexattr_t mat;
|
pthread_mutexattr_t mat;
|
||||||
@ -617,7 +623,7 @@ p_new_mutex(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_destroy_mutex(void)
|
p_destroy_mutex( USES_REGS1 )
|
||||||
{
|
{
|
||||||
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG1));
|
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG1));
|
||||||
|
|
||||||
@ -628,7 +634,7 @@ p_destroy_mutex(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_lock_mutex(void)
|
p_lock_mutex( USES_REGS1 )
|
||||||
{
|
{
|
||||||
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG1));
|
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG1));
|
||||||
|
|
||||||
@ -640,7 +646,7 @@ p_lock_mutex(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_trylock_mutex(void)
|
p_trylock_mutex( USES_REGS1 )
|
||||||
{
|
{
|
||||||
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG1));
|
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG1));
|
||||||
|
|
||||||
@ -652,7 +658,7 @@ p_trylock_mutex(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_unlock_mutex(void)
|
p_unlock_mutex( USES_REGS1 )
|
||||||
{
|
{
|
||||||
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG1));
|
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG1));
|
||||||
|
|
||||||
@ -663,7 +669,7 @@ p_unlock_mutex(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_mutex_info(void)
|
p_mutex_info( USES_REGS1 )
|
||||||
{
|
{
|
||||||
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG1));
|
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG1));
|
||||||
|
|
||||||
@ -673,7 +679,7 @@ p_mutex_info(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_cond_create(void)
|
p_cond_create( USES_REGS1 )
|
||||||
{
|
{
|
||||||
pthread_cond_t* condp;
|
pthread_cond_t* condp;
|
||||||
|
|
||||||
@ -686,7 +692,7 @@ p_cond_create(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_cond_destroy(void)
|
p_cond_destroy( USES_REGS1 )
|
||||||
{
|
{
|
||||||
pthread_cond_t *condp = (pthread_cond_t *)IntegerOfTerm(Deref(ARG1));
|
pthread_cond_t *condp = (pthread_cond_t *)IntegerOfTerm(Deref(ARG1));
|
||||||
|
|
||||||
@ -697,7 +703,7 @@ p_cond_destroy(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_cond_signal(void)
|
p_cond_signal( USES_REGS1 )
|
||||||
{
|
{
|
||||||
pthread_cond_t *condp = (pthread_cond_t *)IntegerOfTerm(Deref(ARG1));
|
pthread_cond_t *condp = (pthread_cond_t *)IntegerOfTerm(Deref(ARG1));
|
||||||
|
|
||||||
@ -707,7 +713,7 @@ p_cond_signal(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_cond_broadcast(void)
|
p_cond_broadcast( USES_REGS1 )
|
||||||
{
|
{
|
||||||
pthread_cond_t *condp = (pthread_cond_t *)IntegerOfTerm(Deref(ARG1));
|
pthread_cond_t *condp = (pthread_cond_t *)IntegerOfTerm(Deref(ARG1));
|
||||||
|
|
||||||
@ -717,7 +723,7 @@ p_cond_broadcast(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_cond_wait(void)
|
p_cond_wait( USES_REGS1 )
|
||||||
{
|
{
|
||||||
pthread_cond_t *condp = (pthread_cond_t *)IntegerOfTerm(Deref(ARG1));
|
pthread_cond_t *condp = (pthread_cond_t *)IntegerOfTerm(Deref(ARG1));
|
||||||
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG2));
|
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG2));
|
||||||
@ -727,7 +733,7 @@ p_cond_wait(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_stacks(void)
|
p_thread_stacks( USES_REGS1 )
|
||||||
{ /* '$thread_signal'(+P) */
|
{ /* '$thread_signal'(+P) */
|
||||||
Int tid = IntegerOfTerm(Deref(ARG1));
|
Int tid = IntegerOfTerm(Deref(ARG1));
|
||||||
Int status= TRUE;
|
Int status= TRUE;
|
||||||
@ -746,7 +752,7 @@ p_thread_stacks(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_atexit(void)
|
p_thread_atexit( USES_REGS1 )
|
||||||
{ /* '$thread_signal'(+P) */
|
{ /* '$thread_signal'(+P) */
|
||||||
Term t;
|
Term t;
|
||||||
|
|
||||||
@ -781,7 +787,7 @@ p_thread_atexit(void)
|
|||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_signal(void)
|
p_thread_signal( USES_REGS1 )
|
||||||
{ /* '$thread_signal'(+P) */
|
{ /* '$thread_signal'(+P) */
|
||||||
Int wid = IntegerOfTerm(Deref(ARG1));
|
Int wid = IntegerOfTerm(Deref(ARG1));
|
||||||
/* make sure the lock is available */
|
/* make sure the lock is available */
|
||||||
@ -804,13 +810,13 @@ p_thread_signal(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_no_threads(void)
|
p_no_threads( USES_REGS1 )
|
||||||
{ /* '$thread_signal'(+P) */
|
{ /* '$thread_signal'(+P) */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nof_threads(void)
|
p_nof_threads( USES_REGS1 )
|
||||||
{ /* '$nof_threads'(+P) */
|
{ /* '$nof_threads'(+P) */
|
||||||
int i = 0, wid;
|
int i = 0, wid;
|
||||||
LOCK(ThreadHandlesLock);
|
LOCK(ThreadHandlesLock);
|
||||||
@ -823,38 +829,38 @@ p_nof_threads(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_max_workers(void)
|
p_max_workers( USES_REGS1 )
|
||||||
{ /* '$max_workers'(+P) */
|
{ /* '$max_workers'(+P) */
|
||||||
return Yap_unify(ARG1,MkIntegerTerm(MAX_WORKERS));
|
return Yap_unify(ARG1,MkIntegerTerm(MAX_WORKERS));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_max_threads(void)
|
p_max_threads( USES_REGS1 )
|
||||||
{ /* '$max_threads'(+P) */
|
{ /* '$max_threads'(+P) */
|
||||||
return Yap_unify(ARG1,MkIntegerTerm(MAX_THREADS));
|
return Yap_unify(ARG1,MkIntegerTerm(MAX_THREADS));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nof_threads_created(void)
|
p_nof_threads_created( USES_REGS1 )
|
||||||
{ /* '$nof_threads'(+P) */
|
{ /* '$nof_threads'(+P) */
|
||||||
return Yap_unify(ARG1,MkIntTerm(NOfThreadsCreated));
|
return Yap_unify(ARG1,MkIntTerm(NOfThreadsCreated));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_runtime(void)
|
p_thread_runtime( USES_REGS1 )
|
||||||
{ /* '$thread_runtime'(+P) */
|
{ /* '$thread_runtime'(+P) */
|
||||||
return Yap_unify(ARG1,MkIntegerTerm(ThreadsTotalTime));
|
return Yap_unify(ARG1,MkIntegerTerm(ThreadsTotalTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_self_lock(void)
|
p_thread_self_lock( USES_REGS1 )
|
||||||
{ /* '$thread_unlock' */
|
{ /* '$thread_unlock' */
|
||||||
pthread_mutex_lock(&(MY_ThreadHandle.tlock));
|
pthread_mutex_lock(&(MY_ThreadHandle.tlock));
|
||||||
return Yap_unify(ARG1,MkIntegerTerm(worker_id));
|
return Yap_unify(ARG1,MkIntegerTerm(worker_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_thread_unlock(void)
|
p_thread_unlock( USES_REGS1 )
|
||||||
{ /* '$thread_unlock' */
|
{ /* '$thread_unlock' */
|
||||||
Int wid = IntegerOfTerm(Deref(ARG1));
|
Int wid = IntegerOfTerm(Deref(ARG1));
|
||||||
DEBUG_TLOCK_ACCESS(19, wid);
|
DEBUG_TLOCK_ACCESS(19, wid);
|
||||||
|
17
C/tracer.c
17
C/tracer.c
@ -39,7 +39,7 @@ TracePutchar(int sno, int ch)
|
|||||||
static void
|
static void
|
||||||
send_tracer_message(char *start, char *name, Int arity, char *mname, CELL *args)
|
send_tracer_message(char *start, char *name, Int arity, char *mname, CELL *args)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
fprintf(Yap_stderr, "(%d)%s", worker_id, start);
|
fprintf(Yap_stderr, "(%d)%s", worker_id, start);
|
||||||
@ -154,6 +154,7 @@ Term old_x1[10000], old_x2[10000], old_x3[10000];
|
|||||||
void
|
void
|
||||||
low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
char *s;
|
char *s;
|
||||||
char *mname;
|
char *mname;
|
||||||
Int arity;
|
Int arity;
|
||||||
@ -357,31 +358,31 @@ toggle_low_level_trace(void)
|
|||||||
Yap_do_low_level_trace = !Yap_do_low_level_trace;
|
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;
|
Yap_do_low_level_trace = TRUE;
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int p_total_choicepoints(void)
|
static Int p_total_choicepoints( USES_REGS1 )
|
||||||
{
|
{
|
||||||
return Yap_unify(MkIntegerTerm(Yap_total_choicepoints),ARG1);
|
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;
|
Yap_total_choicepoints = 0;
|
||||||
return TRUE;
|
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);
|
fprintf(stderr,"Call counter=%lld\n",vsc_count);
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef THREADS
|
#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;
|
thread_trace = IntegerOfTerm(Deref(ARG1))+1;
|
||||||
Yap_do_low_level_trace = TRUE;
|
Yap_do_low_level_trace = TRUE;
|
||||||
@ -391,7 +392,7 @@ static Int p_start_low_level_trace2(void)
|
|||||||
|
|
||||||
#include <stdio.h>
|
#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;
|
Yap_do_low_level_trace = FALSE;
|
||||||
do_trace_primitives = TRUE;
|
do_trace_primitives = TRUE;
|
||||||
@ -400,7 +401,7 @@ static Int p_stop_low_level_trace(void)
|
|||||||
|
|
||||||
volatile int vsc_wait;
|
volatile int vsc_wait;
|
||||||
|
|
||||||
static Int p_vsc_wait(void)
|
static Int p_vsc_wait( USES_REGS1 )
|
||||||
{
|
{
|
||||||
while (!vsc_wait);
|
while (!vsc_wait);
|
||||||
vsc_wait=1;
|
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.
|
the second argument is the term.
|
||||||
******/
|
******/
|
||||||
static Int
|
static Int
|
||||||
p_new_udi(void)
|
p_new_udi( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term spec = Deref(ARG2), udi_type = Deref(ARG1);
|
Term spec = Deref(ARG2), udi_type = Deref(ARG1);
|
||||||
PredEntry *p;
|
PredEntry *p;
|
||||||
|
22
C/unify.c
22
C/unify.c
@ -16,13 +16,15 @@
|
|||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
#define IN_UNIFY_C 1
|
#define IN_UNIFY_C 1
|
||||||
|
|
||||||
|
#define HAS_CACHE_REGS 1
|
||||||
|
|
||||||
#include "absmi.h"
|
#include "absmi.h"
|
||||||
|
|
||||||
STD_PROTO(int Yap_rational_tree_loop, (CELL *, CELL *, CELL **, CELL **));
|
STD_PROTO(int Yap_rational_tree_loop, (CELL *, CELL *, CELL **, CELL **));
|
||||||
|
|
||||||
STATIC_PROTO(int OCUnify_complex, (CELL *, CELL *, CELL *));
|
STATIC_PROTO(int OCUnify_complex, (CELL *, CELL *, CELL *));
|
||||||
STATIC_PROTO(int OCUnify, (register CELL, register 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
|
#ifdef THREADED_CODE
|
||||||
STATIC_PROTO(int rtable_hash_op, (OPCODE));
|
STATIC_PROTO(int rtable_hash_op, (OPCODE));
|
||||||
STATIC_PROTO(void InitReverseLookupOpcode, (void));
|
STATIC_PROTO(void InitReverseLookupOpcode, (void));
|
||||||
@ -35,7 +37,6 @@ STATIC_PROTO(void InitReverseLookupOpcode, (void));
|
|||||||
int
|
int
|
||||||
Yap_rational_tree_loop(CELL *pt0, CELL *pt0_end, CELL **to_visit, CELL **to_visit_max)
|
Yap_rational_tree_loop(CELL *pt0, CELL *pt0_end, CELL **to_visit, CELL **to_visit_max)
|
||||||
{
|
{
|
||||||
|
|
||||||
CELL ** base = to_visit;
|
CELL ** base = to_visit;
|
||||||
rtree_loop:
|
rtree_loop:
|
||||||
while (pt0 < pt0_end) {
|
while (pt0 < pt0_end) {
|
||||||
@ -114,6 +115,7 @@ cufail:
|
|||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
rational_tree(Term d0) {
|
rational_tree(Term d0) {
|
||||||
|
CACHE_REGS
|
||||||
CELL **to_visit_max = (CELL **)AuxBase, **to_visit = (CELL **)AuxSp;
|
CELL **to_visit_max = (CELL **)AuxBase, **to_visit = (CELL **)AuxSp;
|
||||||
|
|
||||||
if (IsPairTerm(d0)) {
|
if (IsPairTerm(d0)) {
|
||||||
@ -134,6 +136,7 @@ rational_tree(Term d0) {
|
|||||||
static int
|
static int
|
||||||
OCUnify_complex(CELL *pt0, CELL *pt0_end, CELL *pt1)
|
OCUnify_complex(CELL *pt0, CELL *pt0_end, CELL *pt1)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
#undef Yap_REGS
|
#undef Yap_REGS
|
||||||
register REGSTORE *regp = Yap_regp;
|
register REGSTORE *regp = Yap_regp;
|
||||||
@ -339,7 +342,7 @@ cufail:
|
|||||||
static int
|
static int
|
||||||
OCUnify(register CELL d0, register CELL d1)
|
OCUnify(register CELL d0, register CELL d1)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
register CELL *pt0, *pt1;
|
register CELL *pt0, *pt1;
|
||||||
|
|
||||||
#if SHADOW_HB
|
#if SHADOW_HB
|
||||||
@ -451,13 +454,13 @@ oc_unify_var_nvar:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_ocunify(void)
|
p_ocunify( USES_REGS1 )
|
||||||
{
|
{
|
||||||
return(OCUnify(ARG1,ARG2));
|
return(OCUnify(ARG1,ARG2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_cyclic(void)
|
p_cyclic( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
if (IsVarTerm(t))
|
if (IsVarTerm(t))
|
||||||
@ -466,7 +469,7 @@ p_cyclic(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_acyclic(void)
|
p_acyclic( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
if (IsVarTerm(t))
|
if (IsVarTerm(t))
|
||||||
@ -477,6 +480,7 @@ p_acyclic(void)
|
|||||||
int
|
int
|
||||||
Yap_IUnify(register CELL d0, register CELL d1)
|
Yap_IUnify(register CELL d0, register CELL d1)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
#if THREADS
|
#if THREADS
|
||||||
#undef Yap_REGS
|
#undef Yap_REGS
|
||||||
register REGSTORE *regp = Yap_regp;
|
register REGSTORE *regp = Yap_regp;
|
||||||
@ -665,6 +669,7 @@ InitReverseLookupOpcode(void)
|
|||||||
static int
|
static int
|
||||||
unifiable_complex(CELL *pt0, CELL *pt0_end, CELL *pt1)
|
unifiable_complex(CELL *pt0, CELL *pt0_end, CELL *pt1)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
#undef Yap_REGS
|
#undef Yap_REGS
|
||||||
register REGSTORE *regp = Yap_regp;
|
register REGSTORE *regp = Yap_regp;
|
||||||
@ -865,6 +870,7 @@ cufail:
|
|||||||
static int
|
static int
|
||||||
unifiable(CELL d0, CELL d1)
|
unifiable(CELL d0, CELL d1)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
#if THREADS
|
#if THREADS
|
||||||
#undef Yap_REGS
|
#undef Yap_REGS
|
||||||
register REGSTORE *regp = Yap_regp;
|
register REGSTORE *regp = Yap_regp;
|
||||||
@ -985,7 +991,7 @@ unifiable_var_nvar_trail:
|
|||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_unifiable(void)
|
p_unifiable( USES_REGS1 )
|
||||||
{
|
{
|
||||||
tr_fr_ptr trp;
|
tr_fr_ptr trp;
|
||||||
Term tf = TermNil;
|
Term tf = TermNil;
|
||||||
@ -1007,6 +1013,7 @@ p_unifiable(void)
|
|||||||
void
|
void
|
||||||
Yap_InitUnify(void)
|
Yap_InitUnify(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term cm = CurrentModule;
|
Term cm = CurrentModule;
|
||||||
Yap_InitCPred("unify_with_occurs_check", 2, p_ocunify, SafePredFlag);
|
Yap_InitCPred("unify_with_occurs_check", 2, p_ocunify, SafePredFlag);
|
||||||
Yap_InitCPred("acyclic_term", 1, p_acyclic, SafePredFlag|TestPredFlag);
|
Yap_InitCPred("acyclic_term", 1, p_acyclic, SafePredFlag|TestPredFlag);
|
||||||
@ -1030,6 +1037,7 @@ Yap_InitAbsmi(void)
|
|||||||
void
|
void
|
||||||
Yap_TrimTrail(void)
|
Yap_TrimTrail(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
#ifdef saveregs
|
#ifdef saveregs
|
||||||
#undef saveregs
|
#undef saveregs
|
||||||
#define saveregs()
|
#define saveregs()
|
||||||
|
292
C/utilpreds.c
292
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 */
|
wrputn(Int n, wrf writewch) /* writes an integer */
|
||||||
|
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
char s[256], *s1=s; /* that should be enough for most integers */
|
char s[256], *s1=s; /* that should be enough for most integers */
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if (lastw == symbol)
|
if (lastw == symbol)
|
||||||
@ -112,6 +113,7 @@ wrputn(Int n, wrf writewch) /* writes an integer */
|
|||||||
static void
|
static void
|
||||||
wrputs(char *s, wrf writewch) /* writes a string */
|
wrputs(char *s, wrf writewch) /* writes a string */
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
while (*s) {
|
while (*s) {
|
||||||
wrputc((unsigned char)(*s++), writewch);
|
wrputc((unsigned char)(*s++), writewch);
|
||||||
}
|
}
|
||||||
@ -120,6 +122,7 @@ wrputs(char *s, wrf writewch) /* writes a string */
|
|||||||
static void
|
static void
|
||||||
wrputws(wchar_t *s, wrf writewch) /* writes a string */
|
wrputws(wchar_t *s, wrf writewch) /* writes a string */
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
while (*s)
|
while (*s)
|
||||||
wrputc(*s++, writewch);
|
wrputc(*s++, writewch);
|
||||||
}
|
}
|
||||||
@ -128,6 +131,7 @@ wrputws(wchar_t *s, wrf writewch) /* writes a string */
|
|||||||
|
|
||||||
static char *
|
static char *
|
||||||
ensure_space(size_t sz) {
|
ensure_space(size_t sz) {
|
||||||
|
CACHE_REGS
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
s = (char *) Yap_PreAllocCodeSpace();
|
s = (char *) Yap_PreAllocCodeSpace();
|
||||||
@ -165,6 +169,7 @@ ensure_space(size_t sz) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
write_mpint(MP_INT *big, wrf writewch) {
|
write_mpint(MP_INT *big, wrf writewch) {
|
||||||
|
CACHE_REGS
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
s = ensure_space(3+mpz_sizeinbase(big, 10));
|
s = ensure_space(3+mpz_sizeinbase(big, 10));
|
||||||
@ -212,6 +217,7 @@ static void
|
|||||||
wrputf(Float f, wrf writewch) /* writes a float */
|
wrputf(Float f, wrf writewch) /* writes a float */
|
||||||
|
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
char s[256], *pt = s, ch;
|
char s[256], *pt = s, ch;
|
||||||
int found_dot = FALSE, found_exp = FALSE;
|
int found_dot = FALSE, found_exp = FALSE;
|
||||||
|
|
||||||
@ -341,6 +347,7 @@ AtomIsSymbols(unsigned char *s) /* Is this atom just formed by symbols ? */
|
|||||||
static void
|
static void
|
||||||
write_quoted(int ch, int quote, wrf writewch)
|
write_quoted(int ch, int quote, wrf writewch)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (yap_flags[CHARACTER_ESCAPE_FLAG] == CPROLOG_CHARACTER_ESCAPES) {
|
if (yap_flags[CHARACTER_ESCAPE_FLAG] == CPROLOG_CHARACTER_ESCAPES) {
|
||||||
wrputc(ch, writewch);
|
wrputc(ch, writewch);
|
||||||
if (ch == '\'')
|
if (ch == '\'')
|
||||||
@ -409,6 +416,7 @@ static void
|
|||||||
putAtom(Atom atom, int Quote_illegal, wrf writewch) /* writes an atom */
|
putAtom(Atom atom, int Quote_illegal, wrf writewch) /* writes an atom */
|
||||||
|
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
unsigned char *s = (unsigned char *)RepAtom(atom)->StrOfAE;
|
unsigned char *s = (unsigned char *)RepAtom(atom)->StrOfAE;
|
||||||
wtype atom_or_symbol = AtomIsSymbols(s);
|
wtype atom_or_symbol = AtomIsSymbols(s);
|
||||||
|
|
||||||
@ -481,6 +489,7 @@ static void
|
|||||||
putString(Term string, wrf writewch) /* writes a string */
|
putString(Term string, wrf writewch) /* writes a string */
|
||||||
|
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
wrputc('"', writewch);
|
wrputc('"', writewch);
|
||||||
while (string != TermNil) {
|
while (string != TermNil) {
|
||||||
int ch = IntOfTerm(HeadOfTerm(string));
|
int ch = IntOfTerm(HeadOfTerm(string));
|
||||||
@ -495,6 +504,7 @@ static void
|
|||||||
putUnquotedString(Term string, wrf writewch) /* writes a string */
|
putUnquotedString(Term string, wrf writewch) /* writes a string */
|
||||||
|
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
while (string != TermNil) {
|
while (string != TermNil) {
|
||||||
int ch = IntOfTerm(HeadOfTerm(string));
|
int ch = IntOfTerm(HeadOfTerm(string));
|
||||||
wrputc(ch, writewch);
|
wrputc(ch, writewch);
|
||||||
@ -507,6 +517,7 @@ putUnquotedString(Term string, wrf writewch) /* writes a string */
|
|||||||
static void
|
static void
|
||||||
write_var(CELL *t, struct write_globs *wglb, struct rewind_term *rwt)
|
write_var(CELL *t, struct write_globs *wglb, struct rewind_term *rwt)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (lastw == alphanum) {
|
if (lastw == alphanum) {
|
||||||
wrputc(' ', wglb->writewch);
|
wrputc(' ', wglb->writewch);
|
||||||
}
|
}
|
||||||
@ -531,14 +542,14 @@ write_var(CELL *t, struct write_globs *wglb, struct rewind_term *rwt)
|
|||||||
wrputc(',', wglb->writewch);
|
wrputc(',', wglb->writewch);
|
||||||
if (wglb->keep_terms) {
|
if (wglb->keep_terms) {
|
||||||
/* garbage collection may be called */
|
/* 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);
|
writeTerm((Term)&(attv->Value), 999, 1, FALSE, wglb, rwt);
|
||||||
wrputc(',', wglb->writewch);
|
wrputc(',', wglb->writewch);
|
||||||
writeTerm(l, 999, 1, FALSE, wglb, rwt);
|
writeTerm(l, 999, 1, FALSE, wglb, rwt);
|
||||||
if (wglb->keep_terms) {
|
if (wglb->keep_terms) {
|
||||||
attv = (attvar_record *)Yap_GetFromSlot(sl);
|
attv = (attvar_record *)Yap_GetFromSlot(sl PASS_REGS);
|
||||||
Yap_RecoverSlots(1);
|
Yap_RecoverSlots(1 PASS_REGS);
|
||||||
}
|
}
|
||||||
wrputc(')', wglb->writewch);
|
wrputc(')', wglb->writewch);
|
||||||
}
|
}
|
||||||
@ -557,6 +568,7 @@ write_var(CELL *t, struct write_globs *wglb, struct rewind_term *rwt)
|
|||||||
static Term
|
static Term
|
||||||
from_pointer(CELL *ptr, struct rewind_term *rwt, struct write_globs *wglb)
|
from_pointer(CELL *ptr, struct rewind_term *rwt, struct write_globs *wglb)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term t;
|
Term t;
|
||||||
|
|
||||||
while (IsVarTerm(*ptr) && !IsUnboundVar(ptr))
|
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)) {
|
if (!IsVarTerm(t) && !IsAtomOrIntTerm(t)) {
|
||||||
struct rewind_term *x = rwt->parent;
|
struct rewind_term *x = rwt->parent;
|
||||||
if (wglb->keep_terms) {
|
if (wglb->keep_terms) {
|
||||||
rwt->u.s.old = Yap_InitSlot(t);
|
rwt->u.s.old = Yap_InitSlot(t PASS_REGS);
|
||||||
rwt->u.s.ptr = Yap_InitSlot((CELL)ptr);
|
rwt->u.s.ptr = Yap_InitSlot((CELL)ptr PASS_REGS);
|
||||||
while (x) {
|
while (x) {
|
||||||
if (Yap_GetFromSlot(x->u.s.old) == t)
|
if (Yap_GetFromSlot(x->u.s.old PASS_REGS) == t)
|
||||||
return TermFoundVar;
|
return TermFoundVar;
|
||||||
x = x->parent;
|
x = x->parent;
|
||||||
}
|
}
|
||||||
@ -590,9 +602,10 @@ from_pointer(CELL *ptr, struct rewind_term *rwt, struct write_globs *wglb)
|
|||||||
static Term
|
static Term
|
||||||
check_infinite_loop(Term t, struct rewind_term *x, struct write_globs *wglb)
|
check_infinite_loop(Term t, struct rewind_term *x, struct write_globs *wglb)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (wglb->keep_terms) {
|
if (wglb->keep_terms) {
|
||||||
while (x) {
|
while (x) {
|
||||||
if (Yap_GetFromSlot(x->u.s.old) == t)
|
if (Yap_GetFromSlot(x->u.s.old PASS_REGS) == t)
|
||||||
return TermFoundVar;
|
return TermFoundVar;
|
||||||
x = x->parent;
|
x = x->parent;
|
||||||
}
|
}
|
||||||
@ -609,13 +622,14 @@ check_infinite_loop(Term t, struct rewind_term *x, struct write_globs *wglb)
|
|||||||
static void
|
static void
|
||||||
restore_from_write(struct rewind_term *rwt, struct write_globs *wglb)
|
restore_from_write(struct rewind_term *rwt, struct write_globs *wglb)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term t;
|
Term t;
|
||||||
if (rwt->u.s.ptr) {
|
if (rwt->u.s.ptr) {
|
||||||
CELL *ptr;
|
CELL *ptr;
|
||||||
if (wglb->keep_terms) {
|
if (wglb->keep_terms) {
|
||||||
ptr = (CELL *)Yap_GetPtrFromSlot(rwt->u.s.ptr);
|
ptr = (CELL *)Yap_GetPtrFromSlot(rwt->u.s.ptr PASS_REGS);
|
||||||
t = Yap_GetPtrFromSlot(rwt->u.s.old);
|
t = Yap_GetPtrFromSlot(rwt->u.s.old PASS_REGS);
|
||||||
Yap_RecoverSlots(2);
|
Yap_RecoverSlots(2 PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
ptr = rwt->u.d.ptr;
|
ptr = rwt->u.d.ptr;
|
||||||
t = rwt->u.d.old;
|
t = rwt->u.d.old;
|
||||||
@ -627,6 +641,7 @@ restore_from_write(struct rewind_term *rwt, struct write_globs *wglb)
|
|||||||
static void
|
static void
|
||||||
write_list(Term t, int direction, int depth, struct write_globs *wglb, struct rewind_term *rwt)
|
write_list(Term t, int direction, int depth, struct write_globs *wglb, struct rewind_term *rwt)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term ti;
|
Term ti;
|
||||||
struct rewind_term nrwt;
|
struct rewind_term nrwt;
|
||||||
nrwt.parent = rwt;
|
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) {
|
if (wglb->keep_terms) {
|
||||||
/* garbage collection may be called */
|
/* 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);
|
writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth+1, FALSE, wglb, &nrwt);
|
||||||
restore_from_write(&nrwt, wglb);
|
restore_from_write(&nrwt, wglb);
|
||||||
if (wglb->keep_terms) {
|
if (wglb->keep_terms) {
|
||||||
t = Yap_GetFromSlot(sl);
|
t = Yap_GetFromSlot(sl PASS_REGS);
|
||||||
Yap_RecoverSlots(1);
|
Yap_RecoverSlots(1 PASS_REGS);
|
||||||
}
|
}
|
||||||
ti = TailOfTerm(t);
|
ti = TailOfTerm(t);
|
||||||
if (IsVarTerm(ti))
|
if (IsVarTerm(ti))
|
||||||
@ -704,6 +719,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
|||||||
/* context priority */
|
/* context priority */
|
||||||
|
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
struct rewind_term nrwt;
|
struct rewind_term nrwt;
|
||||||
nrwt.parent = rwt;
|
nrwt.parent = rwt;
|
||||||
nrwt.u.s.ptr = 0;
|
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;
|
targs[0] = t;
|
||||||
Yap_PutValue(AtomPortray, MkAtomTerm(AtomNil));
|
Yap_PutValue(AtomPortray, MkAtomTerm(AtomNil));
|
||||||
if (EX) old_EX = EX;
|
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);
|
Yap_execute_goal(Yap_MkApplTerm(FunctorPortray, 1, targs), 0, 1);
|
||||||
t = Yap_GetFromSlot(sl);
|
t = Yap_GetFromSlot(sl PASS_REGS);
|
||||||
Yap_RecoverSlots(1);
|
Yap_RecoverSlots(1 PASS_REGS);
|
||||||
if (old_EX != NULL) EX = old_EX;
|
if (old_EX != NULL) EX = old_EX;
|
||||||
if (Yap_GetValue(AtomPortray) == MkAtomTerm(AtomTrue))
|
if (Yap_GetValue(AtomPortray) == MkAtomTerm(AtomTrue))
|
||||||
return;
|
return;
|
||||||
@ -821,10 +837,10 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
|||||||
targs[0] = t;
|
targs[0] = t;
|
||||||
Yap_PutValue(AtomPortray, MkAtomTerm(AtomNil));
|
Yap_PutValue(AtomPortray, MkAtomTerm(AtomNil));
|
||||||
if (EX) old_EX = EX;
|
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);
|
Yap_execute_goal(Yap_MkApplTerm(FunctorPortray, 1, targs),0, 1);
|
||||||
t = Yap_GetFromSlot(sl);
|
t = Yap_GetFromSlot(sl PASS_REGS);
|
||||||
Yap_RecoverSlots(1);
|
Yap_RecoverSlots(1 PASS_REGS);
|
||||||
if (old_EX) EX = old_EX;
|
if (old_EX) EX = old_EX;
|
||||||
if (Yap_GetValue(AtomPortray) == MkAtomTerm(AtomTrue) || EX)
|
if (Yap_GetValue(AtomPortray) == MkAtomTerm(AtomTrue) || EX)
|
||||||
return;
|
return;
|
||||||
@ -887,14 +903,14 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
|||||||
}
|
}
|
||||||
if (wglb->keep_terms) {
|
if (wglb->keep_terms) {
|
||||||
/* garbage collection may be called */
|
/* 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);
|
writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), lp, depth + 1, rinfixarg, wglb, &nrwt);
|
||||||
restore_from_write(&nrwt, wglb);
|
restore_from_write(&nrwt, wglb);
|
||||||
if (wglb->keep_terms) {
|
if (wglb->keep_terms) {
|
||||||
/* garbage collection may be called */
|
/* garbage collection may be called */
|
||||||
t = Yap_GetFromSlot(sl);
|
t = Yap_GetFromSlot(sl PASS_REGS);
|
||||||
Yap_RecoverSlots(1);
|
Yap_RecoverSlots(1 PASS_REGS);
|
||||||
}
|
}
|
||||||
if (bracket_left) {
|
if (bracket_left) {
|
||||||
wrputc(')', wglb->writewch);
|
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) {
|
if (wglb->keep_terms) {
|
||||||
/* garbage collection may be called */
|
/* 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);
|
writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), lp, depth + 1, rinfixarg, wglb, &nrwt);
|
||||||
restore_from_write(&nrwt, wglb);
|
restore_from_write(&nrwt, wglb);
|
||||||
if (wglb->keep_terms) {
|
if (wglb->keep_terms) {
|
||||||
/* garbage collection may be called */
|
/* garbage collection may be called */
|
||||||
t = Yap_GetFromSlot(sl);
|
t = Yap_GetFromSlot(sl PASS_REGS);
|
||||||
Yap_RecoverSlots(1);
|
Yap_RecoverSlots(1 PASS_REGS);
|
||||||
}
|
}
|
||||||
if (bracket_left) {
|
if (bracket_left) {
|
||||||
wrputc(')', wglb->writewch);
|
wrputc(')', wglb->writewch);
|
||||||
@ -996,14 +1012,14 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
|||||||
lastw = separator;
|
lastw = separator;
|
||||||
if (wglb->keep_terms) {
|
if (wglb->keep_terms) {
|
||||||
/* garbage collection may be called */
|
/* 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);
|
writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||||
restore_from_write(&nrwt, wglb);
|
restore_from_write(&nrwt, wglb);
|
||||||
if (wglb->keep_terms) {
|
if (wglb->keep_terms) {
|
||||||
/* garbage collection may be called */
|
/* garbage collection may be called */
|
||||||
t = Yap_GetFromSlot(sl);
|
t = Yap_GetFromSlot(sl PASS_REGS);
|
||||||
Yap_RecoverSlots(1);
|
Yap_RecoverSlots(1 PASS_REGS);
|
||||||
}
|
}
|
||||||
wrputc(')', wglb->writewch);
|
wrputc(')', wglb->writewch);
|
||||||
lastw = separator;
|
lastw = separator;
|
||||||
@ -1029,14 +1045,14 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
|||||||
}
|
}
|
||||||
if (wglb->keep_terms) {
|
if (wglb->keep_terms) {
|
||||||
/* garbage collection may be called */
|
/* 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);
|
writeTerm(from_pointer(RepAppl(t)+op, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||||
restore_from_write(&nrwt, wglb);
|
restore_from_write(&nrwt, wglb);
|
||||||
if (wglb->keep_terms) {
|
if (wglb->keep_terms) {
|
||||||
/* garbage collection may be called */
|
/* garbage collection may be called */
|
||||||
t = Yap_GetFromSlot(sl);
|
t = Yap_GetFromSlot(sl PASS_REGS);
|
||||||
Yap_RecoverSlots(1);
|
Yap_RecoverSlots(1 PASS_REGS);
|
||||||
}
|
}
|
||||||
if (op != Arity) {
|
if (op != Arity) {
|
||||||
wrputc(',', wglb->writewch);
|
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) {
|
if (wglb->keep_terms) {
|
||||||
/* garbage collection may be called */
|
/* 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);
|
writeTerm(from_pointer(RepAppl(t)+op, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||||
restore_from_write(&nrwt, wglb);
|
restore_from_write(&nrwt, wglb);
|
||||||
if (wglb->keep_terms) {
|
if (wglb->keep_terms) {
|
||||||
/* garbage collection may be called */
|
/* garbage collection may be called */
|
||||||
t = Yap_GetFromSlot(sl);
|
t = Yap_GetFromSlot(sl PASS_REGS);
|
||||||
Yap_RecoverSlots(1);
|
Yap_RecoverSlots(1 PASS_REGS);
|
||||||
}
|
}
|
||||||
if (op != Arity) {
|
if (op != Arity) {
|
||||||
wrputc(',', wglb->writewch);
|
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 restore_B(void);
|
||||||
EXTERN void save_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_;
|
Int CurSlot_;
|
||||||
CELL CreepFlag_; /* 13 */
|
CELL CreepFlag_; /* 13 */
|
||||||
@ -171,16 +178,19 @@ extern Term Yap_XREGS[MaxTemps]; /* 29 */
|
|||||||
|
|
||||||
extern pthread_key_t Yap_yaamregs_key;
|
extern pthread_key_t Yap_yaamregs_key;
|
||||||
|
|
||||||
#if CACHE_REGS
|
#undef CACHE_REGS
|
||||||
|
#undef INIT_REGS
|
||||||
#define ENTER_FUNC REGSTORE *regcache = ((REGSTORE *)pthread_getspecific(Yap_yaamregs_key))
|
#undef PASS_REGS
|
||||||
#define Yap_regp ->((REGSTORE *)pthread_getspecific(Yap_yaamregs_key))
|
#undef PASS_REGS1
|
||||||
|
#undef USES_REGS
|
||||||
#else
|
#undef USES_REGS1
|
||||||
|
#define CACHE_REGS REGSTORE *regcache = ((REGSTORE *)pthread_getspecific(Yap_yaamregs_key));
|
||||||
#define Yap_regp ((REGSTORE *)pthread_getspecific(Yap_yaamregs_key))
|
#define INIT_REGS , ((REGSTORE *)pthread_getspecific(Yap_yaamregs_key))
|
||||||
|
#define PASS_REGS1 regcache
|
||||||
#endif
|
#define PASS_REGS , regcache
|
||||||
|
#define USES_REGS1 struct regstore_t *regcache
|
||||||
|
#define USES_REGS , struct regstore_t *regcache
|
||||||
|
#define Yap_regp regcache
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -701,6 +711,7 @@ extern REGSTORE Yap_standard_regs;
|
|||||||
static inline UInt
|
static inline UInt
|
||||||
CalculateStackGap(void)
|
CalculateStackGap(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
UInt gmin = (LCL0-H0)>>2;
|
UInt gmin = (LCL0-H0)>>2;
|
||||||
|
|
||||||
if (gmin < MinStackGap) gmin = MinStackGap;
|
if (gmin < MinStackGap) gmin = MinStackGap;
|
||||||
|
@ -63,6 +63,7 @@ inline EXTERN int IsAttVar (CELL *pt);
|
|||||||
inline EXTERN int
|
inline EXTERN int
|
||||||
IsAttVar (CELL *pt)
|
IsAttVar (CELL *pt)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
return (pt)[-1] == (CELL)attvar_e && pt < H;
|
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
|
/* what to do when someone tries to bind our term to someone else
|
||||||
in some predefined context */
|
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 */
|
/* 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 */
|
/* copy the constraint into a term and back */
|
||||||
Term (*to_term_op) (CELL *);
|
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 */
|
/* op called to do marking in GC */
|
||||||
void (*mark_op) (CELL *);
|
void (*mark_op) (CELL *);
|
||||||
} ext_op;
|
} ext_op;
|
||||||
@ -166,6 +167,7 @@ inline EXTERN Term MkFloatTerm (Float);
|
|||||||
inline EXTERN Term
|
inline EXTERN Term
|
||||||
MkFloatTerm (Float dbl)
|
MkFloatTerm (Float dbl)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
return (Term) ((H[0] = (CELL) FunctorDouble, *(Float *) (H + 1) =
|
return (Term) ((H[0] = (CELL) FunctorDouble, *(Float *) (H + 1) =
|
||||||
dbl, H[2] = EndSpecials, H +=
|
dbl, H[2] = EndSpecials, H +=
|
||||||
3, AbsAppl (H - 3)));
|
3, AbsAppl (H - 3)));
|
||||||
@ -271,6 +273,7 @@ inline EXTERN Term MkLongIntTerm (Int);
|
|||||||
inline EXTERN Term
|
inline EXTERN Term
|
||||||
MkLongIntTerm (Int i)
|
MkLongIntTerm (Int i)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
H[0] = (CELL) FunctorLongInt;
|
H[0] = (CELL) FunctorLongInt;
|
||||||
H[1] = (CELL) (i);
|
H[1] = (CELL) (i);
|
||||||
H[2] = EndSpecials;
|
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;
|
extern int Yap_output_msg;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define MkVarTerm() MkVarTerm__( PASS_REGS1 )
|
||||||
|
#define MkPairTerm(A,B) MkPairTerm__( A, B PASS_REGS )
|
||||||
|
|
||||||
/* applies to unbound variables */
|
/* applies to unbound variables */
|
||||||
|
|
||||||
@ -829,10 +831,10 @@ VarOfTerm (Term t)
|
|||||||
|
|
||||||
#ifdef SBA
|
#ifdef SBA
|
||||||
|
|
||||||
inline EXTERN Term MkVarTerm (void);
|
inline EXTERN Term MkVarTerm__ ( USES_REGS1 );
|
||||||
|
|
||||||
inline EXTERN Term
|
inline EXTERN Term
|
||||||
MkVarTerm ()
|
MkVarTerm__ ( USES_REGS1 )
|
||||||
{
|
{
|
||||||
return (Term) ((*H = 0, H++));
|
return (Term) ((*H = 0, H++));
|
||||||
}
|
}
|
||||||
@ -850,10 +852,10 @@ IsUnboundVar (Term * t)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
inline EXTERN Term MkVarTerm (void);
|
inline EXTERN Term MkVarTerm__ ( USES_REGS1 );
|
||||||
|
|
||||||
inline EXTERN Term
|
inline EXTERN Term
|
||||||
MkVarTerm ()
|
MkVarTerm__ ( USES_REGS1 )
|
||||||
{
|
{
|
||||||
return (Term) ((*H = (CELL) H, H++));
|
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
|
EXTERN inline Term
|
||||||
MkPairTerm (Term head, Term tail)
|
MkPairTerm__ (Term head, Term tail USES_REGS)
|
||||||
{
|
{
|
||||||
register CELL *p = H;
|
register CELL *p = H;
|
||||||
|
|
||||||
@ -1321,14 +1323,14 @@ typedef enum
|
|||||||
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
Yap_StartSlots(void) {
|
Yap_StartSlots( USES_REGS1 ) {
|
||||||
*--ASP = MkIntegerTerm(CurSlot);
|
*--ASP = MkIntegerTerm(CurSlot);
|
||||||
*--ASP = MkIntTerm(0);
|
*--ASP = MkIntTerm(0);
|
||||||
CurSlot = LCL0-ASP;
|
CurSlot = LCL0-ASP;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
Yap_CloseSlots(void) {
|
Yap_CloseSlots( USES_REGS1 ) {
|
||||||
Int old_slots;
|
Int old_slots;
|
||||||
old_slots = IntOfTerm(ASP[0]);
|
old_slots = IntOfTerm(ASP[0]);
|
||||||
ASP += (old_slots+1);
|
ASP += (old_slots+1);
|
||||||
@ -1337,7 +1339,7 @@ Yap_CloseSlots(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline Int
|
static inline Int
|
||||||
Yap_CurrentSlot(void) {
|
Yap_CurrentSlot( USES_REGS1 ) {
|
||||||
return IntOfTerm(ASP[0]);
|
return IntOfTerm(ASP[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,6 +236,7 @@ ADDR STD_PROTO(Yap_InitPreAllocCodeSpace, (void));
|
|||||||
EXTERN inline ADDR
|
EXTERN inline ADDR
|
||||||
Yap_PreAllocCodeSpace(void)
|
Yap_PreAllocCodeSpace(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
return AuxBase;
|
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_NStringToList,(char *, size_t));
|
||||||
Term STD_PROTO(Yap_WideStringToList,(wchar_t *));
|
Term STD_PROTO(Yap_WideStringToList,(wchar_t *));
|
||||||
Term STD_PROTO(Yap_NWideStringToList,(wchar_t *, size_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_NStringToDiffList,(char *,Term, size_t));
|
||||||
Term STD_PROTO(Yap_WideStringToDiffList,(wchar_t *,Term));
|
Term STD_PROTO(Yap_WideStringToDiffList,(wchar_t *,Term));
|
||||||
Term STD_PROTO(Yap_NWideStringToDiffList,(wchar_t *,Term, size_t));
|
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_AtomIncreaseHold,(Atom));
|
||||||
int STD_PROTO(Yap_AtomDecreaseHold,(Atom));
|
int STD_PROTO(Yap_AtomDecreaseHold,(Atom));
|
||||||
|
|
||||||
Int STD_PROTO(Yap_InitSlot,(Term));
|
Int STD_PROTO(Yap_InitSlot,(Term CACHE_TYPE));
|
||||||
Int STD_PROTO(Yap_NewSlots,(int));
|
Int STD_PROTO(Yap_NewSlots,(int CACHE_TYPE));
|
||||||
Term STD_PROTO(Yap_GetFromSlot,(Int));
|
Term STD_PROTO(Yap_GetFromSlot,(Int CACHE_TYPE));
|
||||||
int STD_PROTO(Yap_RecoverSlots,(int));
|
int STD_PROTO(Yap_RecoverSlots,(int CACHE_TYPE));
|
||||||
Term STD_PROTO(Yap_GetPtrFromSlot,(Int));
|
Term STD_PROTO(Yap_GetPtrFromSlot,(Int CACHE_TYPE));
|
||||||
Term *STD_PROTO(Yap_AddressFromSlot,(Int));
|
Term *STD_PROTO(Yap_AddressFromSlot,(Int CACHE_TYPE));
|
||||||
void STD_PROTO(Yap_PutInSlot,(Int, Term));
|
void STD_PROTO(Yap_PutInSlot,(Int, Term CACHE_TYPE));
|
||||||
|
|
||||||
|
|
||||||
#ifdef SFUNC
|
#ifdef SFUNC
|
||||||
@ -82,7 +82,7 @@ Prop STD_PROTO(Yap_GetExpProp,(Atom,unsigned int));
|
|||||||
Prop STD_PROTO(Yap_GetExpPropHavingLock,(AtomEntry *,unsigned int));
|
Prop STD_PROTO(Yap_GetExpPropHavingLock,(AtomEntry *,unsigned int));
|
||||||
|
|
||||||
/* agc.c */
|
/* agc.c */
|
||||||
void STD_PROTO(Yap_atom_gc, (void));
|
void STD_PROTO(Yap_atom_gc, (CACHE_TYPE1));
|
||||||
void STD_PROTO(Yap_init_agc, (void));
|
void STD_PROTO(Yap_init_agc, (void));
|
||||||
|
|
||||||
/* alloc.c */
|
/* alloc.c */
|
||||||
|
16
H/Yatom.h
16
H/Yatom.h
@ -487,7 +487,7 @@ typedef enum
|
|||||||
} op_type;
|
} 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_IsPrefixOp,(Atom,int *,int *));
|
||||||
int STD_PROTO(Yap_IsOp,(Atom));
|
int STD_PROTO(Yap_IsOp,(Atom));
|
||||||
@ -1482,12 +1482,12 @@ EXTERN inline Prop STD_PROTO(GetPredPropByFuncHavingLock, (FunctorEntry *, Term)
|
|||||||
|
|
||||||
#ifdef THREADS
|
#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));
|
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 *
|
EXTERN inline struct pred_entry *
|
||||||
Yap_GetThreadPred(struct pred_entry *ap)
|
Yap_GetThreadPred(struct pred_entry *ap USES_REGS)
|
||||||
{
|
{
|
||||||
Functor f = ap->FunctorOfPred;
|
Functor f = ap->FunctorOfPred;
|
||||||
Term mod = ap->ModuleOfPred;
|
Term mod = ap->ModuleOfPred;
|
||||||
@ -1499,7 +1499,7 @@ Yap_GetThreadPred(struct pred_entry *ap)
|
|||||||
ap->ModuleOfPred == mod) return ap;
|
ap->ModuleOfPred == mod) return ap;
|
||||||
p0 = ap->NextOfPE;
|
p0 = ap->NextOfPE;
|
||||||
}
|
}
|
||||||
return RepPredProp(Yap_NewThreadPred(ap));
|
return RepPredProp(Yap_NewThreadPred(ap PASS_REGS));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1516,7 +1516,7 @@ GetPredPropByFuncHavingLock (FunctorEntry *fe, Term cur_mod)
|
|||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
/* Thread Local Predicates */
|
/* Thread Local Predicates */
|
||||||
if (p->PredFlags & ThreadLocalPredFlag) {
|
if (p->PredFlags & ThreadLocalPredFlag) {
|
||||||
return AbsPredProp (Yap_GetThreadPred (p));
|
return AbsPredProp (Yap_GetThreadPred (p INIT_REGS));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return AbsPredProp(p);
|
return AbsPredProp(p);
|
||||||
@ -1534,7 +1534,7 @@ GetPredPropByFuncHavingLock (FunctorEntry *fe, Term cur_mod)
|
|||||||
/* Thread Local Predicates */
|
/* Thread Local Predicates */
|
||||||
if (p->PredFlags & ThreadLocalPredFlag) {
|
if (p->PredFlags & ThreadLocalPredFlag) {
|
||||||
READ_UNLOCK(PredHashRWLock);
|
READ_UNLOCK(PredHashRWLock);
|
||||||
return AbsPredProp (Yap_GetThreadPred (p));
|
return AbsPredProp (Yap_GetThreadPred (p INIT_REGS));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
READ_UNLOCK(PredHashRWLock);
|
READ_UNLOCK(PredHashRWLock);
|
||||||
@ -1582,7 +1582,7 @@ PredPropByAtom (Atom at, Term cur_mod)
|
|||||||
if (pe->PredFlags & ThreadLocalPredFlag)
|
if (pe->PredFlags & ThreadLocalPredFlag)
|
||||||
{
|
{
|
||||||
WRITE_UNLOCK (ae->ARWLock);
|
WRITE_UNLOCK (ae->ARWLock);
|
||||||
return AbsPredProp (Yap_GetThreadPred (pe));
|
return AbsPredProp (Yap_GetThreadPred (pe INIT_REGS));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
WRITE_UNLOCK (ae->ARWLock);
|
WRITE_UNLOCK (ae->ARWLock);
|
||||||
|
@ -181,12 +181,14 @@ register struct yami* P1REG asm ("bp"); /* can't use yamop before Yap.h */
|
|||||||
inline EXTERN void
|
inline EXTERN void
|
||||||
init_absmi_regs(REGSTORE * absmi_regs)
|
init_absmi_regs(REGSTORE * absmi_regs)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
memcpy(absmi_regs, Yap_regp, sizeof(REGSTORE));
|
memcpy(absmi_regs, Yap_regp, sizeof(REGSTORE));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline EXTERN void
|
inline EXTERN void
|
||||||
restore_absmi_regs(REGSTORE * old_regs)
|
restore_absmi_regs(REGSTORE * old_regs)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
memcpy(old_regs, Yap_regp, sizeof(REGSTORE));
|
memcpy(old_regs, Yap_regp, sizeof(REGSTORE));
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
pthread_setspecific(Yap_yaamregs_key, (void *)old_regs);
|
pthread_setspecific(Yap_yaamregs_key, (void *)old_regs);
|
||||||
@ -1113,6 +1115,7 @@ typedef struct v_record {
|
|||||||
static int
|
static int
|
||||||
IUnify_complex(CELL *pt0, CELL *pt0_end, CELL *pt1)
|
IUnify_complex(CELL *pt0, CELL *pt0_end, CELL *pt1)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
#undef Yap_REGS
|
#undef Yap_REGS
|
||||||
register REGSTORE *regp = Yap_regp;
|
register REGSTORE *regp = Yap_regp;
|
||||||
@ -1310,6 +1313,7 @@ iequ_complex(register CELL *pt0, register CELL *pt0_end,
|
|||||||
register CELL *pt1
|
register CELL *pt1
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
#undef Yap_REGS
|
#undef Yap_REGS
|
||||||
register REGSTORE *regp = Yap_regp;
|
register REGSTORE *regp = Yap_regp;
|
||||||
@ -1551,6 +1555,7 @@ Yap_regtoregno(wamreg reg)
|
|||||||
static inline void
|
static inline void
|
||||||
prune(choiceptr cp)
|
prune(choiceptr cp)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (SHOULD_CUT_UP_TO(B,cp))
|
if (SHOULD_CUT_UP_TO(B,cp))
|
||||||
{
|
{
|
||||||
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
|
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
|
||||||
@ -1582,6 +1587,7 @@ prune(choiceptr cp)
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
void SET_ASP(CELL *yreg, Int sz) {
|
void SET_ASP(CELL *yreg, Int sz) {
|
||||||
|
CACHE_REGS
|
||||||
ASP = (CELL *) (((char *) yreg) + sz);
|
ASP = (CELL *) (((char *) yreg) + sz);
|
||||||
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
|
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
|
||||||
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
|
#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);
|
typedef Int (*CmpPredicate)(Term, Term);
|
||||||
|
|
||||||
|
@ -409,6 +409,7 @@ inline EXTERN void STD_PROTO(reset_trail,(tr_fr_ptr));
|
|||||||
|
|
||||||
inline EXTERN void
|
inline EXTERN void
|
||||||
reset_trail(tr_fr_ptr TR0) {
|
reset_trail(tr_fr_ptr TR0) {
|
||||||
|
CACHE_REGS
|
||||||
while(TR != TR0) {
|
while(TR != TR0) {
|
||||||
CELL d1;
|
CELL d1;
|
||||||
--TR;
|
--TR;
|
||||||
@ -458,6 +459,7 @@ inline EXTERN void close_attvar_chain(CELL *dvarsmin, CELL *dvarsmax);
|
|||||||
|
|
||||||
inline EXTERN void
|
inline EXTERN void
|
||||||
close_attvar_chain(CELL *dvarsmin, CELL *dvarsmax) {
|
close_attvar_chain(CELL *dvarsmin, CELL *dvarsmax) {
|
||||||
|
CACHE_REGS
|
||||||
if (dvarsmin) {
|
if (dvarsmin) {
|
||||||
dvarsmin += 1;
|
dvarsmin += 1;
|
||||||
do {
|
do {
|
||||||
@ -475,6 +477,7 @@ close_attvar_chain(CELL *dvarsmin, CELL *dvarsmax) {
|
|||||||
EXTERN inline
|
EXTERN inline
|
||||||
Int Yap_unify(Term t0, Term t1)
|
Int Yap_unify(Term t0, Term t1)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
tr_fr_ptr TR0 = TR;
|
tr_fr_ptr TR0 = TR;
|
||||||
|
|
||||||
if (Yap_IUnify(t0,t1)) {
|
if (Yap_IUnify(t0,t1)) {
|
||||||
@ -490,6 +493,7 @@ EXTERN Int STD_PROTO(Yap_unify_constant,(Term,Term));
|
|||||||
EXTERN inline Int
|
EXTERN inline Int
|
||||||
Yap_unify_constant(register Term a, register Term cons)
|
Yap_unify_constant(register Term a, register Term cons)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
CELL *pt;
|
CELL *pt;
|
||||||
deref_head(a,unify_cons_unk);
|
deref_head(a,unify_cons_unk);
|
||||||
unify_cons_nonvar:
|
unify_cons_nonvar:
|
||||||
@ -547,6 +551,7 @@ Yap_unify_constant(register Term a, register Term cons)
|
|||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
do_cut(int i) {
|
do_cut(int i) {
|
||||||
|
CACHE_REGS
|
||||||
#ifdef CUT_C
|
#ifdef CUT_C
|
||||||
if (POP_CHOICE_POINT(B->cp_b)) {
|
if (POP_CHOICE_POINT(B->cp_b)) {
|
||||||
cut_c_pop();
|
cut_c_pop();
|
||||||
|
@ -39,9 +39,9 @@ struct cut_c_str{
|
|||||||
cut_c_str_ptr TOP = Yap_REGS.CUT_C_TOP; \
|
cut_c_str_ptr TOP = Yap_REGS.CUT_C_TOP; \
|
||||||
CPredicate func = (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.f; \
|
CPredicate func = (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.f; \
|
||||||
PredEntry *pred = (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.p; \
|
PredEntry *pred = (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.p; \
|
||||||
Yap_StartSlots(); \
|
Yap_StartSlots( PASS_REGS1 ); \
|
||||||
YAP_ExecuteOnCut(pred,func); \
|
YAP_ExecuteOnCut(pred,func); \
|
||||||
Yap_CloseSlots(); \
|
Yap_CloseSlots( PASS_REGS1 ); \
|
||||||
cut_c_pop();
|
cut_c_pop();
|
||||||
|
|
||||||
|
|
||||||
|
1
H/eval.h
1
H/eval.h
@ -189,6 +189,7 @@ Yap_Eval(Term t)
|
|||||||
inline static Term
|
inline static Term
|
||||||
Yap_FoundArithError(Term t, Term inp)
|
Yap_FoundArithError(Term t, Term inp)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (Yap_Error_TYPE) {
|
if (Yap_Error_TYPE) {
|
||||||
Yap_Error(Yap_Error_TYPE, (inp ? inp : Yap_Error_Term), Yap_ErrorMessage);
|
Yap_Error(Yap_Error_TYPE, (inp ? inp : Yap_Error_Term), Yap_ErrorMessage);
|
||||||
P = FAILCODE;
|
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 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
|
static inline Int
|
||||||
MARKED_PTR(CELL* ptr)
|
MARKED_PTR__(CELL* ptr USES_REGS)
|
||||||
{
|
{
|
||||||
return mcell(ptr) & MARK_BIT;
|
return mcell(ptr) & MARK_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Int
|
static inline Int
|
||||||
UNMARKED_MARK(CELL* ptr, char *bp)
|
UNMARKED_MARK__(CELL* ptr, char *bp USES_REGS)
|
||||||
{
|
{
|
||||||
Int pos = ptr - (CELL *)Yap_GlobalBase;
|
Int pos = ptr - (CELL *)Yap_GlobalBase;
|
||||||
char t = bp[pos];
|
char t = bp[pos];
|
||||||
@ -105,13 +113,13 @@ UNMARKED_MARK(CELL* ptr, char *bp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
MARK(CELL* ptr)
|
MARK__(CELL* ptr USES_REGS)
|
||||||
{
|
{
|
||||||
mcell(ptr) = mcell(ptr) | MARK_BIT;
|
mcell(ptr) = mcell(ptr) | MARK_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
UNMARK(CELL* ptr)
|
UNMARK__(CELL* ptr USES_REGS)
|
||||||
{
|
{
|
||||||
mcell(ptr) = mcell(ptr) & ~MARK_BIT;
|
mcell(ptr) = mcell(ptr) & ~MARK_BIT;
|
||||||
}
|
}
|
||||||
@ -122,19 +130,19 @@ UNMARK(CELL* ptr)
|
|||||||
#define UNMARK_CELL(X) (X)
|
#define UNMARK_CELL(X) (X)
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
RMARK(CELL* ptr)
|
RMARK__(CELL* ptr USES_REGS)
|
||||||
{
|
{
|
||||||
mcell(ptr) = mcell(ptr) | RMARK_BIT;
|
mcell(ptr) = mcell(ptr) | RMARK_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
UNRMARK(CELL* ptr)
|
UNRMARK__(CELL* ptr USES_REGS)
|
||||||
{
|
{
|
||||||
mcell(ptr) = mcell(ptr) & ~RMARK_BIT;
|
mcell(ptr) = mcell(ptr) & ~RMARK_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
RMARKED(CELL* ptr)
|
RMARKED__(CELL* ptr USES_REGS)
|
||||||
{
|
{
|
||||||
return mcell(ptr) & RMARK_BIT;
|
return mcell(ptr) & RMARK_BIT;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
restore_opcodes(yamop *pc, yamop *max)
|
restore_opcodes(yamop *pc, yamop *max USES_REGS)
|
||||||
{
|
{
|
||||||
yamop *opc = NULL;
|
yamop *opc = NULL;
|
||||||
do {
|
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 Atomics 0
|
||||||
#define Funcs 1
|
#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
|
static Term
|
||||||
ConstantTermAdjust (Term t)
|
ConstantTermAdjust__ (Term t USES_REGS)
|
||||||
{
|
{
|
||||||
if (IsAtomTerm(t))
|
if (IsAtomTerm(t))
|
||||||
return AtomTermAdjust(t);
|
return AtomTermAdjust(t);
|
||||||
@ -248,7 +256,7 @@ ConstantTermAdjust (Term t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
DBGroundTermAdjust (Term t)
|
DBGroundTermAdjust__ (Term t USES_REGS)
|
||||||
{
|
{
|
||||||
/* The term itself is restored by dbtermlist */
|
/* The term itself is restored by dbtermlist */
|
||||||
if (IsPairTerm(t)) {
|
if (IsPairTerm(t)) {
|
||||||
@ -261,7 +269,7 @@ DBGroundTermAdjust (Term t)
|
|||||||
/* Now, everything on its place so you must adjust the pointers */
|
/* Now, everything on its place so you must adjust the pointers */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_clean_susp_clauses(yamop *ipc) {
|
do_clean_susp_clauses(yamop *ipc USES_REGS) {
|
||||||
COUNT i;
|
COUNT i;
|
||||||
yamop **st = (yamop **)NEXTOP(ipc,sssllp);
|
yamop **st = (yamop **)NEXTOP(ipc,sssllp);
|
||||||
|
|
||||||
@ -281,7 +289,7 @@ do_clean_susp_clauses(yamop *ipc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
AdjustSwitchTable(op_numbers op, yamop *table, COUNT i)
|
AdjustSwitchTable__(op_numbers op, yamop *table, COUNT i USES_REGS)
|
||||||
{
|
{
|
||||||
CELL *startcode = (CELL *)table;
|
CELL *startcode = (CELL *)table;
|
||||||
/* in case the table is already gone */
|
/* 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[1] = (CELL)CodeAddrAdjust(oldjmp);
|
||||||
oldcode += 2;
|
oldcode += 2;
|
||||||
}
|
}
|
||||||
rehash(startcode, i, Funcs);
|
rehash(startcode, i, Funcs PASS_REGS);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case _switch_on_cons:
|
case _switch_on_cons:
|
||||||
@ -324,7 +332,7 @@ AdjustSwitchTable(op_numbers op, yamop *table, COUNT i)
|
|||||||
oldcode += 2;
|
oldcode += 2;
|
||||||
}
|
}
|
||||||
#if !USE_OFFSETS
|
#if !USE_OFFSETS
|
||||||
rehash(startcode, i, Atomics);
|
rehash(startcode, i, Atomics PASS_REGS);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -385,12 +393,12 @@ AdjustSwitchTable(op_numbers op, yamop *table, COUNT i)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC_PROTO(void RestoreAtomList, (Atom));
|
STATIC_PROTO(void RestoreAtomList, (Atom CACHE_TYPE));
|
||||||
STATIC_PROTO(void RestoreAtom, (AtomEntry *));
|
STATIC_PROTO(void RestoreAtom, (AtomEntry * CACHE_TYPE));
|
||||||
STATIC_PROTO(void RestoreHashPreds, (void));
|
STATIC_PROTO(void RestoreHashPreds, ( CACHE_TYPE1 ));
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreAtoms(void)
|
RestoreAtoms( USES_REGS1 )
|
||||||
{
|
{
|
||||||
AtomHashEntry *HashPtr;
|
AtomHashEntry *HashPtr;
|
||||||
register int i;
|
register int i;
|
||||||
@ -400,13 +408,13 @@ RestoreAtoms(void)
|
|||||||
HashPtr = HashChain;
|
HashPtr = HashChain;
|
||||||
for (i = 0; i < AtomHashTableSize; ++i) {
|
for (i = 0; i < AtomHashTableSize; ++i) {
|
||||||
HashPtr->Entry = NoAGCAtomAdjust(HashPtr->Entry);
|
HashPtr->Entry = NoAGCAtomAdjust(HashPtr->Entry);
|
||||||
RestoreAtomList(HashPtr->Entry);
|
RestoreAtomList(HashPtr->Entry PASS_REGS);
|
||||||
HashPtr++;
|
HashPtr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreWideAtoms(void)
|
RestoreWideAtoms( USES_REGS1 )
|
||||||
{
|
{
|
||||||
AtomHashEntry *HashPtr;
|
AtomHashEntry *HashPtr;
|
||||||
register int i;
|
register int i;
|
||||||
@ -416,25 +424,25 @@ RestoreWideAtoms(void)
|
|||||||
HashPtr = WideHashChain;
|
HashPtr = WideHashChain;
|
||||||
for (i = 0; i < WideAtomHashTableSize; ++i) {
|
for (i = 0; i < WideAtomHashTableSize; ++i) {
|
||||||
HashPtr->Entry = AtomAdjust(HashPtr->Entry);
|
HashPtr->Entry = AtomAdjust(HashPtr->Entry);
|
||||||
RestoreAtomList(HashPtr->Entry);
|
RestoreAtomList(HashPtr->Entry PASS_REGS);
|
||||||
HashPtr++;
|
HashPtr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreInvisibleAtoms(void)
|
RestoreInvisibleAtoms( USES_REGS1 )
|
||||||
{
|
{
|
||||||
INVISIBLECHAIN.Entry = AtomAdjust(INVISIBLECHAIN.Entry);
|
INVISIBLECHAIN.Entry = AtomAdjust(INVISIBLECHAIN.Entry);
|
||||||
RestoreAtomList(INVISIBLECHAIN.Entry);
|
RestoreAtomList(INVISIBLECHAIN.Entry PASS_REGS);
|
||||||
RestoreAtom(RepAtom(AtomFoundVar));
|
RestoreAtom(RepAtom(AtomFoundVar) PASS_REGS);
|
||||||
RestoreAtom(RepAtom(AtomFreeTerm));
|
RestoreAtom(RepAtom(AtomFreeTerm) PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "rclause.h"
|
#include "rclause.h"
|
||||||
|
|
||||||
/* adjusts terms stored in the data base, when they have no variables */
|
/* adjusts terms stored in the data base, when they have no variables */
|
||||||
static Term
|
static Term
|
||||||
AdjustDBTerm(Term trm, Term *p_base)
|
AdjustDBTerm__(Term trm, Term *p_base USES_REGS)
|
||||||
{
|
{
|
||||||
if (IsVarTerm(trm))
|
if (IsVarTerm(trm))
|
||||||
return CodeVarAdjust(trm);
|
return CodeVarAdjust(trm);
|
||||||
@ -488,7 +496,7 @@ AdjustDBTerm(Term trm, Term *p_base)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreDBTerm(DBTerm *dbr, int attachments)
|
RestoreDBTerm(DBTerm *dbr, int attachments USES_REGS)
|
||||||
{
|
{
|
||||||
if (attachments) {
|
if (attachments) {
|
||||||
#ifdef COROUTINING
|
#ifdef COROUTINING
|
||||||
@ -515,7 +523,7 @@ RestoreDBTerm(DBTerm *dbr, int attachments)
|
|||||||
|
|
||||||
/* Restores a prolog clause, in its compiled form */
|
/* Restores a prolog clause, in its compiled form */
|
||||||
static void
|
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
|
* Cl points to the start of the code, IsolFlag tells if we have a single
|
||||||
* clause for this predicate or not
|
* clause for this predicate or not
|
||||||
@ -529,12 +537,12 @@ RestoreStaticClause(StaticClause *cl)
|
|||||||
if (cl->ClNext) {
|
if (cl->ClNext) {
|
||||||
cl->ClNext = PtoStCAdjust(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 */
|
/* Restores a prolog clause, in its compiled form */
|
||||||
static void
|
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
|
* Cl points to the start of the code, IsolFlag tells if we have a single
|
||||||
* clause for this predicate or not
|
* clause for this predicate or not
|
||||||
@ -551,14 +559,14 @@ RestoreMegaClause(MegaClause *cl)
|
|||||||
|
|
||||||
for (i = 0, ptr = cl->ClCode; i < ncls; i++) {
|
for (i = 0, ptr = cl->ClCode; i < ncls; i++) {
|
||||||
yamop *nextptr = (yamop *)((char *)ptr + cl->ClItemSize);
|
yamop *nextptr = (yamop *)((char *)ptr + cl->ClItemSize);
|
||||||
restore_opcodes(ptr, nextptr);
|
restore_opcodes(ptr, nextptr PASS_REGS);
|
||||||
ptr = nextptr;
|
ptr = nextptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Restores a prolog clause, in its compiled form */
|
/* Restores a prolog clause, in its compiled form */
|
||||||
static void
|
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
|
* Cl points to the start of the code, IsolFlag tells if we have a single
|
||||||
* clause for this predicate or not
|
* clause for this predicate or not
|
||||||
@ -568,12 +576,12 @@ RestoreDynamicClause(DynamicClause *cl, PredEntry *pp)
|
|||||||
cl->ClPrevious = PtoOpAdjust(cl->ClPrevious);
|
cl->ClPrevious = PtoOpAdjust(cl->ClPrevious);
|
||||||
}
|
}
|
||||||
INIT_LOCK(cl->ClLock);
|
INIT_LOCK(cl->ClLock);
|
||||||
restore_opcodes(cl->ClCode, NULL);
|
restore_opcodes(cl->ClCode, NULL PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Restores a prolog clause, in its compiled form */
|
/* Restores a prolog clause, in its compiled form */
|
||||||
static void
|
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
|
* Cl points to the start of the code, IsolFlag tells if we have a single
|
||||||
* clause for this predicate or not
|
* clause for this predicate or not
|
||||||
@ -585,7 +593,7 @@ RestoreLUClause(LogUpdClause *cl, PredEntry *pp)
|
|||||||
}
|
}
|
||||||
if (cl->ClSource) {
|
if (cl->ClSource) {
|
||||||
cl->ClSource = DBTermAdjust(cl->ClSource);
|
cl->ClSource = DBTermAdjust(cl->ClSource);
|
||||||
RestoreDBTerm(cl->ClSource, TRUE);
|
RestoreDBTerm(cl->ClSource, TRUE PASS_REGS);
|
||||||
}
|
}
|
||||||
if (cl->ClPrev) {
|
if (cl->ClPrev) {
|
||||||
cl->ClPrev = PtoLUCAdjust(cl->ClPrev);
|
cl->ClPrev = PtoLUCAdjust(cl->ClPrev);
|
||||||
@ -594,11 +602,11 @@ RestoreLUClause(LogUpdClause *cl, PredEntry *pp)
|
|||||||
cl->ClNext = PtoLUCAdjust(cl->ClNext);
|
cl->ClNext = PtoLUCAdjust(cl->ClNext);
|
||||||
}
|
}
|
||||||
cl->ClPred = PtoPredAdjust(cl->ClPred);
|
cl->ClPred = PtoPredAdjust(cl->ClPred);
|
||||||
restore_opcodes(cl->ClCode, NULL);
|
restore_opcodes(cl->ClCode, NULL PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreDBTermEntry(struct dbterm_list *dbl) {
|
RestoreDBTermEntry(struct dbterm_list *dbl USES_REGS) {
|
||||||
DBTerm *dbt;
|
DBTerm *dbt;
|
||||||
|
|
||||||
if (dbl->dbterms)
|
if (dbl->dbterms)
|
||||||
@ -610,13 +618,13 @@ RestoreDBTermEntry(struct dbterm_list *dbl) {
|
|||||||
dbl->next_dbl = PtoDBTLAdjust(dbl->next_dbl);
|
dbl->next_dbl = PtoDBTLAdjust(dbl->next_dbl);
|
||||||
dbl->p = PredEntryAdjust(dbl->p);
|
dbl->p = PredEntryAdjust(dbl->p);
|
||||||
while (dbt) {
|
while (dbt) {
|
||||||
RestoreDBTerm(dbt, FALSE);
|
RestoreDBTerm(dbt, FALSE PASS_REGS);
|
||||||
dbt = dbt->ag.NextDBT;
|
dbt = dbt->ag.NextDBT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CleanLUIndex(LogUpdIndex *idx, int recurse)
|
CleanLUIndex(LogUpdIndex *idx, int recurse USES_REGS)
|
||||||
{
|
{
|
||||||
// INIT_LOCK(idx->ClLock);
|
// INIT_LOCK(idx->ClLock);
|
||||||
idx->ClPred = PtoPredAdjust(idx->ClPred);
|
idx->ClPred = PtoPredAdjust(idx->ClPred);
|
||||||
@ -628,30 +636,30 @@ CleanLUIndex(LogUpdIndex *idx, int recurse)
|
|||||||
if (idx->SiblingIndex) {
|
if (idx->SiblingIndex) {
|
||||||
idx->SiblingIndex = LUIndexAdjust(idx->SiblingIndex);
|
idx->SiblingIndex = LUIndexAdjust(idx->SiblingIndex);
|
||||||
if (recurse)
|
if (recurse)
|
||||||
CleanLUIndex(idx->SiblingIndex, TRUE);
|
CleanLUIndex(idx->SiblingIndex, TRUE PASS_REGS);
|
||||||
}
|
}
|
||||||
if (idx->ChildIndex) {
|
if (idx->ChildIndex) {
|
||||||
idx->ChildIndex = LUIndexAdjust(idx->ChildIndex);
|
idx->ChildIndex = LUIndexAdjust(idx->ChildIndex);
|
||||||
if (recurse)
|
if (recurse)
|
||||||
CleanLUIndex(idx->ChildIndex, TRUE);
|
CleanLUIndex(idx->ChildIndex, TRUE PASS_REGS);
|
||||||
}
|
}
|
||||||
if (!(idx->ClFlags & SwitchTableMask)) {
|
if (!(idx->ClFlags & SwitchTableMask)) {
|
||||||
restore_opcodes(idx->ClCode, NULL);
|
restore_opcodes(idx->ClCode, NULL PASS_REGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CleanSIndex(StaticIndex *idx, int recurse)
|
CleanSIndex(StaticIndex *idx, int recurse USES_REGS)
|
||||||
{
|
{
|
||||||
beginning:
|
beginning:
|
||||||
if (!(idx->ClFlags & SwitchTableMask)) {
|
if (!(idx->ClFlags & SwitchTableMask)) {
|
||||||
restore_opcodes(idx->ClCode, NULL);
|
restore_opcodes(idx->ClCode, NULL PASS_REGS);
|
||||||
}
|
}
|
||||||
idx->ClPred = PtoPredAdjust(idx->ClPred);
|
idx->ClPred = PtoPredAdjust(idx->ClPred);
|
||||||
if (idx->ChildIndex) {
|
if (idx->ChildIndex) {
|
||||||
idx->ChildIndex = SIndexAdjust(idx->ChildIndex);
|
idx->ChildIndex = SIndexAdjust(idx->ChildIndex);
|
||||||
if (recurse)
|
if (recurse)
|
||||||
CleanSIndex(idx->ChildIndex, TRUE);
|
CleanSIndex(idx->ChildIndex, TRUE PASS_REGS);
|
||||||
}
|
}
|
||||||
if (idx->SiblingIndex) {
|
if (idx->SiblingIndex) {
|
||||||
idx->SiblingIndex = SIndexAdjust(idx->SiblingIndex);
|
idx->SiblingIndex = SIndexAdjust(idx->SiblingIndex);
|
||||||
@ -664,7 +672,7 @@ CleanSIndex(StaticIndex *idx, int recurse)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreSWIAtoms(void)
|
RestoreSWIAtoms( USES_REGS1 )
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
for (i=0; i < N_SWI_ATOMS; i++) {
|
for (i=0; i < N_SWI_ATOMS; i++) {
|
||||||
@ -687,14 +695,14 @@ RestoreSWIBlobs(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestorePredHash(void)
|
RestorePredHash( USES_REGS1 )
|
||||||
{
|
{
|
||||||
PredHash = PtoPtoPredAdjust(PredHash);
|
PredHash = PtoPtoPredAdjust(PredHash);
|
||||||
if (PredHash == NULL) {
|
if (PredHash == NULL) {
|
||||||
Yap_Error(FATAL_ERROR,MkIntTerm(0),"restore should find predicate hash table");
|
Yap_Error(FATAL_ERROR,MkIntTerm(0),"restore should find predicate hash table");
|
||||||
}
|
}
|
||||||
REINIT_RWLOCK(PredHashRWLock);
|
REINIT_RWLOCK(PredHashRWLock);
|
||||||
RestoreHashPreds(); /* does most of the work */
|
RestoreHashPreds( PASS_REGS1 ); /* does most of the work */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -711,7 +719,7 @@ RestoreEnvInst(yamop start[2], yamop **instp, op_numbers opc, PredEntry *pred)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreOtaplInst(yamop start[1], OPCODE opc, PredEntry *pe)
|
RestoreOtaplInst__(yamop start[1], OPCODE opc, PredEntry *pe USES_REGS)
|
||||||
{
|
{
|
||||||
yamop *ipc = start;
|
yamop *ipc = start;
|
||||||
|
|
||||||
@ -730,20 +738,20 @@ RestoreOtaplInst(yamop start[1], OPCODE opc, PredEntry *pe)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreDBTermsList(void)
|
RestoreDBTermsList( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (Yap_heap_regs->dbterms_list) {
|
if (Yap_heap_regs->dbterms_list) {
|
||||||
struct dbterm_list *dbl = PtoDBTLAdjust(Yap_heap_regs->dbterms_list);
|
struct dbterm_list *dbl = PtoDBTLAdjust(Yap_heap_regs->dbterms_list);
|
||||||
Yap_heap_regs->dbterms_list = dbl;
|
Yap_heap_regs->dbterms_list = dbl;
|
||||||
while (dbl) {
|
while (dbl) {
|
||||||
RestoreDBTermEntry(dbl);
|
RestoreDBTermEntry(dbl PASS_REGS);
|
||||||
dbl = dbl->next_dbl;
|
dbl = dbl->next_dbl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreExpandList(void)
|
RestoreExpandList( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (Yap_heap_regs->expand_clauses_first)
|
if (Yap_heap_regs->expand_clauses_first)
|
||||||
Yap_heap_regs->expand_clauses_first = PtoOpAdjust(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;
|
yamop *ptr = Yap_heap_regs->expand_clauses_first;
|
||||||
while (ptr) {
|
while (ptr) {
|
||||||
do_clean_susp_clauses(ptr);
|
do_clean_susp_clauses(ptr PASS_REGS);
|
||||||
ptr = ptr->u.sssllp.snext;
|
ptr = ptr->u.sssllp.snext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -768,7 +776,7 @@ RestoreUdiControlBlocks(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreIntKeys(void)
|
RestoreIntKeys( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (Yap_heap_regs->IntKeys != NULL) {
|
if (Yap_heap_regs->IntKeys != NULL) {
|
||||||
Yap_heap_regs->IntKeys = (Prop *)AddrAdjust((ADDR)(Yap_heap_regs->IntKeys));
|
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++) {
|
for (i = 0; i < Yap_heap_regs->int_keys_size; i++) {
|
||||||
if (Yap_heap_regs->IntKeys[i] != NIL) {
|
if (Yap_heap_regs->IntKeys[i] != NIL) {
|
||||||
Prop p0 = Yap_heap_regs->IntKeys[i] = PropAdjust(Yap_heap_regs->IntKeys[i]);
|
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
|
static void
|
||||||
RestoreIntLUKeys(void)
|
RestoreIntLUKeys( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (Yap_heap_regs->IntLUKeys != NULL) {
|
if (Yap_heap_regs->IntLUKeys != NULL) {
|
||||||
Yap_heap_regs->IntLUKeys = (Prop *)AddrAdjust((ADDR)(Yap_heap_regs->IntLUKeys));
|
Yap_heap_regs->IntLUKeys = (Prop *)AddrAdjust((ADDR)(Yap_heap_regs->IntLUKeys));
|
||||||
@ -800,7 +808,7 @@ RestoreIntLUKeys(void)
|
|||||||
PredEntry *pe = RepPredProp(p0);
|
PredEntry *pe = RepPredProp(p0);
|
||||||
pe->NextOfPE =
|
pe->NextOfPE =
|
||||||
PropAdjust(pe->NextOfPE);
|
PropAdjust(pe->NextOfPE);
|
||||||
CleanCode(pe);
|
CleanCode(pe PASS_REGS);
|
||||||
p0 = RepProp(pe->NextOfPE);
|
p0 = RepProp(pe->NextOfPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -810,7 +818,7 @@ RestoreIntLUKeys(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreIntBBKeys(void)
|
RestoreIntBBKeys( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (Yap_heap_regs->IntBBKeys != NULL) {
|
if (Yap_heap_regs->IntBBKeys != NULL) {
|
||||||
Yap_heap_regs->IntBBKeys = (Prop *)AddrAdjust((ADDR)(Yap_heap_regs->IntBBKeys));
|
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++) {
|
for (i = 0; i < Yap_heap_regs->int_bb_keys_size; i++) {
|
||||||
if (Yap_heap_regs->IntBBKeys[i] != NIL) {
|
if (Yap_heap_regs->IntBBKeys[i] != NIL) {
|
||||||
Prop p0 = Yap_heap_regs->IntBBKeys[i] = PropAdjust(Yap_heap_regs->IntBBKeys[i]);
|
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
|
static void
|
||||||
RestoreDBErasedMarker(void)
|
RestoreDBErasedMarker__( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Yap_heap_regs->db_erased_marker =
|
Yap_heap_regs->db_erased_marker =
|
||||||
DBRefAdjust(Yap_heap_regs->db_erased_marker);
|
DBRefAdjust(Yap_heap_regs->db_erased_marker);
|
||||||
@ -839,7 +847,7 @@ RestoreDBErasedMarker(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreLogDBErasedMarker(void)
|
RestoreLogDBErasedMarker__( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Yap_heap_regs->logdb_erased_marker =
|
Yap_heap_regs->logdb_erased_marker =
|
||||||
PtoLUCAdjust(Yap_heap_regs->logdb_erased_marker);
|
PtoLUCAdjust(Yap_heap_regs->logdb_erased_marker);
|
||||||
@ -857,65 +865,65 @@ RestoreLogDBErasedMarker(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreDeadStaticClauses(void)
|
RestoreDeadStaticClauses( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (Yap_heap_regs->dead_static_clauses) {
|
if (Yap_heap_regs->dead_static_clauses) {
|
||||||
StaticClause *sc = PtoStCAdjust(Yap_heap_regs->dead_static_clauses);
|
StaticClause *sc = PtoStCAdjust(Yap_heap_regs->dead_static_clauses);
|
||||||
Yap_heap_regs->dead_static_clauses = sc;
|
Yap_heap_regs->dead_static_clauses = sc;
|
||||||
while (sc) {
|
while (sc) {
|
||||||
RestoreStaticClause(sc);
|
RestoreStaticClause(sc PASS_REGS);
|
||||||
sc = sc->ClNext;
|
sc = sc->ClNext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreDeadMegaClauses(void)
|
RestoreDeadMegaClauses( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (Yap_heap_regs->dead_mega_clauses) {
|
if (Yap_heap_regs->dead_mega_clauses) {
|
||||||
MegaClause *mc = (MegaClause *)AddrAdjust((ADDR)(Yap_heap_regs->dead_mega_clauses));
|
MegaClause *mc = (MegaClause *)AddrAdjust((ADDR)(Yap_heap_regs->dead_mega_clauses));
|
||||||
Yap_heap_regs->dead_mega_clauses = mc;
|
Yap_heap_regs->dead_mega_clauses = mc;
|
||||||
while (mc) {
|
while (mc) {
|
||||||
RestoreMegaClause(mc);
|
RestoreMegaClause(mc PASS_REGS);
|
||||||
mc = mc->ClNext;
|
mc = mc->ClNext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreDeadStaticIndices(void)
|
RestoreDeadStaticIndices( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (Yap_heap_regs->dead_static_indices) {
|
if (Yap_heap_regs->dead_static_indices) {
|
||||||
StaticIndex *si = (StaticIndex *)AddrAdjust((ADDR)(Yap_heap_regs->dead_static_indices));
|
StaticIndex *si = (StaticIndex *)AddrAdjust((ADDR)(Yap_heap_regs->dead_static_indices));
|
||||||
Yap_heap_regs->dead_static_indices = si;
|
Yap_heap_regs->dead_static_indices = si;
|
||||||
while (si) {
|
while (si) {
|
||||||
CleanSIndex(si, FALSE);
|
CleanSIndex(si, FALSE PASS_REGS);
|
||||||
si = si->SiblingIndex;
|
si = si->SiblingIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreDBErasedList(void)
|
RestoreDBErasedList( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (Yap_heap_regs->db_erased_list) {
|
if (Yap_heap_regs->db_erased_list) {
|
||||||
LogUpdClause *lcl = Yap_heap_regs->db_erased_list =
|
LogUpdClause *lcl = Yap_heap_regs->db_erased_list =
|
||||||
PtoLUCAdjust(Yap_heap_regs->db_erased_list);
|
PtoLUCAdjust(Yap_heap_regs->db_erased_list);
|
||||||
while (lcl) {
|
while (lcl) {
|
||||||
RestoreLUClause(lcl, FALSE);
|
RestoreLUClause(lcl, FALSE PASS_REGS);
|
||||||
lcl = lcl->ClNext;
|
lcl = lcl->ClNext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreDBErasedIList(void)
|
RestoreDBErasedIList( USES_REGS1 )
|
||||||
{
|
{
|
||||||
if (Yap_heap_regs->db_erased_ilist) {
|
if (Yap_heap_regs->db_erased_ilist) {
|
||||||
LogUpdIndex *icl = Yap_heap_regs->db_erased_ilist =
|
LogUpdIndex *icl = Yap_heap_regs->db_erased_ilist =
|
||||||
LUIndexAdjust(Yap_heap_regs->db_erased_ilist);
|
LUIndexAdjust(Yap_heap_regs->db_erased_ilist);
|
||||||
while (icl) {
|
while (icl) {
|
||||||
CleanLUIndex(icl, FALSE);
|
CleanLUIndex(icl, FALSE PASS_REGS);
|
||||||
icl = icl->SiblingIndex;
|
icl = icl->SiblingIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -929,18 +937,10 @@ RestoreStreams(void)
|
|||||||
static void
|
static void
|
||||||
RestoreAliases(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
|
static void
|
||||||
RestoreForeignCode(void)
|
RestoreForeignCode__( USES_REGS1 )
|
||||||
{
|
{
|
||||||
ForeignObj *f_code;
|
ForeignObj *f_code;
|
||||||
|
|
||||||
@ -978,7 +978,7 @@ RestoreForeignCode(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreYapRecords(void)
|
RestoreYapRecords( USES_REGS1 )
|
||||||
{
|
{
|
||||||
struct record_list *ptr;
|
struct record_list *ptr;
|
||||||
|
|
||||||
@ -988,16 +988,17 @@ RestoreYapRecords(void)
|
|||||||
ptr->next_rec = DBRecordAdjust(ptr->next_rec);
|
ptr->next_rec = DBRecordAdjust(ptr->next_rec);
|
||||||
ptr->prev_rec = DBRecordAdjust(ptr->prev_rec);
|
ptr->prev_rec = DBRecordAdjust(ptr->prev_rec);
|
||||||
ptr->dbrecord = DBTermAdjust(ptr->dbrecord);
|
ptr->dbrecord = DBTermAdjust(ptr->dbrecord);
|
||||||
RestoreDBTerm(ptr->dbrecord, FALSE);
|
RestoreDBTerm(ptr->dbrecord, FALSE PASS_REGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreBallTerm(int wid)
|
RestoreBallTerm(int wid)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (BallTerm) {
|
if (BallTerm) {
|
||||||
BallTerm = DBTermAdjust(BallTerm);
|
BallTerm = DBTermAdjust(BallTerm);
|
||||||
RestoreDBTerm(BallTerm, TRUE);
|
RestoreDBTerm(BallTerm, TRUE PASS_REGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1007,18 +1008,19 @@ RestoreBallTerm(int wid)
|
|||||||
static void
|
static void
|
||||||
restore_codes(void)
|
restore_codes(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Yap_heap_regs->heap_top = AddrAdjust(OldHeapTop);
|
Yap_heap_regs->heap_top = AddrAdjust(OldHeapTop);
|
||||||
#include "rhstruct.h"
|
#include "rhstruct.h"
|
||||||
RestoreGlobal();
|
RestoreGlobal();
|
||||||
#ifndef worker_id
|
#ifndef worker_id
|
||||||
#define worker_id 0
|
#define worker_id 0
|
||||||
#endif
|
#endif
|
||||||
RestoreWorker(worker_id);
|
RestoreWorker(worker_id PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreDBEntry(DBRef dbr)
|
RestoreDBEntry(DBRef dbr USES_REGS)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_RESTORE
|
#ifdef DEBUG_RESTORE
|
||||||
fprintf(stderr, "Restoring at %x", dbr);
|
fprintf(stderr, "Restoring at %x", dbr);
|
||||||
@ -1033,7 +1035,7 @@ RestoreDBEntry(DBRef dbr)
|
|||||||
else
|
else
|
||||||
fprintf(stderr, " a var\n");
|
fprintf(stderr, " a var\n");
|
||||||
#endif
|
#endif
|
||||||
RestoreDBTerm(&(dbr->DBT), TRUE);
|
RestoreDBTerm(&(dbr->DBT), TRUE PASS_REGS);
|
||||||
if (dbr->Parent) {
|
if (dbr->Parent) {
|
||||||
dbr->Parent = (DBProp)AddrAdjust((ADDR)(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 */
|
/* Restores a DB structure, as it was saved in the heap */
|
||||||
static void
|
static void
|
||||||
RestoreDB(DBEntry *pp)
|
RestoreDB(DBEntry *pp USES_REGS)
|
||||||
{
|
{
|
||||||
register DBRef dbr;
|
register DBRef dbr;
|
||||||
|
|
||||||
@ -1071,7 +1073,7 @@ RestoreDB(DBEntry *pp)
|
|||||||
dbr = pp->F0;
|
dbr = pp->F0;
|
||||||
/* While we have something in the data base, even if erased, restore it */
|
/* While we have something in the data base, even if erased, restore it */
|
||||||
while (dbr) {
|
while (dbr) {
|
||||||
RestoreDBEntry(dbr);
|
RestoreDBEntry(dbr PASS_REGS);
|
||||||
if (dbr->n != NULL)
|
if (dbr->n != NULL)
|
||||||
dbr->n = DBRefAdjust(dbr->n);
|
dbr->n = DBRefAdjust(dbr->n);
|
||||||
if (dbr->p != NULL)
|
if (dbr->p != NULL)
|
||||||
@ -1085,24 +1087,24 @@ RestoreDB(DBEntry *pp)
|
|||||||
* and ending with Last, First may be equal to Last
|
* and ending with Last, First may be equal to Last
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
CleanClauses(yamop *First, yamop *Last, PredEntry *pp)
|
CleanClauses(yamop *First, yamop *Last, PredEntry *pp USES_REGS)
|
||||||
{
|
{
|
||||||
if (pp->PredFlags & LogUpdatePredFlag) {
|
if (pp->PredFlags & LogUpdatePredFlag) {
|
||||||
LogUpdClause *cl = ClauseCodeToLogUpdClause(First);
|
LogUpdClause *cl = ClauseCodeToLogUpdClause(First);
|
||||||
|
|
||||||
while (cl != NULL) {
|
while (cl != NULL) {
|
||||||
RestoreLUClause(cl, pp);
|
RestoreLUClause(cl, pp PASS_REGS);
|
||||||
cl = cl->ClNext;
|
cl = cl->ClNext;
|
||||||
}
|
}
|
||||||
} else if (pp->PredFlags & MegaClausePredFlag) {
|
} else if (pp->PredFlags & MegaClausePredFlag) {
|
||||||
MegaClause *cl = ClauseCodeToMegaClause(First);
|
MegaClause *cl = ClauseCodeToMegaClause(First);
|
||||||
|
|
||||||
RestoreMegaClause(cl);
|
RestoreMegaClause(cl PASS_REGS);
|
||||||
} else if (pp->PredFlags & DynamicPredFlag) {
|
} else if (pp->PredFlags & DynamicPredFlag) {
|
||||||
yamop *cl = First;
|
yamop *cl = First;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
RestoreDynamicClause(ClauseCodeToDynamicClause(cl), pp);
|
RestoreDynamicClause(ClauseCodeToDynamicClause(cl), pp PASS_REGS);
|
||||||
if (cl == Last) return;
|
if (cl == Last) return;
|
||||||
cl = NextDynamicClause(cl);
|
cl = NextDynamicClause(cl);
|
||||||
} while (TRUE);
|
} while (TRUE);
|
||||||
@ -1110,7 +1112,7 @@ CleanClauses(yamop *First, yamop *Last, PredEntry *pp)
|
|||||||
StaticClause *cl = ClauseCodeToStaticClause(First);
|
StaticClause *cl = ClauseCodeToStaticClause(First);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
RestoreStaticClause(cl);
|
RestoreStaticClause(cl PASS_REGS);
|
||||||
if (cl->ClCode == Last) return;
|
if (cl->ClCode == Last) return;
|
||||||
cl = cl->ClNext;
|
cl = cl->ClNext;
|
||||||
} while (TRUE);
|
} while (TRUE);
|
||||||
@ -1121,7 +1123,7 @@ CleanClauses(yamop *First, yamop *Last, PredEntry *pp)
|
|||||||
|
|
||||||
/* Restores a DB structure, as it was saved in the heap */
|
/* Restores a DB structure, as it was saved in the heap */
|
||||||
static void
|
static void
|
||||||
RestoreBB(BlackBoardEntry *pp, int int_key)
|
RestoreBB(BlackBoardEntry *pp, int int_key USES_REGS)
|
||||||
{
|
{
|
||||||
Term t = pp->Element;
|
Term t = pp->Element;
|
||||||
if (t) {
|
if (t) {
|
||||||
@ -1131,7 +1133,7 @@ RestoreBB(BlackBoardEntry *pp, int int_key)
|
|||||||
pp->Element = AtomTermAdjust(t);
|
pp->Element = AtomTermAdjust(t);
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
static void
|
||||||
restore_static_array(StaticArrayEntry *ae)
|
restore_static_array(StaticArrayEntry *ae USES_REGS)
|
||||||
{
|
{
|
||||||
Int sz = -ae->ArrayEArity;
|
Int sz = -ae->ArrayEArity;
|
||||||
switch (ae->ArrayType) {
|
switch (ae->ArrayType) {
|
||||||
@ -1251,7 +1253,7 @@ restore_static_array(StaticArrayEntry *ae)
|
|||||||
} else {
|
} else {
|
||||||
DBTerm *db = (DBTerm *)RepAppl(reg);
|
DBTerm *db = (DBTerm *)RepAppl(reg);
|
||||||
db = DBTermAdjust(db);
|
db = DBTermAdjust(db);
|
||||||
RestoreDBTerm(db, TRUE);
|
RestoreDBTerm(db, TRUE PASS_REGS);
|
||||||
base->tstore = AbsAppl((CELL *)db);
|
base->tstore = AbsAppl((CELL *)db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1270,7 +1272,7 @@ restore_static_array(StaticArrayEntry *ae)
|
|||||||
base++;
|
base++;
|
||||||
} else {
|
} else {
|
||||||
*base++ = reg = DBTermAdjust(reg);
|
*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
|
* because of the indexing code
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
CleanCode(PredEntry *pp)
|
CleanCode(PredEntry *pp USES_REGS)
|
||||||
{
|
{
|
||||||
CELL flag;
|
CELL flag;
|
||||||
|
|
||||||
@ -1325,7 +1327,7 @@ CleanCode(PredEntry *pp)
|
|||||||
/* assembly */
|
/* assembly */
|
||||||
if (pp->CodeOfPred) {
|
if (pp->CodeOfPred) {
|
||||||
pp->CodeOfPred = PtoOpAdjust(pp->CodeOfPred);
|
pp->CodeOfPred = PtoOpAdjust(pp->CodeOfPred);
|
||||||
CleanClauses(pp->CodeOfPred, pp->CodeOfPred, pp);
|
CleanClauses(pp->CodeOfPred, pp->CodeOfPred, pp PASS_REGS);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
yamop *FirstC, *LastC;
|
yamop *FirstC, *LastC;
|
||||||
@ -1347,21 +1349,21 @@ CleanCode(PredEntry *pp)
|
|||||||
#ifdef DEBUG_RESTORE2
|
#ifdef DEBUG_RESTORE2
|
||||||
fprintf(stderr, "at %ux Correcting clauses from %p to %p\n", *(OPCODE *) FirstC, FirstC, LastC);
|
fprintf(stderr, "at %ux Correcting clauses from %p to %p\n", *(OPCODE *) FirstC, FirstC, LastC);
|
||||||
#endif
|
#endif
|
||||||
CleanClauses(FirstC, LastC, pp);
|
CleanClauses(FirstC, LastC, pp PASS_REGS);
|
||||||
if (flag & IndexedPredFlag) {
|
if (flag & IndexedPredFlag) {
|
||||||
#ifdef DEBUG_RESTORE2
|
#ifdef DEBUG_RESTORE2
|
||||||
fprintf(stderr, "Correcting indexed code\n");
|
fprintf(stderr, "Correcting indexed code\n");
|
||||||
#endif
|
#endif
|
||||||
if (flag & LogUpdatePredFlag) {
|
if (flag & LogUpdatePredFlag) {
|
||||||
CleanLUIndex(ClauseCodeToLogUpdIndex(pp->cs.p_code.TrueCodeOfPred), TRUE);
|
CleanLUIndex(ClauseCodeToLogUpdIndex(pp->cs.p_code.TrueCodeOfPred), TRUE PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
CleanSIndex(ClauseCodeToStaticIndex(pp->cs.p_code.TrueCodeOfPred), TRUE);
|
CleanSIndex(ClauseCodeToStaticIndex(pp->cs.p_code.TrueCodeOfPred), TRUE PASS_REGS);
|
||||||
}
|
}
|
||||||
} else if (flag & DynamicPredFlag) {
|
} else if (flag & DynamicPredFlag) {
|
||||||
#ifdef DEBUG_RESTORE2
|
#ifdef DEBUG_RESTORE2
|
||||||
fprintf(stderr, "Correcting dynamic code\n");
|
fprintf(stderr, "Correcting dynamic code\n");
|
||||||
#endif
|
#endif
|
||||||
RestoreDynamicClause(ClauseCodeToDynamicClause(pp->cs.p_code.TrueCodeOfPred),pp);
|
RestoreDynamicClause(ClauseCodeToDynamicClause(pp->cs.p_code.TrueCodeOfPred),pp PASS_REGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* we are pointing at ourselves */
|
/* we are pointing at ourselves */
|
||||||
@ -1372,7 +1374,7 @@ CleanCode(PredEntry *pp)
|
|||||||
* if we find code or data bases
|
* if we find code or data bases
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
RestoreEntries(PropEntry *pp, int int_key)
|
RestoreEntries(PropEntry *pp, int int_key USES_REGS)
|
||||||
{
|
{
|
||||||
while (!EndOfPAEntr(pp)) {
|
while (!EndOfPAEntr(pp)) {
|
||||||
switch(pp->KindOfPE) {
|
switch(pp->KindOfPE) {
|
||||||
@ -1388,7 +1390,7 @@ RestoreEntries(PropEntry *pp, int int_key)
|
|||||||
PropAdjust(fe->PropsOfFE);
|
PropAdjust(fe->PropsOfFE);
|
||||||
if (!EndOfPAEntr(p0)) {
|
if (!EndOfPAEntr(p0)) {
|
||||||
/* at most one property */
|
/* at most one property */
|
||||||
CleanCode(RepPredProp(p0));
|
CleanCode(RepPredProp(p0) PASS_REGS);
|
||||||
RepPredProp(p0)->NextOfPE =
|
RepPredProp(p0)->NextOfPE =
|
||||||
PropAdjust(RepPredProp(p0)->NextOfPE);
|
PropAdjust(RepPredProp(p0)->NextOfPE);
|
||||||
p0 = RepPredProp(p0)->NextOfPE;
|
p0 = RepPredProp(p0)->NextOfPE;
|
||||||
@ -1422,7 +1424,7 @@ RestoreEntries(PropEntry *pp, int int_key)
|
|||||||
StaticArrayEntry *sae = (StaticArrayEntry *)ae;
|
StaticArrayEntry *sae = (StaticArrayEntry *)ae;
|
||||||
if (sae->NextAE)
|
if (sae->NextAE)
|
||||||
sae->NextAE = PtoArraySAdjust(sae->NextAE);
|
sae->NextAE = PtoArraySAdjust(sae->NextAE);
|
||||||
restore_static_array(sae);
|
restore_static_array(sae PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
if (ae->NextAE)
|
if (ae->NextAE)
|
||||||
ae->NextAE = PtoArrayEAdjust(ae->NextAE);
|
ae->NextAE = PtoArrayEAdjust(ae->NextAE);
|
||||||
@ -1452,7 +1454,7 @@ RestoreEntries(PropEntry *pp, int int_key)
|
|||||||
PredEntry *pe = (PredEntry *) pp;
|
PredEntry *pe = (PredEntry *) pp;
|
||||||
pe->NextOfPE =
|
pe->NextOfPE =
|
||||||
PropAdjust(pe->NextOfPE);
|
PropAdjust(pe->NextOfPE);
|
||||||
CleanCode(pe);
|
CleanCode(pe PASS_REGS);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DBProperty:
|
case DBProperty:
|
||||||
@ -1464,7 +1466,7 @@ RestoreEntries(PropEntry *pp, int int_key)
|
|||||||
DBEntry *de = (DBEntry *) pp;
|
DBEntry *de = (DBEntry *) pp;
|
||||||
de->NextOfPE =
|
de->NextOfPE =
|
||||||
PropAdjust(de->NextOfPE);
|
PropAdjust(de->NextOfPE);
|
||||||
RestoreDB(de);
|
RestoreDB(de PASS_REGS);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BBProperty:
|
case BBProperty:
|
||||||
@ -1472,7 +1474,7 @@ RestoreEntries(PropEntry *pp, int int_key)
|
|||||||
BlackBoardEntry *bb = (BlackBoardEntry *) pp;
|
BlackBoardEntry *bb = (BlackBoardEntry *) pp;
|
||||||
bb->NextOfPE =
|
bb->NextOfPE =
|
||||||
PropAdjust(bb->NextOfPE);
|
PropAdjust(bb->NextOfPE);
|
||||||
RestoreBB(bb, int_key);
|
RestoreBB(bb, int_key PASS_REGS);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GlobalProperty:
|
case GlobalProperty:
|
||||||
@ -1563,7 +1565,7 @@ RestoreEntries(PropEntry *pp, int int_key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreAtom(AtomEntry *at)
|
RestoreAtom(AtomEntry *at USES_REGS)
|
||||||
{
|
{
|
||||||
AtomEntry *nat;
|
AtomEntry *nat;
|
||||||
|
|
||||||
@ -1575,7 +1577,7 @@ RestoreAtom(AtomEntry *at)
|
|||||||
else
|
else
|
||||||
fprintf(errout, "Restoring %s\n", at->StrOfAE);
|
fprintf(errout, "Restoring %s\n", at->StrOfAE);
|
||||||
#endif
|
#endif
|
||||||
RestoreEntries(RepProp(at->PropsOfAE), FALSE);
|
RestoreEntries(RepProp(at->PropsOfAE), FALSE PASS_REGS);
|
||||||
/* cannot use AtomAdjust without breaking agc */
|
/* cannot use AtomAdjust without breaking agc */
|
||||||
nat = RepAtom(at->NextOfAE);
|
nat = RepAtom(at->NextOfAE);
|
||||||
if (nat)
|
if (nat)
|
||||||
|
32
H/rhstruct.h
32
H/rhstruct.h
@ -74,9 +74,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
RestoreInvisibleAtoms();
|
RestoreInvisibleAtoms( PASS_REGS1 );
|
||||||
RestoreWideAtoms();
|
RestoreWideAtoms( PASS_REGS1 );
|
||||||
RestoreAtoms();
|
RestoreAtoms( PASS_REGS1 );
|
||||||
|
|
||||||
#include "ratoms.h"
|
#include "ratoms.h"
|
||||||
#ifdef EUROTRA
|
#ifdef EUROTRA
|
||||||
@ -106,7 +106,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
RestorePredHash();
|
RestorePredHash( PASS_REGS1 );
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -204,10 +204,10 @@
|
|||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
REINIT_LOCK(Yap_heap_regs->dbterms_list_lock);
|
REINIT_LOCK(Yap_heap_regs->dbterms_list_lock);
|
||||||
#endif
|
#endif
|
||||||
RestoreDBTermsList();
|
RestoreDBTermsList( PASS_REGS1 );
|
||||||
|
|
||||||
|
|
||||||
RestoreExpandList();
|
RestoreExpandList( PASS_REGS1 );
|
||||||
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
REINIT_LOCK(Yap_heap_regs->expand_clauses_list_lock);
|
REINIT_LOCK(Yap_heap_regs->expand_clauses_list_lock);
|
||||||
@ -227,9 +227,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
RestoreIntKeys();
|
RestoreIntKeys( PASS_REGS1 );
|
||||||
RestoreIntLUKeys();
|
RestoreIntLUKeys( PASS_REGS1 );
|
||||||
RestoreIntBBKeys();
|
RestoreIntBBKeys( PASS_REGS1 );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -240,11 +240,11 @@
|
|||||||
RestoreDBErasedMarker();
|
RestoreDBErasedMarker();
|
||||||
RestoreLogDBErasedMarker();
|
RestoreLogDBErasedMarker();
|
||||||
|
|
||||||
RestoreDeadStaticClauses();
|
RestoreDeadStaticClauses( PASS_REGS1 );
|
||||||
RestoreDeadMegaClauses();
|
RestoreDeadMegaClauses( PASS_REGS1 );
|
||||||
RestoreDeadStaticIndices();
|
RestoreDeadStaticIndices( PASS_REGS1 );
|
||||||
RestoreDBErasedList();
|
RestoreDBErasedList( PASS_REGS1 );
|
||||||
RestoreDBErasedIList();
|
RestoreDBErasedIList( PASS_REGS1 );
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
REINIT_LOCK(Yap_heap_regs->dead_static_clauses_lock);
|
REINIT_LOCK(Yap_heap_regs->dead_static_clauses_lock);
|
||||||
REINIT_LOCK(Yap_heap_regs->dead_mega_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:
|
case _copy_idb_term:
|
||||||
return found_idb_clause(pc, startp, endp);
|
return found_idb_clause(pc, startp, endp);
|
||||||
case _expand_index:
|
case _expand_index:
|
||||||
return found_expand(pc, startp, endp);
|
return found_expand(pc, startp, endp PASS_REGS);
|
||||||
case _index_pred:
|
case _index_pred:
|
||||||
return found_owner_op(pc, startp, endp);
|
return found_owner_op(pc, startp, endp PASS_REGS);
|
||||||
case _lock_pred:
|
case _lock_pred:
|
||||||
return found_owner_op(pc, startp, endp);
|
return found_owner_op(pc, startp, endp PASS_REGS);
|
||||||
case _op_fail:
|
case _op_fail:
|
||||||
if (codeptr == FAILCODE)
|
if (codeptr == FAILCODE)
|
||||||
return found_fail(pc, startp, endp);
|
return found_fail(pc, startp, endp PASS_REGS);
|
||||||
pc = NEXTOP(pc,e);
|
pc = NEXTOP(pc,e);
|
||||||
break;
|
break;
|
||||||
case _spy_pred:
|
case _spy_pred:
|
||||||
return found_owner_op(pc, startp, endp);
|
return found_owner_op(pc, startp, endp PASS_REGS);
|
||||||
case _trust_fail:
|
case _trust_fail:
|
||||||
if (codeptr == TRUSTFAILCODE)
|
if (codeptr == TRUSTFAILCODE)
|
||||||
return found_fail(pc, startp, endp);
|
return found_fail(pc, startp, endp PASS_REGS);
|
||||||
pc = NEXTOP(pc,e);
|
pc = NEXTOP(pc,e);
|
||||||
break;
|
break;
|
||||||
case _undef_p:
|
case _undef_p:
|
||||||
return found_owner_op(pc, startp, endp);
|
return found_owner_op(pc, startp, endp PASS_REGS);
|
||||||
case _unify_idb_term:
|
case _unify_idb_term:
|
||||||
return found_idb_clause(pc, startp, endp);
|
return found_idb_clause(pc, startp, endp);
|
||||||
case _allocate:
|
case _allocate:
|
||||||
@ -195,7 +195,7 @@
|
|||||||
break;
|
break;
|
||||||
/* instructions type l */
|
/* instructions type l */
|
||||||
case _Ystop:
|
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:
|
||||||
case _jump_if_var:
|
case _jump_if_var:
|
||||||
case _move_back:
|
case _move_back:
|
||||||
@ -402,7 +402,7 @@
|
|||||||
break;
|
break;
|
||||||
/* instructions type sssllp */
|
/* instructions type sssllp */
|
||||||
case _expand_clauses:
|
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);
|
pc = NEXTOP(pc,sssllp);
|
||||||
break;
|
break;
|
||||||
/* instructions type x */
|
/* instructions type x */
|
||||||
|
@ -187,7 +187,7 @@ typedef struct TOKEN {
|
|||||||
|
|
||||||
#define Ord(X) ((enum TokenKinds) (X))
|
#define Ord(X) ((enum TokenKinds) (X))
|
||||||
|
|
||||||
#define NextToken GNextToken()
|
#define NextToken GNextToken( PASS_REGS1 )
|
||||||
|
|
||||||
typedef struct VARSTRUCT {
|
typedef struct VARSTRUCT {
|
||||||
Term VarAdr;
|
Term VarAdr;
|
||||||
|
@ -51,7 +51,7 @@ myddas_init_initialize_myddas(void){
|
|||||||
MYDDAS_UTIL_CONNECTION
|
MYDDAS_UTIL_CONNECTION
|
||||||
myddas_init_initialize_connection(void *conn,void *enviromment,
|
myddas_init_initialize_connection(void *conn,void *enviromment,
|
||||||
MYDDAS_UTIL_CONNECTION next){
|
MYDDAS_UTIL_CONNECTION next){
|
||||||
|
CACHE_REGS
|
||||||
MYDDAS_UTIL_CONNECTION new = NULL;
|
MYDDAS_UTIL_CONNECTION new = NULL;
|
||||||
MYDDAS_MALLOC(new,struct myddas_list_connection);
|
MYDDAS_MALLOC(new,struct myddas_list_connection);
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ myddas_init_initialize_connection(void *conn,void *enviromment,
|
|||||||
MYDDAS_UTIL_PREDICATE
|
MYDDAS_UTIL_PREDICATE
|
||||||
myddas_init_initialize_predicate(char *pred_name, int pred_arity,
|
myddas_init_initialize_predicate(char *pred_name, int pred_arity,
|
||||||
char *pred_module, MYDDAS_UTIL_PREDICATE next){
|
char *pred_module, MYDDAS_UTIL_PREDICATE next){
|
||||||
|
CACHE_REGS
|
||||||
MYDDAS_UTIL_PREDICATE new = NULL;
|
MYDDAS_UTIL_PREDICATE new = NULL;
|
||||||
MYDDAS_MALLOC(new,struct myddas_list_preds);
|
MYDDAS_MALLOC(new,struct myddas_list_preds);
|
||||||
|
|
||||||
|
@ -29,15 +29,15 @@
|
|||||||
|
|
||||||
static Int null_id = 0;
|
static Int null_id = 0;
|
||||||
|
|
||||||
STATIC_PROTO(Int c_db_odbc_connect,(void));
|
STATIC_PROTO(Int c_db_odbc_connect,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_odbc_disconnect,(void));
|
STATIC_PROTO(Int c_db_odbc_disconnect,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_odbc_number_of_fields,(void));
|
STATIC_PROTO(Int c_db_odbc_number_of_fields,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_odbc_get_attributes_types,(void));
|
STATIC_PROTO(Int c_db_odbc_get_attributes_types,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_odbc_query,(void));
|
STATIC_PROTO(Int c_db_odbc_query,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_odbc_row,(void));
|
STATIC_PROTO(Int c_db_odbc_row,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_odbc_row_cut,(void));
|
STATIC_PROTO(Int c_db_odbc_row_cut,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_odbc_get_fields_properties,(void));
|
STATIC_PROTO(Int c_db_odbc_get_fields_properties,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_odbc_number_of_fields_in_query,(void));
|
STATIC_PROTO(Int c_db_odbc_number_of_fields_in_query,( USES_REGS1 ));
|
||||||
|
|
||||||
static int
|
static int
|
||||||
odbc_error(SQLSMALLINT type, SQLHANDLE hdbc, char *msg, char *print)
|
odbc_error(SQLSMALLINT type, SQLHANDLE hdbc, char *msg, char *print)
|
||||||
@ -321,7 +321,7 @@ static int SQLCOLATTRIBUTE( SQLHSTMT StatementHandle,
|
|||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
c_db_odbc_connect(void) {
|
c_db_odbc_connect( USES_REGS1 ) {
|
||||||
Term arg_driver = Deref(ARG1);
|
Term arg_driver = Deref(ARG1);
|
||||||
Term arg_user = Deref(ARG2);
|
Term arg_user = Deref(ARG2);
|
||||||
Term arg_passwd = Deref(ARG3);
|
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 */
|
/* db_query: SQLQuery x ResultSet x Arity x BindList x Connection */
|
||||||
static Int
|
static Int
|
||||||
c_db_odbc_query(void) {
|
c_db_odbc_query( USES_REGS1 ) {
|
||||||
Term arg_sql_query = Deref(ARG1);
|
Term arg_sql_query = Deref(ARG1);
|
||||||
Term arg_result_set = Deref(ARG2);
|
Term arg_result_set = Deref(ARG2);
|
||||||
Term arg_arity = Deref(ARG3);
|
Term arg_arity = Deref(ARG3);
|
||||||
@ -452,7 +452,7 @@ c_db_odbc_query(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
c_db_odbc_number_of_fields(void) {
|
c_db_odbc_number_of_fields( USES_REGS1 ) {
|
||||||
Term arg_relation = Deref(ARG1);
|
Term arg_relation = Deref(ARG1);
|
||||||
Term arg_conn = Deref(ARG2);
|
Term arg_conn = Deref(ARG2);
|
||||||
Term arg_fields = Deref(ARG3);
|
Term arg_fields = Deref(ARG3);
|
||||||
@ -493,7 +493,7 @@ c_db_odbc_number_of_fields(void) {
|
|||||||
|
|
||||||
/* db_get_attributes_types: RelName x Connection -> TypesList */
|
/* db_get_attributes_types: RelName x Connection -> TypesList */
|
||||||
static Int
|
static Int
|
||||||
c_db_odbc_get_attributes_types(void) {
|
c_db_odbc_get_attributes_types( USES_REGS1 ) {
|
||||||
Term arg_relation = Deref(ARG1);
|
Term arg_relation = Deref(ARG1);
|
||||||
Term arg_conn = Deref(ARG2);
|
Term arg_conn = Deref(ARG2);
|
||||||
Term arg_types_list = Deref(ARG3);
|
Term arg_types_list = Deref(ARG3);
|
||||||
@ -554,7 +554,7 @@ c_db_odbc_get_attributes_types(void) {
|
|||||||
|
|
||||||
/* db_disconnect */
|
/* db_disconnect */
|
||||||
static Int
|
static Int
|
||||||
c_db_odbc_disconnect(void) {
|
c_db_odbc_disconnect( USES_REGS1 ) {
|
||||||
Term arg_conn = Deref(ARG1);
|
Term arg_conn = Deref(ARG1);
|
||||||
|
|
||||||
SQLHDBC conn = (SQLHDBC) (IntegerOfTerm(arg_conn));
|
SQLHDBC conn = (SQLHDBC) (IntegerOfTerm(arg_conn));
|
||||||
@ -579,7 +579,7 @@ c_db_odbc_disconnect(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
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));
|
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 -> */
|
/* db_row: ResultSet x BindList x ListOfArgs -> */
|
||||||
static Int
|
static Int
|
||||||
c_db_odbc_row(void) {
|
c_db_odbc_row( USES_REGS1 ) {
|
||||||
Term arg_result_set = Deref(ARG1);
|
Term arg_result_set = Deref(ARG1);
|
||||||
Term arg_bind_list = Deref(ARG2);
|
Term arg_bind_list = Deref(ARG2);
|
||||||
Term arg_list_args = Deref(ARG3);
|
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
|
/* Mudar esta funcao de forma a nao fazer a consulta, pois
|
||||||
no predicate db_sql_selet vai fazer duas vezes a mesma consutla*/
|
no predicate db_sql_selet vai fazer duas vezes a mesma consutla*/
|
||||||
static Int
|
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_query = Deref(ARG1);
|
||||||
Term arg_conn = Deref(ARG2);
|
Term arg_conn = Deref(ARG2);
|
||||||
Term arg_fields = Deref(ARG3);
|
Term arg_fields = Deref(ARG3);
|
||||||
@ -714,7 +714,7 @@ c_db_odbc_number_of_fields_in_query(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
c_db_odbc_get_fields_properties(void) {
|
c_db_odbc_get_fields_properties( USES_REGS1 ) {
|
||||||
Term nome_relacao = Deref(ARG1);
|
Term nome_relacao = Deref(ARG1);
|
||||||
Term arg_conn = Deref(ARG2);
|
Term arg_conn = Deref(ARG2);
|
||||||
Term fields_properties_list = Deref(ARG3);
|
Term fields_properties_list = Deref(ARG3);
|
||||||
|
@ -27,24 +27,24 @@
|
|||||||
#include "myddas_statistics.h"
|
#include "myddas_statistics.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC_PROTO(Int c_db_initialize_myddas,(void));
|
STATIC_PROTO(Int c_db_initialize_myddas,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_connection_type,(void));
|
STATIC_PROTO(Int c_db_connection_type,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_add_preds,(void));
|
STATIC_PROTO(Int c_db_add_preds,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_preds_conn_start ,(void));
|
STATIC_PROTO(Int c_db_preds_conn_start ,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_preds_conn_continue ,(void));
|
STATIC_PROTO(Int c_db_preds_conn_continue ,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_connection_start ,(void));
|
STATIC_PROTO(Int c_db_connection_start ,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_connection_continue ,(void));
|
STATIC_PROTO(Int c_db_connection_continue ,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_check_if_exists_pred,(void));
|
STATIC_PROTO(Int c_db_check_if_exists_pred,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_delete_predicate,(void));
|
STATIC_PROTO(Int c_db_delete_predicate,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_multi_queries_number,(void));
|
STATIC_PROTO(Int c_db_multi_queries_number,( USES_REGS1 ));
|
||||||
#ifdef MYDDAS_STATS
|
#ifdef MYDDAS_STATS
|
||||||
STATIC_PROTO(Int c_db_stats,(void));
|
STATIC_PROTO(Int c_db_stats,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_stats_walltime,(void));
|
STATIC_PROTO(Int c_db_stats_walltime,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_stats_translate,(void));
|
STATIC_PROTO(Int c_db_stats_translate,( USES_REGS1 ));
|
||||||
STATIC_PROTO(Int c_db_stats_time,(void));
|
STATIC_PROTO(Int c_db_stats_time,( USES_REGS1 ));
|
||||||
#endif
|
#endif
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
STATIC_PROTO(Int c_db_check,(void));
|
STATIC_PROTO(Int c_db_check,( USES_REGS1 ));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Yap_InitMYDDAS_SharedPreds(void)
|
void Yap_InitMYDDAS_SharedPreds(void)
|
||||||
@ -102,7 +102,7 @@ void Yap_InitBackMYDDAS_SharedPreds(void)
|
|||||||
|
|
||||||
/* Initialize all of the MYDDAS global structures */
|
/* Initialize all of the MYDDAS global structures */
|
||||||
static Int
|
static Int
|
||||||
c_db_initialize_myddas(void){
|
c_db_initialize_myddas( USES_REGS1 ){
|
||||||
Yap_REGS.MYDDAS_GLOBAL_POINTER = myddas_init_initialize_myddas();
|
Yap_REGS.MYDDAS_GLOBAL_POINTER = myddas_init_initialize_myddas();
|
||||||
#ifdef MYDDAS_STATS
|
#ifdef MYDDAS_STATS
|
||||||
Yap_REGS.MYDDAS_GLOBAL_POINTER = myddas_stats_initialize_global_stats(Yap_REGS.MYDDAS_GLOBAL_POINTER);
|
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*/
|
NOTE: In order to use this predicate, the connection*/
|
||||||
/* c_db_connection_type: +Connection * ?Type */
|
/* c_db_connection_type: +Connection * ?Type */
|
||||||
static Int
|
static Int
|
||||||
c_db_connection_type (void){
|
c_db_connection_type ( USES_REGS1 ){
|
||||||
Term arg_con = Deref(ARG1);
|
Term arg_con = Deref(ARG1);
|
||||||
Term arg_type = Deref(ARG2);
|
Term arg_type = Deref(ARG2);
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ c_db_connection_type (void){
|
|||||||
|
|
||||||
/* db_add_preds: PredName * Arity * Module * Connection*/
|
/* db_add_preds: PredName * Arity * Module * Connection*/
|
||||||
static Int
|
static Int
|
||||||
c_db_add_preds (void){
|
c_db_add_preds ( USES_REGS1 ){
|
||||||
Term arg_nome = Deref(ARG1);
|
Term arg_nome = Deref(ARG1);
|
||||||
Term arg_aridade = Deref(ARG2);
|
Term arg_aridade = Deref(ARG2);
|
||||||
Term arg_module = Deref(ARG3);
|
Term arg_module = Deref(ARG3);
|
||||||
@ -164,7 +164,7 @@ c_db_add_preds (void){
|
|||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
c_db_check_if_exists_pred (void){
|
c_db_check_if_exists_pred ( USES_REGS1 ){
|
||||||
Term arg_nome = Deref(ARG1);
|
Term arg_nome = Deref(ARG1);
|
||||||
Term arg_aridade = Deref(ARG2);
|
Term arg_aridade = Deref(ARG2);
|
||||||
Term arg_module = Deref(ARG3);
|
Term arg_module = Deref(ARG3);
|
||||||
@ -182,7 +182,7 @@ c_db_check_if_exists_pred (void){
|
|||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
c_db_delete_predicate(void){
|
c_db_delete_predicate( USES_REGS1 ){
|
||||||
Term arg_module = Deref(ARG1);
|
Term arg_module = Deref(ARG1);
|
||||||
Term arg_name = Deref(ARG2);
|
Term arg_name = Deref(ARG2);
|
||||||
Term arg_arity = Deref(ARG3);
|
Term arg_arity = Deref(ARG3);
|
||||||
@ -203,7 +203,7 @@ c_db_delete_predicate(void){
|
|||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
c_db_multi_queries_number(void){
|
c_db_multi_queries_number( USES_REGS1 ){
|
||||||
Term arg_conn = Deref(ARG1);
|
Term arg_conn = Deref(ARG1);
|
||||||
Term arg_number = Deref(ARG2);
|
Term arg_number = Deref(ARG2);
|
||||||
|
|
||||||
@ -228,18 +228,18 @@ c_db_multi_queries_number(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
c_db_connection_start(void){
|
c_db_connection_start( USES_REGS1 ){
|
||||||
|
|
||||||
MYDDAS_UTIL_CONNECTION node =
|
MYDDAS_UTIL_CONNECTION node =
|
||||||
Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||||
|
|
||||||
EXTRA_CBACK_ARG(1,1)=(CELL) MkIntegerTerm((Int)node);
|
EXTRA_CBACK_ARG(1,1)=(CELL) MkIntegerTerm((Int)node);
|
||||||
|
|
||||||
return (c_db_connection_continue());
|
return (c_db_connection_continue( PASS_REGS1 ));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
c_db_connection_continue(void){
|
c_db_connection_continue( USES_REGS1 ){
|
||||||
Term arg_conn = Deref(ARG1);
|
Term arg_conn = Deref(ARG1);
|
||||||
|
|
||||||
MYDDAS_UTIL_CONNECTION node;
|
MYDDAS_UTIL_CONNECTION node;
|
||||||
@ -261,7 +261,7 @@ c_db_connection_continue(void){
|
|||||||
|
|
||||||
/* db_preds_conn : Connection(+) * Pred_name(-) * Pred_arity */
|
/* db_preds_conn : Connection(+) * Pred_name(-) * Pred_arity */
|
||||||
static Int
|
static Int
|
||||||
c_db_preds_conn_start (void){
|
c_db_preds_conn_start ( USES_REGS1 ){
|
||||||
Term arg_conn = Deref(ARG1);
|
Term arg_conn = Deref(ARG1);
|
||||||
|
|
||||||
Int *conn = (Int *) IntegerOfTerm(arg_conn);
|
Int *conn = (Int *) IntegerOfTerm(arg_conn);
|
||||||
@ -278,12 +278,12 @@ c_db_preds_conn_start (void){
|
|||||||
void *pointer = myddas_util_get_list_pred(node);
|
void *pointer = myddas_util_get_list_pred(node);
|
||||||
EXTRA_CBACK_ARG(4,1)=(CELL) MkIntegerTerm((Int)pointer);
|
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*/
|
/* db_preds_conn : Connection(+) * Pred_name(-) * Pred_arity*/
|
||||||
static Int
|
static Int
|
||||||
c_db_preds_conn_continue (void){
|
c_db_preds_conn_continue ( USES_REGS1 ){
|
||||||
Term module = Deref(ARG2);
|
Term module = Deref(ARG2);
|
||||||
Term name = Deref(ARG3);
|
Term name = Deref(ARG3);
|
||||||
Term arity = Deref(ARG4);
|
Term arity = Deref(ARG4);
|
||||||
@ -317,7 +317,7 @@ c_db_preds_conn_continue (void){
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
static Int
|
static Int
|
||||||
c_db_check(void){
|
c_db_check( USES_REGS1 ){
|
||||||
check_int();
|
check_int();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ c_db_check(void){
|
|||||||
#ifdef MYDDAS_STATS
|
#ifdef MYDDAS_STATS
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
c_db_stats_walltime(void){
|
c_db_stats_walltime( USES_REGS1 ){
|
||||||
Term arg_time = Deref(ARG1);
|
Term arg_time = Deref(ARG1);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -344,7 +344,7 @@ c_db_stats_walltime(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
c_db_stats_translate(void){
|
c_db_stats_translate( USES_REGS1 ){
|
||||||
Term arg_start = Deref(ARG1);
|
Term arg_start = Deref(ARG1);
|
||||||
Term arg_end = Deref(ARG2);
|
Term arg_end = Deref(ARG2);
|
||||||
|
|
||||||
@ -386,7 +386,7 @@ c_db_stats_translate(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
c_db_stats_time(void){
|
c_db_stats_time( USES_REGS1 ){
|
||||||
Term arg_reference = Deref(ARG1);
|
Term arg_reference = Deref(ARG1);
|
||||||
Term arg_time = Deref(ARG2);
|
Term arg_time = Deref(ARG2);
|
||||||
|
|
||||||
@ -473,7 +473,7 @@ c_db_stats_time(void){
|
|||||||
|
|
||||||
//Returns the stats of this module in a list
|
//Returns the stats of this module in a list
|
||||||
static Int
|
static Int
|
||||||
c_db_stats(void) {
|
c_db_stats( USES_REGS1 ) {
|
||||||
Term arg_conn = Deref(ARG1);
|
Term arg_conn = Deref(ARG1);
|
||||||
Term arg_list = Deref(ARG2);
|
Term arg_list = Deref(ARG2);
|
||||||
|
|
||||||
@ -655,6 +655,7 @@ c_db_stats(void) {
|
|||||||
/* from the mysql server */
|
/* from the mysql server */
|
||||||
void Yap_MYDDAS_delete_all_myddas_structs(void)
|
void Yap_MYDDAS_delete_all_myddas_structs(void)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
|
|
||||||
/* NAO ESQUECER DE FAZER ISTO TB PARA O DB_CLOSE*/
|
/* NAO ESQUECER DE FAZER ISTO TB PARA O DB_CLOSE*/
|
||||||
MYDDAS_GLOBAL global =
|
MYDDAS_GLOBAL global =
|
||||||
|
@ -56,6 +56,7 @@ myddas_util_connection_type(void *con){
|
|||||||
MYDDAS_UTIL_PREDICATE
|
MYDDAS_UTIL_PREDICATE
|
||||||
myddas_util_search_predicate(char *pred_name, Int pred_arity,
|
myddas_util_search_predicate(char *pred_name, Int pred_arity,
|
||||||
char *pred_module){
|
char *pred_module){
|
||||||
|
CACHE_REGS
|
||||||
MYDDAS_UTIL_PREDICATE pred=NULL;
|
MYDDAS_UTIL_PREDICATE pred=NULL;
|
||||||
MYDDAS_UTIL_CONNECTION top = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
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
|
void
|
||||||
myddas_util_delete_predicate(MYDDAS_UTIL_PREDICATE to_delete){
|
myddas_util_delete_predicate(MYDDAS_UTIL_PREDICATE to_delete){
|
||||||
|
CACHE_REGS
|
||||||
if (to_delete->next != NULL)
|
if (to_delete->next != NULL)
|
||||||
to_delete->next->previous = to_delete->previous;
|
to_delete->next->previous = to_delete->previous;
|
||||||
if (to_delete->previous != NULL)
|
if (to_delete->previous != NULL)
|
||||||
@ -109,7 +110,7 @@ myddas_util_delete_predicate(MYDDAS_UTIL_PREDICATE to_delete){
|
|||||||
|
|
||||||
void
|
void
|
||||||
myddas_util_delete_connection(void *conn){
|
myddas_util_delete_connection(void *conn){
|
||||||
|
CACHE_REGS
|
||||||
MYDDAS_UTIL_CONNECTION to_delete = myddas_util_search_connection(conn);
|
MYDDAS_UTIL_CONNECTION to_delete = myddas_util_search_connection(conn);
|
||||||
|
|
||||||
if (to_delete == NULL)
|
if (to_delete == NULL)
|
||||||
@ -141,6 +142,7 @@ myddas_util_delete_connection(void *conn){
|
|||||||
|
|
||||||
MYDDAS_UTIL_CONNECTION
|
MYDDAS_UTIL_CONNECTION
|
||||||
myddas_util_search_connection(void *conn){
|
myddas_util_search_connection(void *conn){
|
||||||
|
CACHE_REGS
|
||||||
MYDDAS_UTIL_CONNECTION list = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
MYDDAS_UTIL_CONNECTION list = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||||
|
|
||||||
#ifdef MYDDAS_STATS
|
#ifdef MYDDAS_STATS
|
||||||
@ -157,7 +159,7 @@ myddas_util_search_connection(void *conn){
|
|||||||
|
|
||||||
MYDDAS_UTIL_CONNECTION
|
MYDDAS_UTIL_CONNECTION
|
||||||
myddas_util_add_connection(void *conn, void *enviromment){
|
myddas_util_add_connection(void *conn, void *enviromment){
|
||||||
|
CACHE_REGS
|
||||||
MYDDAS_UTIL_CONNECTION node=NULL;
|
MYDDAS_UTIL_CONNECTION node=NULL;
|
||||||
MYDDAS_UTIL_CONNECTION temp=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*/
|
if there is any odbc connections left on the list*/
|
||||||
SQLHENV
|
SQLHENV
|
||||||
myddas_util_get_odbc_enviromment(SQLHDBC connection){
|
myddas_util_get_odbc_enviromment(SQLHDBC connection){
|
||||||
|
CACHE_REGS
|
||||||
MYDDAS_UTIL_CONNECTION top = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
MYDDAS_UTIL_CONNECTION top = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||||
|
|
||||||
for (;top != NULL;top=top->next)
|
for (;top != NULL;top=top->next)
|
||||||
@ -238,6 +241,7 @@ myddas_util_find_predicate(char *pred_name, Int pred_arity,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
myddas_util_delete_predicate_list(MYDDAS_UTIL_PREDICATE preds_list){
|
myddas_util_delete_predicate_list(MYDDAS_UTIL_PREDICATE preds_list){
|
||||||
|
CACHE_REGS
|
||||||
MYDDAS_UTIL_PREDICATE to_delete = NULL;
|
MYDDAS_UTIL_PREDICATE to_delete = NULL;
|
||||||
|
|
||||||
for (;preds_list != NULL;)
|
for (;preds_list != NULL;)
|
||||||
@ -321,7 +325,8 @@ myddas_util_table_write(MYSQL_RES *res_set){
|
|||||||
|
|
||||||
//DELETE THIS WHEN DB_STATS IS COMPLETED
|
//DELETE THIS WHEN DB_STATS IS COMPLETED
|
||||||
MyddasInt
|
MyddasInt
|
||||||
get_myddas_top(){
|
get_myddas_top( void ){
|
||||||
|
CACHE_REGS
|
||||||
if (Yap_REGS.MYDDAS_GLOBAL_POINTER == NULL)
|
if (Yap_REGS.MYDDAS_GLOBAL_POINTER == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
return (Int)Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
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
|
#ifdef DEBUG
|
||||||
void check_int(){
|
void check_int( void ){
|
||||||
|
CACHE_REGS
|
||||||
Int i;
|
Int i;
|
||||||
MYDDAS_UTIL_PREDICATE pred = NULL;
|
MYDDAS_UTIL_PREDICATE pred = NULL;
|
||||||
MYDDAS_UTIL_CONNECTION top = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
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) {
|
void Yap_init_local(void) {
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
|
CACHE_REGS
|
||||||
/* local data related to or-parallelism */
|
/* local data related to or-parallelism */
|
||||||
LOCAL = REMOTE + worker_id;
|
LOCAL = REMOTE + worker_id;
|
||||||
Set_LOCAL_top_cp((choiceptr) Yap_LocalBase);
|
Set_LOCAL_top_cp((choiceptr) Yap_LocalBase);
|
||||||
@ -209,6 +210,7 @@ void Yap_init_local(void) {
|
|||||||
|
|
||||||
void make_root_frames(void) {
|
void make_root_frames(void) {
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
|
CACHE_REGS
|
||||||
/* root or frame */
|
/* root or frame */
|
||||||
or_fr_ptr or_fr;
|
or_fr_ptr or_fr;
|
||||||
|
|
||||||
@ -248,6 +250,7 @@ void make_root_frames(void) {
|
|||||||
|
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
void init_workers(void) {
|
void init_workers(void) {
|
||||||
|
CACHE_REGS
|
||||||
int proc;
|
int proc;
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
return;
|
return;
|
||||||
|
@ -35,39 +35,39 @@
|
|||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
|
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
static Int p_freeze_choice_point(void);
|
static Int p_freeze_choice_point( USES_REGS1 );
|
||||||
static Int p_wake_choice_point(void);
|
static Int p_wake_choice_point( USES_REGS1 );
|
||||||
static Int p_reset_frozen_choice_points(void);
|
static Int p_reset_frozen_choice_points( USES_REGS1 );
|
||||||
static Int p_abolish_frozen_choice_points_until(void);
|
static Int p_abolish_frozen_choice_points_until( USES_REGS1 );
|
||||||
static Int p_abolish_frozen_choice_points_all(void);
|
static Int p_abolish_frozen_choice_points_all( USES_REGS1 );
|
||||||
static Int p_table(void);
|
static Int p_table( USES_REGS1 );
|
||||||
static Int p_tabling_mode(void);
|
static Int p_tabling_mode( USES_REGS1 );
|
||||||
static Int p_abolish_table(void);
|
static Int p_abolish_table( USES_REGS1 );
|
||||||
static Int p_abolish_all_tables(void);
|
static Int p_abolish_all_tables( USES_REGS1 );
|
||||||
static Int p_show_tabled_predicates(void);
|
static Int p_show_tabled_predicates( USES_REGS1 );
|
||||||
static Int p_show_table(void);
|
static Int p_show_table( USES_REGS1 );
|
||||||
static Int p_show_all_tables(void);
|
static Int p_show_all_tables( USES_REGS1 );
|
||||||
static Int p_show_global_trie(void);
|
static Int p_show_global_trie( USES_REGS1 );
|
||||||
static Int p_show_statistics_table(void);
|
static Int p_show_statistics_table( USES_REGS1 );
|
||||||
static Int p_show_statistics_tabling(void);
|
static Int p_show_statistics_tabling( USES_REGS1 );
|
||||||
static Int p_show_statistics_global_trie(void);
|
static Int p_show_statistics_global_trie( USES_REGS1 );
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
static Int p_yapor_threads(void);
|
static Int p_yapor_threads( USES_REGS1 );
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
static Int p_worker(void);
|
static Int p_worker( USES_REGS1 );
|
||||||
static Int p_yapor_on(void);
|
static Int p_yapor_on( USES_REGS1 );
|
||||||
static Int p_start_yapor(void);
|
static Int p_start_yapor( USES_REGS1 );
|
||||||
static Int p_default_sequential(void);
|
static Int p_default_sequential( USES_REGS1 );
|
||||||
static Int p_execution_mode(void);
|
static Int p_execution_mode( USES_REGS1 );
|
||||||
static Int p_performance(void);
|
static Int p_performance( USES_REGS1 );
|
||||||
static Int p_parallel_new_answer(void);
|
static Int p_parallel_new_answer( USES_REGS1 );
|
||||||
static Int p_parallel_yes_answer(void);
|
static Int p_parallel_yes_answer( USES_REGS1 );
|
||||||
static Int p_show_statistics_or(void);
|
static Int p_show_statistics_or( USES_REGS1 );
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
#if defined(YAPOR) && defined(TABLING)
|
#if defined(YAPOR) && defined(TABLING)
|
||||||
static Int p_show_statistics_opt(void);
|
static Int p_show_statistics_opt( USES_REGS1 );
|
||||||
#endif /* YAPOR && TABLING */
|
#endif /* YAPOR && TABLING */
|
||||||
static Int p_get_optyap_statistics(void);
|
static Int p_get_optyap_statistics( USES_REGS1 );
|
||||||
|
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
static inline realtime current_time(void);
|
static inline realtime current_time(void);
|
||||||
@ -172,7 +172,7 @@ void finish_yapor(void) {
|
|||||||
***********************************/
|
***********************************/
|
||||||
|
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
static Int p_freeze_choice_point(void) {
|
static Int p_freeze_choice_point( USES_REGS1 ) {
|
||||||
if (IsVarTerm(Deref(ARG1))) {
|
if (IsVarTerm(Deref(ARG1))) {
|
||||||
Int offset = freeze_current_cp();
|
Int offset = freeze_current_cp();
|
||||||
return Yap_unify(ARG1, MkIntegerTerm(offset));
|
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);
|
Term term_offset = Deref(ARG1);
|
||||||
if (IsIntegerTerm(term_offset))
|
if (IsIntegerTerm(term_offset))
|
||||||
wake_frozen_cp(IntegerOfTerm(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);
|
Term term_offset = Deref(ARG1);
|
||||||
if (IsIntegerTerm(term_offset))
|
if (IsIntegerTerm(term_offset))
|
||||||
abolish_frozen_cps_until(IntegerOfTerm(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();
|
abolish_frozen_cps_all();
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_table(void) {
|
static Int p_table( USES_REGS1 ) {
|
||||||
Term mod, t;
|
Term mod, t;
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
Atom at;
|
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;
|
Term mod, t, tvalue;
|
||||||
tab_ent_ptr tab_ent;
|
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;
|
Term mod, t;
|
||||||
tab_ent_ptr tab_ent;
|
tab_ent_ptr tab_ent;
|
||||||
sg_hash_ptr hash;
|
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;
|
tab_ent_ptr tab_ent;
|
||||||
sg_hash_ptr hash;
|
sg_hash_ptr hash;
|
||||||
sg_node_ptr sg_node;
|
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_ptr tab_ent;
|
||||||
|
|
||||||
tab_ent = GLOBAL_root_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;
|
Term mod, t;
|
||||||
tab_ent_ptr tab_ent;
|
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_ptr tab_ent;
|
||||||
|
|
||||||
tab_ent = GLOBAL_root_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);
|
show_global_trie(SHOW_MODE_STRUCTURE);
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_show_statistics_table(void) {
|
static Int p_show_statistics_table( USES_REGS1 ) {
|
||||||
Term mod, t;
|
Term mod, t;
|
||||||
tab_ent_ptr tab_ent;
|
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;
|
long total_bytes = 0, aux_bytes;
|
||||||
|
|
||||||
aux_bytes = 0;
|
aux_bytes = 0;
|
||||||
@ -489,7 +489,7 @@ static Int p_show_statistics_tabling(void) {
|
|||||||
return (TRUE);
|
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);
|
show_global_trie(SHOW_MODE_STATISTICS);
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
@ -500,7 +500,7 @@ static Int p_show_statistics_global_trie(void) {
|
|||||||
** YapOr C Predicates **
|
** YapOr C Predicates **
|
||||||
*********************************/
|
*********************************/
|
||||||
|
|
||||||
static Int p_yapor_threads(void) {
|
static Int p_yapor_threads( USES_REGS1 ) {
|
||||||
#if defined(YAPOR) && defined(THREADS)
|
#if defined(YAPOR) && defined(THREADS)
|
||||||
return Yap_unify(MkIntegerTerm(number_workers),ARG1);
|
return Yap_unify(MkIntegerTerm(number_workers),ARG1);
|
||||||
#else
|
#else
|
||||||
@ -510,19 +510,19 @@ static Int p_yapor_threads(void) {
|
|||||||
|
|
||||||
|
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
static Int p_worker(void) {
|
static Int p_worker( USES_REGS1 ) {
|
||||||
CurrentModule = USER_MODULE;
|
CurrentModule = USER_MODULE;
|
||||||
P = GETWORK_FIRST_TIME;
|
P = GETWORK_FIRST_TIME;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_yapor_on(void) {
|
static Int p_yapor_on( USES_REGS1 ) {
|
||||||
return (PARALLEL_EXECUTION_MODE);
|
return (PARALLEL_EXECUTION_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_start_yapor(void) {
|
static Int p_start_yapor( USES_REGS1 ) {
|
||||||
#ifdef TIMESTAMP_CHECK
|
#ifdef TIMESTAMP_CHECK
|
||||||
GLOBAL_timestamp = 0;
|
GLOBAL_timestamp = 0;
|
||||||
#endif /* TIMESTAMP_CHECK */
|
#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;
|
Term t;
|
||||||
t = Deref(ARG1);
|
t = Deref(ARG1);
|
||||||
if (IsVarTerm(t)) {
|
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;
|
Term t;
|
||||||
t = Deref(ARG1);
|
t = Deref(ARG1);
|
||||||
if (IsVarTerm(t)) {
|
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;
|
Term t;
|
||||||
realtime one_worker_execution_time = 0;
|
realtime one_worker_execution_time = 0;
|
||||||
int i;
|
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;
|
or_fr_ptr leftmost_or_fr;
|
||||||
|
|
||||||
length_answer = 0;
|
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;
|
GLOBAL_answers = YES_ANSWER;
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int p_show_statistics_or(void) {
|
static Int p_show_statistics_or( USES_REGS1 ) {
|
||||||
long total_bytes = 0, aux_bytes;
|
long total_bytes = 0, aux_bytes;
|
||||||
|
|
||||||
aux_bytes = 0;
|
aux_bytes = 0;
|
||||||
@ -733,7 +733,7 @@ static Int p_show_statistics_or(void) {
|
|||||||
**********************************/
|
**********************************/
|
||||||
|
|
||||||
#if defined(YAPOR) && defined(TABLING)
|
#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;
|
long total_bytes = 0, aux_bytes;
|
||||||
|
|
||||||
aux_bytes = 0;
|
aux_bytes = 0;
|
||||||
@ -783,7 +783,7 @@ static Int p_show_statistics_opt(void) {
|
|||||||
#endif /* YAPOR && TABLING */
|
#endif /* YAPOR && TABLING */
|
||||||
|
|
||||||
|
|
||||||
static Int p_get_optyap_statistics(void) {
|
static Int p_get_optyap_statistics( USES_REGS1 ) {
|
||||||
Term tbytes, tstructs;
|
Term tbytes, tstructs;
|
||||||
Int value, bytes = -1, structs = -1;
|
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) {
|
static inline void show_answers(void) {
|
||||||
|
CACHE_REGS
|
||||||
int i;
|
int i;
|
||||||
if (OrFr_qg_solutions(LOCAL_top_or_fr)) {
|
if (OrFr_qg_solutions(LOCAL_top_or_fr)) {
|
||||||
qg_ans_fr_ptr aux_answer1, aux_answer2;
|
qg_ans_fr_ptr aux_answer1, aux_answer2;
|
||||||
|
@ -23,18 +23,21 @@ typedef unsigned long bitmap;
|
|||||||
static inline choiceptr
|
static inline choiceptr
|
||||||
offset_to_cptr(Int node)
|
offset_to_cptr(Int node)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
return (choiceptr)(LCL0+node);
|
return (choiceptr)(LCL0+node);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Int
|
static inline Int
|
||||||
cptr_to_offset(choiceptr node)
|
cptr_to_offset(choiceptr node)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
return (Int)((CELL *)node-LCL0);
|
return (Int)((CELL *)node-LCL0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline choiceptr
|
static inline choiceptr
|
||||||
offset_to_cptr_with_null(Int node)
|
offset_to_cptr_with_null(Int node)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (node == 0L) return NULL;
|
if (node == 0L) return NULL;
|
||||||
return (choiceptr)(LCL0+node);
|
return (choiceptr)(LCL0+node);
|
||||||
}
|
}
|
||||||
@ -42,6 +45,7 @@ offset_to_cptr_with_null(Int node)
|
|||||||
static inline Int
|
static inline Int
|
||||||
cptr_to_offset_with_null(choiceptr node)
|
cptr_to_offset_with_null(choiceptr node)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (node == NULL) return 0L;
|
if (node == NULL) return 0L;
|
||||||
return (Int)((CELL *)node-LCL0);
|
return (Int)((CELL *)node-LCL0);
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
** -------------------------- */
|
** -------------------------- */
|
||||||
|
|
||||||
void prune_shared_branch(choiceptr prune_cp) {
|
void prune_shared_branch(choiceptr prune_cp) {
|
||||||
|
CACHE_REGS
|
||||||
int i, ltt, depth;
|
int i, ltt, depth;
|
||||||
bitmap members;
|
bitmap members;
|
||||||
choiceptr leftmost_cp;
|
choiceptr leftmost_cp;
|
||||||
|
@ -284,6 +284,7 @@ void PUT_OUT_REQUESTABLE(int p) {
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
void SCH_update_local_or_tops(void) {
|
void SCH_update_local_or_tops(void) {
|
||||||
|
CACHE_REGS
|
||||||
Set_LOCAL_top_cp(Get_LOCAL_top_cp()->cp_b);
|
Set_LOCAL_top_cp(Get_LOCAL_top_cp()->cp_b);
|
||||||
LOCAL_top_or_fr = Get_LOCAL_top_cp()->cp_or_fr;
|
LOCAL_top_or_fr = Get_LOCAL_top_cp()->cp_or_fr;
|
||||||
return;
|
return;
|
||||||
@ -292,6 +293,7 @@ void SCH_update_local_or_tops(void) {
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
void SCH_refuse_share_request_if_any(void) {
|
void SCH_refuse_share_request_if_any(void) {
|
||||||
|
CACHE_REGS
|
||||||
if (SCH_any_share_request) {
|
if (SCH_any_share_request) {
|
||||||
REMOTE_reply_signal(LOCAL_share_request) = no_sharing;
|
REMOTE_reply_signal(LOCAL_share_request) = no_sharing;
|
||||||
LOCAL_share_request = MAX_WORKERS;
|
LOCAL_share_request = MAX_WORKERS;
|
||||||
@ -303,6 +305,7 @@ void SCH_refuse_share_request_if_any(void) {
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
void SCH_set_load(choiceptr current_cp) {
|
void SCH_set_load(choiceptr current_cp) {
|
||||||
|
CACHE_REGS
|
||||||
Int lub; /* local untried branches */
|
Int lub; /* local untried branches */
|
||||||
choiceptr previous_cp = current_cp->cp_b;
|
choiceptr previous_cp = current_cp->cp_b;
|
||||||
|
|
||||||
@ -326,6 +329,7 @@ void SCH_set_load(choiceptr current_cp) {
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
void SCH_new_alternative(yamop *curpc, yamop *new) {
|
void SCH_new_alternative(yamop *curpc, yamop *new) {
|
||||||
|
CACHE_REGS
|
||||||
OrFr_alternative(LOCAL_top_or_fr) = new;
|
OrFr_alternative(LOCAL_top_or_fr) = new;
|
||||||
BRANCH(worker_id, OrFr_depth(LOCAL_top_or_fr)) = YAMOP_OR_ARG(curpc);
|
BRANCH(worker_id, OrFr_depth(LOCAL_top_or_fr)) = YAMOP_OR_ARG(curpc);
|
||||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||||
@ -351,6 +355,7 @@ void CUT_send_prune_request(int worker, choiceptr prune_cp) {
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
void CUT_reset_prune_request(void) {
|
void CUT_reset_prune_request(void) {
|
||||||
|
CACHE_REGS
|
||||||
LOCK_WORKER(worker_id);
|
LOCK_WORKER(worker_id);
|
||||||
if (Get_LOCAL_prune_request() && EQUAL_OR_YOUNGER_CP(Get_LOCAL_prune_request(), Get_LOCAL_top_cp()))
|
if (Get_LOCAL_prune_request() && EQUAL_OR_YOUNGER_CP(Get_LOCAL_prune_request(), Get_LOCAL_top_cp()))
|
||||||
Set_LOCAL_prune_request(NULL);
|
Set_LOCAL_prune_request(NULL);
|
||||||
@ -366,6 +371,7 @@ void CUT_reset_prune_request(void) {
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
int CUT_last_worker_left_pending_prune(or_fr_ptr or_frame) {
|
int CUT_last_worker_left_pending_prune(or_fr_ptr or_frame) {
|
||||||
|
CACHE_REGS
|
||||||
int i, depth, ltt;
|
int i, depth, ltt;
|
||||||
bitmap members;
|
bitmap members;
|
||||||
|
|
||||||
@ -383,6 +389,7 @@ int CUT_last_worker_left_pending_prune(or_fr_ptr or_frame) {
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
or_fr_ptr CUT_leftmost_or_frame(void) {
|
or_fr_ptr CUT_leftmost_or_frame(void) {
|
||||||
|
CACHE_REGS
|
||||||
int i, depth, ltt;
|
int i, depth, ltt;
|
||||||
bitmap members;
|
bitmap members;
|
||||||
or_fr_ptr leftmost_or_fr, or_fr, nearest_or_fr;
|
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
|
static inline
|
||||||
void CUT_store_answer(or_fr_ptr or_frame, qg_ans_fr_ptr new_answer) {
|
void CUT_store_answer(or_fr_ptr or_frame, qg_ans_fr_ptr new_answer) {
|
||||||
|
CACHE_REGS
|
||||||
int ltt;
|
int ltt;
|
||||||
qg_sol_fr_ptr *solution_ptr;
|
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
|
static inline
|
||||||
void CUT_store_answers(or_fr_ptr or_frame, qg_sol_fr_ptr new_solution) {
|
void CUT_store_answers(or_fr_ptr or_frame, qg_sol_fr_ptr new_solution) {
|
||||||
|
CACHE_REGS
|
||||||
int ltt;
|
int ltt;
|
||||||
qg_sol_fr_ptr *solution_ptr;
|
qg_sol_fr_ptr *solution_ptr;
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ STD_PROTO(static inline void move_up_to_prune_request, (void));
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
void PUT_NO_WORK_IN_UPPER_NODES(void) {
|
void PUT_NO_WORK_IN_UPPER_NODES(void) {
|
||||||
|
CACHE_REGS
|
||||||
or_fr_ptr current_node, nearest_livenode;
|
or_fr_ptr current_node, nearest_livenode;
|
||||||
current_node = LOCAL_top_or_fr;
|
current_node = LOCAL_top_or_fr;
|
||||||
while ((nearest_livenode = OrFr_nearest_livenode(current_node))) {
|
while ((nearest_livenode = OrFr_nearest_livenode(current_node))) {
|
||||||
@ -100,6 +101,7 @@ void PUT_OUT_ROOT_NODE(int worker_num) {
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
void move_up_to_prune_request(void) {
|
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()));
|
YAPOR_ERROR_CHECKING(move_up_to_prune_request, EQUAL_OR_YOUNGER_CP(Get_LOCAL_prune_request(), Get_LOCAL_top_cp()));
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -140,6 +142,7 @@ void move_up_to_prune_request(void) {
|
|||||||
** -------------------------- */
|
** -------------------------- */
|
||||||
|
|
||||||
int get_work(void) {
|
int get_work(void) {
|
||||||
|
CACHE_REGS
|
||||||
int counter;
|
int counter;
|
||||||
bitmap stable_busy;
|
bitmap stable_busy;
|
||||||
yamop *alt_with_work;
|
yamop *alt_with_work;
|
||||||
@ -265,6 +268,7 @@ int get_work(void) {
|
|||||||
|
|
||||||
static
|
static
|
||||||
int move_up_one_node(or_fr_ptr nearest_livenode) {
|
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()));
|
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);
|
LOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||||
@ -519,6 +523,7 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
|
|||||||
|
|
||||||
static
|
static
|
||||||
int get_work_below(void){
|
int get_work_below(void){
|
||||||
|
CACHE_REGS
|
||||||
int i, worker_p, big_load;
|
int i, worker_p, big_load;
|
||||||
bitmap busy_below, idle_below;
|
bitmap busy_below, idle_below;
|
||||||
|
|
||||||
@ -548,6 +553,7 @@ int get_work_below(void){
|
|||||||
|
|
||||||
static
|
static
|
||||||
int get_work_above(void){
|
int get_work_above(void){
|
||||||
|
CACHE_REGS
|
||||||
int i, worker_p, big_load;
|
int i, worker_p, big_load;
|
||||||
bitmap visible_busy_above, visible_idle_above;
|
bitmap visible_busy_above, visible_idle_above;
|
||||||
|
|
||||||
@ -601,6 +607,7 @@ int get_work_above(void){
|
|||||||
|
|
||||||
static
|
static
|
||||||
int find_a_better_position(void){
|
int find_a_better_position(void){
|
||||||
|
CACHE_REGS
|
||||||
int i;
|
int i;
|
||||||
bitmap busy_above, idle_above;
|
bitmap busy_above, idle_above;
|
||||||
BITMAP_difference(busy_above, GLOBAL_bm_present_workers, OrFr_members(LOCAL_top_or_fr));
|
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
|
static
|
||||||
int search_for_hidden_shared_work(bitmap stable_busy){
|
int search_for_hidden_shared_work(bitmap stable_busy){
|
||||||
|
CACHE_REGS
|
||||||
int i;
|
int i;
|
||||||
bitmap invisible_work, idle_below;
|
bitmap invisible_work, idle_below;
|
||||||
BITMAP_intersection(invisible_work, stable_busy, GLOBAL_bm_requestable_workers);
|
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) {
|
void make_root_choice_point(void) {
|
||||||
|
CACHE_REGS
|
||||||
if (worker_id == 0) {
|
if (worker_id == 0) {
|
||||||
SetOrFr_node(GLOBAL_root_or_fr, B);
|
SetOrFr_node(GLOBAL_root_or_fr, B);
|
||||||
Set_LOCAL_top_cp(B);
|
Set_LOCAL_top_cp(B);
|
||||||
@ -96,6 +97,7 @@ void make_root_choice_point(void) {
|
|||||||
|
|
||||||
|
|
||||||
void free_root_choice_point(void) {
|
void free_root_choice_point(void) {
|
||||||
|
CACHE_REGS
|
||||||
B = Get_LOCAL_top_cp()->cp_b;
|
B = Get_LOCAL_top_cp()->cp_b;
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
Set_LOCAL_top_cp_on_stack((choiceptr) Yap_LocalBase);
|
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;
|
int worker_q = LOCAL_share_request;
|
||||||
|
|
||||||
if (! BITMAP_member(OrFr_members(REMOTE_top_or_fr(worker_q)), worker_id) ||
|
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) {
|
int q_share_work(int worker_p) {
|
||||||
|
CACHE_REGS
|
||||||
LOCK_OR_FRAME(LOCAL_top_or_fr);
|
LOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||||
if (Get_REMOTE_prune_request(worker_p)) {
|
if (Get_REMOTE_prune_request(worker_p)) {
|
||||||
/* worker p with prune request */
|
/* worker p with prune request */
|
||||||
@ -200,6 +204,7 @@ int q_share_work(int worker_p) {
|
|||||||
|
|
||||||
static
|
static
|
||||||
void share_private_nodes(int worker_q) {
|
void share_private_nodes(int worker_q) {
|
||||||
|
CACHE_REGS
|
||||||
choiceptr sharing_node = B;
|
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) {
|
void private_completion(sg_fr_ptr sg_fr) {
|
||||||
|
CACHE_REGS
|
||||||
/* complete subgoals */
|
/* complete subgoals */
|
||||||
#ifdef LIMIT_TABLING
|
#ifdef LIMIT_TABLING
|
||||||
sg_fr_ptr aux_sg_fr;
|
sg_fr_ptr aux_sg_fr;
|
||||||
@ -142,6 +143,7 @@ void private_completion(sg_fr_ptr sg_fr) {
|
|||||||
|
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
void public_completion(void) {
|
void public_completion(void) {
|
||||||
|
CACHE_REGS
|
||||||
dep_fr_ptr chain_dep_fr, next_dep_fr;
|
dep_fr_ptr chain_dep_fr, next_dep_fr;
|
||||||
or_fr_ptr chain_or_fr, top_or_fr, next_or_fr;
|
or_fr_ptr chain_or_fr, top_or_fr, next_or_fr;
|
||||||
susp_fr_ptr susp_fr, next_susp_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) {
|
void complete_suspension_frames(or_fr_ptr or_fr) {
|
||||||
|
CACHE_REGS
|
||||||
dep_fr_ptr chain_dep_fr;
|
dep_fr_ptr chain_dep_fr;
|
||||||
or_fr_ptr chain_or_fr;
|
or_fr_ptr chain_or_fr;
|
||||||
susp_fr_ptr susp_fr;
|
susp_fr_ptr susp_fr;
|
||||||
@ -318,6 +321,7 @@ void complete_suspension_frames(or_fr_ptr or_fr) {
|
|||||||
|
|
||||||
|
|
||||||
void suspend_branch(void) {
|
void suspend_branch(void) {
|
||||||
|
CACHE_REGS
|
||||||
or_fr_ptr or_frame;
|
or_fr_ptr or_frame;
|
||||||
|
|
||||||
/* suspension only occurs in shared nodes that **
|
/* 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) {
|
void resume_suspension_frame(susp_fr_ptr resume_fr, or_fr_ptr top_or_fr) {
|
||||||
|
CACHE_REGS
|
||||||
or_fr_ptr or_frame;
|
or_fr_ptr or_frame;
|
||||||
sg_fr_ptr sg_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) {
|
static inline Int freeze_current_cp(void) {
|
||||||
|
CACHE_REGS
|
||||||
choiceptr freeze_cp = B;
|
choiceptr freeze_cp = B;
|
||||||
|
|
||||||
B_FZ = freeze_cp;
|
B_FZ = freeze_cp;
|
||||||
@ -439,6 +440,7 @@ static inline Int freeze_current_cp(void) {
|
|||||||
|
|
||||||
|
|
||||||
static inline void wake_frozen_cp(Int frozen_offset) {
|
static inline void wake_frozen_cp(Int frozen_offset) {
|
||||||
|
CACHE_REGS
|
||||||
choiceptr frozen_cp = (choiceptr)(Yap_LocalBase - frozen_offset);
|
choiceptr frozen_cp = (choiceptr)(Yap_LocalBase - frozen_offset);
|
||||||
|
|
||||||
restore_bindings(TR, frozen_cp->cp_tr);
|
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) {
|
static inline void abolish_frozen_cps_until(Int frozen_offset) {
|
||||||
|
CACHE_REGS
|
||||||
choiceptr frozen_cp = (choiceptr)(Yap_LocalBase - frozen_offset);
|
choiceptr frozen_cp = (choiceptr)(Yap_LocalBase - frozen_offset);
|
||||||
|
|
||||||
B_FZ = frozen_cp;
|
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) {
|
static inline void abolish_frozen_cps_all(void) {
|
||||||
|
CACHE_REGS
|
||||||
B_FZ = (choiceptr) Yap_LocalBase;
|
B_FZ = (choiceptr) Yap_LocalBase;
|
||||||
H_FZ = (CELL *) Yap_GlobalBase;
|
H_FZ = (CELL *) Yap_GlobalBase;
|
||||||
TR_FZ = (tr_fr_ptr) Yap_TrailBase;
|
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) {
|
static inline void adjust_freeze_registers(void) {
|
||||||
|
CACHE_REGS
|
||||||
B_FZ = DepFr_cons_cp(LOCAL_top_dep_fr);
|
B_FZ = DepFr_cons_cp(LOCAL_top_dep_fr);
|
||||||
H_FZ = B_FZ->cp_h;
|
H_FZ = B_FZ->cp_h;
|
||||||
TR_FZ = B_FZ->cp_tr;
|
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) {
|
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);
|
TABLING_ERROR_CHECKING(unbind_variables, unbind_tr < end_tr);
|
||||||
/* unbind loop */
|
/* unbind loop */
|
||||||
while (unbind_tr != end_tr) {
|
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) {
|
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);
|
TABLING_ERROR_CHECKING(rebind_variables, rebind_tr < end_tr);
|
||||||
/* rebind loop */
|
/* rebind loop */
|
||||||
Yap_NEW_MAHASH((ma_h_inner_struct *)H);
|
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) {
|
static inline void restore_bindings(tr_fr_ptr unbind_tr, tr_fr_ptr rebind_tr) {
|
||||||
|
CACHE_REGS
|
||||||
CELL ref;
|
CELL ref;
|
||||||
tr_fr_ptr end_tr;
|
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) {
|
static inline CELL *expand_auxiliary_stack(CELL *stack) {
|
||||||
|
CACHE_REGS
|
||||||
void *old_top = Yap_TrailTop;
|
void *old_top = Yap_TrailTop;
|
||||||
INFORMATION_MESSAGE("Expanding trail in 64 Kbytes");
|
INFORMATION_MESSAGE("Expanding trail in 64 Kbytes");
|
||||||
if (! Yap_growtrail(K64, TRUE)) { /* TRUE means 'contiguous_only' */
|
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) {
|
static inline void abolish_incomplete_subgoals(choiceptr prune_cp) {
|
||||||
|
CACHE_REGS
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
if (EQUAL_OR_YOUNGER_CP(GetOrFr_node(LOCAL_top_susp_or_fr), prune_cp))
|
if (EQUAL_OR_YOUNGER_CP(GetOrFr_node(LOCAL_top_susp_or_fr), prune_cp))
|
||||||
pruning_over_tabling_data_structures();
|
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) {
|
static inline void collect_suspension_frames(or_fr_ptr or_fr) {
|
||||||
|
CACHE_REGS
|
||||||
int depth;
|
int depth;
|
||||||
or_fr_ptr *susp_ptr;
|
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)
|
Yap_TrailTop --> | | <-- stack_terms_base (TRIE_COMPACT_PAIRS)
|
||||||
-----------
|
-----------
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
CACHE_REGS
|
||||||
CELL *stack_vars = *stack_vars_ptr;
|
CELL *stack_vars = *stack_vars_ptr;
|
||||||
CELL *stack_terms_limit = (CELL *) TR;
|
CELL *stack_terms_limit = (CELL *) TR;
|
||||||
#ifdef TRIE_COMPACT_PAIRS
|
#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) {
|
sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
|
||||||
|
CACHE_REGS
|
||||||
CELL *stack_vars;
|
CELL *stack_vars;
|
||||||
int i, subs_arity, pred_arity;
|
int i, subs_arity, pred_arity;
|
||||||
tab_ent_ptr tab_ent;
|
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) {
|
ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
||||||
#define subs_arity *subs_ptr
|
#define subs_arity *subs_ptr
|
||||||
|
CACHE_REGS
|
||||||
CELL *stack_vars;
|
CELL *stack_vars;
|
||||||
int i, vars_arity;
|
int i, vars_arity;
|
||||||
ans_node_ptr current_ans_node;
|
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) {
|
void load_answer(ans_node_ptr current_ans_node, CELL *subs_ptr) {
|
||||||
|
CACHE_REGS
|
||||||
#define subs_arity *subs_ptr
|
#define subs_arity *subs_ptr
|
||||||
CELL *stack_terms;
|
CELL *stack_terms;
|
||||||
int i;
|
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) {
|
CELL *exec_substitution(gt_node_ptr current_node, CELL *aux_stack) {
|
||||||
|
CACHE_REGS
|
||||||
#define subs_arity *subs_ptr
|
#define subs_arity *subs_ptr
|
||||||
CELL *stack_terms, *subs_ptr;
|
CELL *stack_terms, *subs_ptr;
|
||||||
Term t;
|
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 --> | |
|
Yap_TrailTop --> | |
|
||||||
-----------
|
-----------
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
CACHE_REGS
|
||||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||||
gt_node_ptr current_node = GLOBAL_root_gt;
|
gt_node_ptr current_node = GLOBAL_root_gt;
|
||||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
#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 --> | |
|
Yap_TrailTop --> | |
|
||||||
-----------
|
-----------
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
CACHE_REGS
|
||||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||||
gt_node_ptr current_node = GLOBAL_root_gt;
|
gt_node_ptr current_node = GLOBAL_root_gt;
|
||||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
#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)
|
Yap_TrailTop --> | | <-- stack_terms_base (TRIE_COMPACT_PAIRS)
|
||||||
-----------
|
-----------
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
CACHE_REGS
|
||||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||||
int vars_arity = *vars_arity_ptr;
|
int vars_arity = *vars_arity_ptr;
|
||||||
#else
|
#else
|
||||||
|
@ -34,7 +34,8 @@ static PL_blob_t unregistered_blob_atom =
|
|||||||
PL_EXPORT(int)
|
PL_EXPORT(int)
|
||||||
PL_is_blob(term_t t, PL_blob_t **type)
|
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;
|
Atom a;
|
||||||
BlobPropEntry *b;
|
BlobPropEntry *b;
|
||||||
|
|
||||||
@ -88,6 +89,7 @@ lookupBlob(void *blob, size_t len, PL_blob_t *type)
|
|||||||
PL_EXPORT(int)
|
PL_EXPORT(int)
|
||||||
PL_unify_blob(term_t t, void *blob, size_t len, PL_blob_t *type)
|
PL_unify_blob(term_t t, void *blob, size_t len, PL_blob_t *type)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
AtomEntry *ae;
|
AtomEntry *ae;
|
||||||
|
|
||||||
if (!blob)
|
if (!blob)
|
||||||
@ -96,7 +98,7 @@ PL_unify_blob(term_t t, void *blob, size_t len, PL_blob_t *type)
|
|||||||
if (!ae) {
|
if (!ae) {
|
||||||
return FALSE;
|
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)
|
PL_EXPORT(int)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -98,6 +98,7 @@ SWIAtomToAtom(atom_t at)
|
|||||||
static inline Term
|
static inline Term
|
||||||
SWIModuleToModule(module_t m)
|
SWIModuleToModule(module_t m)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
if (m)
|
if (m)
|
||||||
return (CELL)m;
|
return (CELL)m;
|
||||||
if (CurrentModule)
|
if (CurrentModule)
|
||||||
|
@ -145,7 +145,7 @@ gen_hstruct(Inp,Out) :-
|
|||||||
Out = "#include \"ratoms.h\"".
|
Out = "#include \"ratoms.h\"".
|
||||||
gen_hstruct(Inp,Out) :-
|
gen_hstruct(Inp,Out) :-
|
||||||
Inp = "START_WORKER_LOCAL", !,
|
Inp = "START_WORKER_LOCAL", !,
|
||||||
Out = "static void RestoreWorker(int wid) {",
|
Out = "static void RestoreWorker(int wid USES_REGS) {",
|
||||||
assert(globals(worker_init)).
|
assert(globals(worker_init)).
|
||||||
gen_hstruct(Inp,Out) :-
|
gen_hstruct(Inp,Out) :-
|
||||||
Inp = "END_WORKER_LOCAL", !,
|
Inp = "END_WORKER_LOCAL", !,
|
||||||
|
@ -77,7 +77,7 @@ header(W) :-
|
|||||||
header_rclause(W) :-
|
header_rclause(W) :-
|
||||||
format(W,'~n /* This file was generated automatically by \"yap -L misc/buildops\"~n please do not update */~n~n
|
format(W,'~n /* This file was generated automatically by \"yap -L misc/buildops\"~n please do not update */~n~n
|
||||||
static void
|
static void
|
||||||
restore_opcodes(yamop *pc, yamop *max)
|
restore_opcodes(yamop *pc, yamop *max USES_REGS)
|
||||||
{
|
{
|
||||||
yamop *opc = NULL;
|
yamop *opc = NULL;
|
||||||
do {
|
do {
|
||||||
@ -369,11 +369,11 @@ output_walk(C,"e",[Op|Ops]) :-
|
|||||||
special_walk_op(Op), !, % Nstop and friends
|
special_walk_op(Op), !, % Nstop and friends
|
||||||
output_ewalks(C,[Op|Ops]).
|
output_ewalks(C,[Op|Ops]).
|
||||||
output_walk(C,"sssllp",[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_ewalks(C,[Op|Ops]).
|
||||||
output_walk(C,"l",[Op|_]) :-
|
output_walk(C,"l",[Op|_]) :-
|
||||||
special_walk_op(Op), !, % IDB
|
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,_) :-
|
output_walk(C,T,_) :-
|
||||||
format(C,' pc = NEXTOP(pc,~s);
|
format(C,' pc = NEXTOP(pc,~s);
|
||||||
break;~n',[T]).
|
break;~n',[T]).
|
||||||
@ -391,29 +391,29 @@ output_ewalks(C,["copy_idb_term"|Ops]) :-
|
|||||||
format(C,' return found_idb_clause(pc, startp, endp);~n',[]),
|
format(C,' return found_idb_clause(pc, startp, endp);~n',[]),
|
||||||
output_ewalks(C,Ops).
|
output_ewalks(C,Ops).
|
||||||
output_ewalks(C,["undef_p"|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,Ops).
|
||||||
output_ewalks(C,["spy_pred"|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,Ops).
|
||||||
output_ewalks(C,["expand_index"|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,Ops).
|
||||||
output_ewalks(C,["index_pred"|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,Ops).
|
||||||
output_ewalks(C,["lock_pred"|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,Ops).
|
||||||
output_ewalks(C,["op_fail"|Ops]) :-
|
output_ewalks(C,["op_fail"|Ops]) :-
|
||||||
format(C,' if (codeptr == FAILCODE)
|
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);
|
format(C,' pc = NEXTOP(pc,~s);
|
||||||
break;~n',["e"]),
|
break;~n',["e"]),
|
||||||
output_ewalks(C,Ops).
|
output_ewalks(C,Ops).
|
||||||
output_ewalks(C,["trust_fail"|Ops]) :-
|
output_ewalks(C,["trust_fail"|Ops]) :-
|
||||||
format(C,' if (codeptr == TRUSTFAILCODE)
|
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);
|
format(C,' pc = NEXTOP(pc,~s);
|
||||||
break;~n',["e"]),
|
break;~n',["e"]),
|
||||||
output_ewalks(C,Ops).
|
output_ewalks(C,Ops).
|
||||||
|
@ -251,22 +251,22 @@ extern PL_local_data_t lds;
|
|||||||
|
|
||||||
#define GLOBAL_LD (PL_local_data_p)
|
#define GLOBAL_LD (PL_local_data_p)
|
||||||
|
|
||||||
#undef LD
|
|
||||||
|
|
||||||
#if !defined(O_PLMT) && !defined(YAPOR)
|
#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 ARG1_LD void
|
||||||
#define ARG_LD
|
#define ARG_LD
|
||||||
#define GET_LD
|
#define GET_LD
|
||||||
#define PRED_LD
|
#define PRED_LD
|
||||||
#define PASS_LD
|
#define PASS_LD
|
||||||
|
#define PASS_LD1
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define LOCAL_LD (__PL_ld)
|
#define LOCAL_LD (__PL_ld)
|
||||||
#define LD LOCAL_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 ARG1_LD PL_local_data_t *__PL_ld
|
||||||
|
|
||||||
#define ARG_LD , ARG1_LD
|
#define ARG_LD , ARG1_LD
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
/* vsc: needs defining before getting rid of YAP locks */
|
/* vsc: needs defining before getting rid of YAP locks */
|
||||||
static inline int
|
static inline int
|
||||||
do_startCritical(void) {
|
do_startCritical(void) {
|
||||||
|
CACHE_REGS
|
||||||
YAPEnterCriticalSection();
|
YAPEnterCriticalSection();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -833,7 +833,8 @@ PL_dispatch(int fd, int wait)
|
|||||||
YAP: YAP_Atom YAP_AtomOfTerm(Term) */
|
YAP: YAP_Atom YAP_AtomOfTerm(Term) */
|
||||||
int PL_get_atom__LD(term_t ts, atom_t *a ARG_LD)
|
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))
|
if ( !IsAtomTerm(t))
|
||||||
return 0;
|
return 0;
|
||||||
*a = YAP_SWIAtomFromAtom(AtomOfTerm(t));
|
*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)
|
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 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;
|
return to;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PL_is_variable__LD(term_t ts ARG_LD)
|
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);
|
return YAP_IsVarTerm(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PL_unify_atom__LD(term_t t, atom_t at ARG_LD)
|
int PL_unify_atom__LD(term_t t, atom_t at ARG_LD)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
YAP_Term cterm = MkAtomTerm(YAP_AtomFromSWIAtom(at));
|
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)
|
/* SWI: int PL_unify_integer(term_t ?t, long n)
|
||||||
YAP long int unify(YAP_Term* a, Term* b) */
|
YAP long int unify(YAP_Term* a, Term* b) */
|
||||||
int PL_unify_integer__LD(term_t t, long n ARG_LD)
|
int PL_unify_integer__LD(term_t t, long n ARG_LD)
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term iterm = MkIntegerTerm(n);
|
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);
|
extern int Yap_getInputStream(term_t t, IOSTREAM **s);
|
||||||
|
@ -238,6 +238,7 @@ true :- true.
|
|||||||
% then we can execute the programs.
|
% then we can execute the programs.
|
||||||
'$startup_goals' :-
|
'$startup_goals' :-
|
||||||
recorded('$startup_goal',G,_),
|
recorded('$startup_goal',G,_),
|
||||||
|
writeln(G),
|
||||||
'$current_module'(Module),
|
'$current_module'(Module),
|
||||||
'$system_catch'('$query'(once(G), []),Module,Error,user:'$Error'(Error)),
|
'$system_catch'('$query'(once(G), []),Module,Error,user:'$Error'(Error)),
|
||||||
fail.
|
fail.
|
||||||
|
Reference in New Issue
Block a user