Merge branch 'master' of ssh://yap.git.sourceforge.net/gitroot/yap/yap-6.3

This commit is contained in:
U-WIN-ENP104VVO3U\Vítor Santos Costa 2011-06-06 10:21:40 +01:00
commit 82d45468fb
223 changed files with 22013 additions and 8958 deletions

View File

@ -53,7 +53,7 @@ Cell *C, OldC;
Cell move_structures(Cell c)
{
Cell *NewC, *NewH;
Cell OldC,OldH;
Cell OldC,LOCAL_OldH;
OldC=deref((Cell) c);
/*
@ -67,7 +67,7 @@ Cell OldC,OldH;
return(OldC);
}
OldH=(Cell) beam_H;
LOCAL_OldH=(Cell) beam_H;
NewH=beam_H;
if (isappl(OldC)) {
int i,arity;
@ -81,7 +81,7 @@ Cell OldC,OldH;
NewH++;
NewC++;
}
return(absappl(OldH));
return(absappl(LOCAL_OldH));
}
/* else if (ispair(c)) { */
NewC=(Cell *) reppair(OldC);
@ -90,7 +90,7 @@ Cell OldC,OldH;
NewC++;
NewH++;
*NewH=move_structures((Cell) NewC);
return(abspair(OldH));
return(abspair(LOCAL_OldH));
}

View File

@ -440,7 +440,7 @@ if (a==NULL) return;
Cell copy_structures(Cell c)
{
Cell *NewC, *NewH;
Cell OldC,OldH;
Cell OldC,LOCAL_OldH;
OldC=deref((Cell) c);
@ -451,7 +451,7 @@ Cell OldC,OldH;
return(OldC);
}
OldH=(Cell) beam_H;
LOCAL_OldH=(Cell) beam_H;
NewH=beam_H;
if (isappl(OldC)) {
int i,arity;
@ -465,7 +465,7 @@ Cell OldC,OldH;
NewH++;
NewC++;
}
return(absappl(OldH));
return(absappl(LOCAL_OldH));
}
/* else if (ispair(c)) { */
NewC=(Cell *) reppair(OldC);
@ -474,5 +474,5 @@ Cell OldC,OldH;
NewC++;
NewH++;
*NewH=copy_structures((Cell) NewC);
return(abspair(OldH));
return(abspair(LOCAL_OldH));
}

View File

@ -748,13 +748,13 @@ void ShowCode_new2(int op, int new1,CELL new4)
Yap_plwrite(MkIntTerm(new4), Yap_DebugPutc, 0, 1200);
break;
default:
Yap_DebugPutc (Yap_c_error_stream,'%');
Yap_DebugPutc (Yap_c_error_stream,ch);
Yap_DebugPutc (LOCAL_c_error_stream,'%');
Yap_DebugPutc (LOCAL_c_error_stream,ch);
}
else
Yap_DebugPutc (Yap_c_error_stream,ch);
Yap_DebugPutc (LOCAL_c_error_stream,ch);
}
Yap_DebugPutc (Yap_c_error_stream,'\n');
Yap_DebugPutc (LOCAL_c_error_stream,'\n');
}

456
C/absmi.c

File diff suppressed because it is too large Load Diff

View File

@ -840,8 +840,8 @@ Yap_NewThreadPred(PredEntry *ap USES_REGS)
p->beamTable = NULL;
#endif
/* careful that they don't cross MkFunctor */
p->NextOfPE = AbsPredProp(MY_ThreadHandle.local_preds);
MY_ThreadHandle.local_preds = p;
p->NextOfPE = AbsPredProp(LOCAL_ThreadHandle.local_preds);
LOCAL_ThreadHandle.local_preds = p;
p->FunctorOfPred = ap->FunctorOfPred;
#ifdef LOW_PROF
if (ProfilerOn &&

68
C/agc.c
View File

@ -18,7 +18,6 @@
static char SccsId[] = "@(#)agc.c 1.3 3/15/90";
#endif
#include "absmi.h"
#include "Foreign.h"
#include "alloc.h"
@ -30,20 +29,12 @@ static char SccsId[] = "@(#)agc.c 1.3 3/15/90";
/* #define DEBUG_RESTORE1 1 */
/* #define DEBUG_RESTORE2 1 */
/* #define DEBUG_RESTORE3 1 */
#define errout Yap_stderr
#define errout GLOBAL_stderr
#endif
STATIC_PROTO(void RestoreEntries, (PropEntry *, int USES_REGS));
STATIC_PROTO(void CleanCode, (PredEntry * USES_REGS));
static int agc_calls;
static YAP_ULONG_LONG agc_collected;
static Int tot_agc_time = 0; /* total time spent in GC */
static Int tot_agc_recovered = 0; /* number of heap objects in all garbage collections */
#define AtomMarkedBit 1
static inline void
@ -225,16 +216,16 @@ RestoreHashPreds( USES_REGS1 )
static void init_reg_copies(USES_REGS1)
{
OldASP = ASP;
OldLCL0 = LCL0;
OldTR = TR;
OldGlobalBase = (CELL *)Yap_GlobalBase;
OldH = H;
OldH0 = H0;
OldTrailBase = Yap_TrailBase;
OldTrailTop = Yap_TrailTop;
OldHeapBase = Yap_HeapBase;
OldHeapTop = HeapTop;
LOCAL_OldASP = ASP;
LOCAL_OldLCL0 = LCL0;
LOCAL_OldTR = TR;
LOCAL_OldGlobalBase = (CELL *)LOCAL_GlobalBase;
LOCAL_OldH = H;
LOCAL_OldH0 = H0;
LOCAL_OldTrailBase = LOCAL_TrailBase;
LOCAL_OldTrailTop = LOCAL_TrailTop;
LOCAL_OldHeapBase = Yap_HeapBase;
LOCAL_OldHeapTop = HeapTop;
}
@ -262,7 +253,7 @@ mark_trail(USES_REGS1)
pt = TR;
/* moving the trail is simple */
while (pt != (tr_fr_ptr)Yap_TrailBase) {
while (pt != (tr_fr_ptr)LOCAL_TrailBase) {
CELL reg = TrailTerm(pt-1);
if (!IsVarTerm(reg)) {
@ -384,7 +375,7 @@ clean_atom_list(AtomHashEntry *HashPtr)
AtomEntry *at = RepAtom(atm);
if (AtomResetMark(at) ||
at->PropsOfAE != NIL ||
(Yap_AGCHook != NULL && !Yap_AGCHook(atm))) {
(GLOBAL_AGCHook != NULL && !GLOBAL_AGCHook(atm))) {
patm = &(at->NextOfAE);
atm = at->NextOfAE;
} else {
@ -393,12 +384,12 @@ clean_atom_list(AtomHashEntry *HashPtr)
#ifdef DEBUG_RESTORE3
fprintf(stderr, "Purged %p:%S\n", at, at->WStrOfAE);
#endif
agc_collected += sizeof(AtomEntry)+wcslen(at->WStrOfAE);
GLOBAL_agc_collected += sizeof(AtomEntry)+wcslen(at->WStrOfAE);
} else {
#ifdef DEBUG_RESTORE3
fprintf(stderr, "Purged %p:%s patm=%p %p\n", at, at->StrOfAE, patm, at->NextOfAE);
#endif
agc_collected += sizeof(AtomEntry)+strlen(at->StrOfAE);
GLOBAL_agc_collected += sizeof(AtomEntry)+strlen(at->StrOfAE);
}
*patm = atm = at->NextOfAE;
Yap_FreeCodeSpace((char *)at);
@ -448,13 +439,13 @@ atom_gc(USES_REGS1)
if (Yap_GetValue(AtomGcTrace) != TermNil)
gc_trace = 1;
agc_calls++;
agc_collected = 0;
GLOBAL_agc_calls++;
GLOBAL_agc_collected = 0;
if (gc_trace) {
fprintf(Yap_stderr, "%% agc:\n");
fprintf(GLOBAL_stderr, "%% agc:\n");
} else if (gc_verbose) {
fprintf(Yap_stderr, "%% Start of atom garbage collection %d:\n", agc_calls);
fprintf(GLOBAL_stderr, "%% Start of atom garbage collection %d:\n", GLOBAL_agc_calls);
}
time_start = Yap_cputime();
/* get the number of active registers */
@ -463,18 +454,17 @@ atom_gc(USES_REGS1)
mark_stacks(PASS_REGS1);
restore_codes();
clean_atoms();
Yap_AGcLastCall = NOfAtoms;
YAPLeaveCriticalSection();
agc_time = Yap_cputime()-time_start;
tot_agc_time += agc_time;
tot_agc_recovered += agc_collected;
GLOBAL_tot_agc_time += agc_time;
GLOBAL_tot_agc_recovered += GLOBAL_agc_collected;
if (gc_verbose) {
#ifdef _WIN32
fprintf(Yap_stderr, "%% Collected %I64d bytes.\n", agc_collected);
fprintf(GLOBAL_stderr, "%% Collected %I64d bytes.\n", GLOBAL_agc_collected);
#else
fprintf(Yap_stderr, "%% Collected %lld bytes.\n", agc_collected);
fprintf(GLOBAL_stderr, "%% Collected %lld bytes.\n", GLOBAL_agc_collected);
#endif
fprintf(Yap_stderr, "%% GC %d took %g sec, total of %g sec doing GC so far.\n", agc_calls, (double)agc_time/1000, (double)tot_agc_time/1000);
fprintf(GLOBAL_stderr, "%% GC %d took %g sec, total of %g sec doing GC so far.\n", GLOBAL_agc_calls, (double)agc_time/1000, (double)GLOBAL_tot_agc_time/1000);
}
}
@ -496,9 +486,9 @@ p_atom_gc(USES_REGS1)
static Int
p_inform_agc(USES_REGS1)
{
Term tn = MkIntegerTerm(tot_agc_time);
Term tt = MkIntegerTerm(agc_calls);
Term ts = MkIntegerTerm(tot_agc_recovered);
Term tn = MkIntegerTerm(GLOBAL_tot_agc_time);
Term tt = MkIntegerTerm(GLOBAL_agc_calls);
Term ts = MkIntegerTerm(GLOBAL_tot_agc_recovered);
return
Yap_unify(tn, ARG2) &&
@ -511,7 +501,7 @@ p_agc_threshold(USES_REGS1)
{
Term t = Deref(ARG1);
if (IsVarTerm(t)) {
return Yap_unify(ARG1, MkIntegerTerm(Yap_AGcThreshold));
return Yap_unify(ARG1, MkIntegerTerm(GLOBAL_AGcThreshold));
} else if (!IsIntegerTerm(t)) {
Yap_Error(TYPE_ERROR_INTEGER,t,"prolog_flag/2 agc_margin");
return FALSE;
@ -521,7 +511,7 @@ p_agc_threshold(USES_REGS1)
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,t,"prolog_flag/2 agc_margin");
return FALSE;
} else {
Yap_AGcThreshold = i;
GLOBAL_AGcThreshold = i;
return TRUE;
}
}

266
C/alloc.c
View File

@ -128,6 +128,7 @@ long long unsigned int tmalloc;
static inline char *
call_malloc(unsigned long int size)
{
CACHE_REGS
char *out;
#if USE_DL_MALLOC
LOCK(DLMallocLock);
@ -137,13 +138,13 @@ call_malloc(unsigned long int size)
tmalloc += size;
size += sizeof(CELL);
#endif
Yap_PrologMode |= MallocMode;
LOCAL_PrologMode |= MallocMode;
out = (char *) my_malloc(size);
#if INSTRUMENT_MALLOC
*(CELL*)out = size-sizeof(CELL);
out += sizeof(CELL);
#endif
Yap_PrologMode &= ~MallocMode;
LOCAL_PrologMode &= ~MallocMode;
#if USE_DL_MALLOC
UNLOCK(DLMallocLock);
#endif
@ -160,6 +161,7 @@ Yap_AllocCodeSpace(unsigned long int size)
static inline char *
call_realloc(char *p, unsigned long int size)
{
CACHE_REGS
char *out;
#if USE_DL_MALLOC
LOCK(DLMallocLock);
@ -171,13 +173,13 @@ call_realloc(char *p, unsigned long int size)
p -= sizeof(CELL);
tmalloc -= *(CELL*)p;
#endif
Yap_PrologMode |= MallocMode;
LOCAL_PrologMode |= MallocMode;
out = (char *) my_realloc0(p, size);
#if INSTRUMENT_MALLOC
*(CELL*)out = size-sizeof(CELL);
out += sizeof(CELL);
#endif
Yap_PrologMode &= ~MallocMode;
LOCAL_PrologMode &= ~MallocMode;
#if USE_DL_MALLOC
UNLOCK(DLMallocLock);
#endif
@ -194,17 +196,18 @@ Yap_ReallocCodeSpace(char *p, unsigned long int size)
void
Yap_FreeCodeSpace(char *p)
{
CACHE_REGS
#if USE_DL_MALLOC
LOCK(DLMallocLock);
#endif
Yap_PrologMode |= MallocMode;
LOCAL_PrologMode |= MallocMode;
#if INSTRUMENT_MALLOC
p -= sizeof(CELL);
tmalloc -= *(CELL*)p;
frees++;
#endif
my_free (p);
Yap_PrologMode &= ~MallocMode;
LOCAL_PrologMode &= ~MallocMode;
#if USE_DL_MALLOC
UNLOCK(DLMallocLock);
#endif
@ -220,17 +223,18 @@ Yap_AllocAtomSpace(unsigned long int size)
void
Yap_FreeAtomSpace(char *p)
{
CACHE_REGS
#if USE_DL_MALLOC
LOCK(DLMallocLock);
#endif
Yap_PrologMode |= MallocMode;
LOCAL_PrologMode |= MallocMode;
#if INSTRUMENT_MALLOC
p -= sizeof(CELL);
tmalloc -= *(CELL*)p;
frees++;
#endif
my_free (p);
Yap_PrologMode &= ~MallocMode;
LOCAL_PrologMode &= ~MallocMode;
#if USE_DL_MALLOC
UNLOCK(DLMallocLock);
#endif
@ -245,24 +249,24 @@ Yap_InitPreAllocCodeSpace(void)
{
CACHE_REGS
char *ptr;
UInt sz = ScratchPad.msz;
if (ScratchPad.ptr == NULL) {
UInt sz = LOCAL_ScratchPad.msz;
if (LOCAL_ScratchPad.ptr == NULL) {
#if USE_DL_MALLOC
LOCK(DLMallocLock);
#endif
Yap_PrologMode |= MallocMode;
LOCAL_PrologMode |= MallocMode;
#if INSTRUMENT_MALLOC
mallocs++;
tmalloc += sz;
sz += sizeof(CELL);
#endif
while (!(ptr = my_malloc(sz))) {
Yap_PrologMode &= ~MallocMode;
LOCAL_PrologMode &= ~MallocMode;
#if USE_DL_MALLOC
UNLOCK(DLMallocLock);
#endif
if (!Yap_growheap(FALSE, Yap_Error_Size, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return(NULL);
}
#if INSTRUMENT_MALLOC
@ -273,18 +277,18 @@ Yap_InitPreAllocCodeSpace(void)
#if USE_DL_MALLOC
LOCK(DLMallocLock);
#endif
Yap_PrologMode |= MallocMode;
LOCAL_PrologMode |= MallocMode;
}
Yap_PrologMode &= ~MallocMode;
LOCAL_PrologMode &= ~MallocMode;
#if USE_DL_MALLOC
UNLOCK(DLMallocLock);
#endif
ScratchPad.ptr = ptr;
LOCAL_ScratchPad.ptr = ptr;
} else {
ptr = ScratchPad.ptr;
ptr = LOCAL_ScratchPad.ptr;
}
AuxBase = (ADDR)(ptr);
AuxSp = (CELL *)(AuxTop = AuxBase+ScratchPad.sz);
AuxSp = (CELL *)(AuxTop = AuxBase+LOCAL_ScratchPad.sz);
return ptr;
}
@ -293,11 +297,11 @@ Yap_ExpandPreAllocCodeSpace(UInt sz0, void *cip, int safe)
{
CACHE_REGS
char *ptr;
UInt sz = ScratchPad.msz;
UInt sz = LOCAL_ScratchPad.msz;
if (sz0 < SCRATCH_INC_SIZE)
sz0 = SCRATCH_INC_SIZE;
if (sz0 < ScratchPad.sz)
sz = ScratchPad.sz+sz0;
if (sz0 < LOCAL_ScratchPad.sz)
sz = LOCAL_ScratchPad.sz+sz0;
else
sz = sz0;
sz = AdjustLargePageSize(sz+sz/4);
@ -305,25 +309,25 @@ Yap_ExpandPreAllocCodeSpace(UInt sz0, void *cip, int safe)
#if USE_DL_MALLOC
LOCK(DLMallocLock);
#endif
Yap_PrologMode |= MallocMode;
LOCAL_PrologMode |= MallocMode;
#if INSTRUMENT_MALLOC
reallocs++;
tmalloc -= ScratchPad.sz;
tmalloc -= LOCAL_ScratchPad.sz;
tmalloc += sz;
#endif
if (!(ptr = my_realloc(ScratchPad.ptr, sz, ScratchPad.sz, safe))) {
Yap_PrologMode &= ~MallocMode;
if (!(ptr = my_realloc(LOCAL_ScratchPad.ptr, sz, LOCAL_ScratchPad.sz, safe))) {
LOCAL_PrologMode &= ~MallocMode;
#if USE_DL_MALLOC
UNLOCK(DLMallocLock);
#endif
return NULL;
}
Yap_PrologMode &= ~MallocMode;
LOCAL_PrologMode &= ~MallocMode;
#if USE_DL_MALLOC
UNLOCK(DLMallocLock);
#endif
ScratchPad.sz = ScratchPad.msz = sz;
ScratchPad.ptr = ptr;
LOCAL_ScratchPad.sz = LOCAL_ScratchPad.msz = sz;
LOCAL_ScratchPad.ptr = ptr;
AuxBase = ptr;
AuxSp = (CELL *)(AuxTop = ptr+sz);
return ptr;
@ -336,11 +340,7 @@ struct various_codes *Yap_heap_regs;
static void
InitHeap(void)
{
CACHE_REGS
Yap_heap_regs = (struct various_codes *)calloc(1, sizeof(struct various_codes));
#if defined(YAPOR) || defined(TABLING)
LOCAL = REMOTE; /* point to the first area */
#endif /* YAPOR || TABLING */
}
void
@ -368,22 +368,22 @@ InitExStacks(int Trail, int Stack)
#ifdef THREADS
if (worker_id)
Yap_GlobalBase = (ADDR)MY_ThreadHandle.stack_address;
LOCAL_GlobalBase = (ADDR)LOCAL_ThreadHandle.stack_address;
#endif
Yap_TrailTop = Yap_GlobalBase + pm;
Yap_LocalBase = Yap_GlobalBase + sa;
Yap_TrailBase = Yap_LocalBase + sizeof(CELL);
LOCAL_TrailTop = LOCAL_GlobalBase + pm;
LOCAL_LocalBase = LOCAL_GlobalBase + sa;
LOCAL_TrailBase = LOCAL_LocalBase + sizeof(CELL);
ScratchPad.ptr = NULL;
ScratchPad.sz = ScratchPad.msz = SCRATCH_START_SIZE;
LOCAL_ScratchPad.ptr = NULL;
LOCAL_ScratchPad.sz = LOCAL_ScratchPad.msz = SCRATCH_START_SIZE;
AuxSp = NULL;
#ifdef DEBUG
if (Yap_output_msg) {
if (GLOBAL_output_msg) {
UInt ta;
fprintf(stderr, "HeapBase = %p GlobalBase = %p\n LocalBase = %p TrailTop = %p\n",
Yap_HeapBase, Yap_GlobalBase, Yap_LocalBase, Yap_TrailTop);
Yap_HeapBase, LOCAL_GlobalBase, LOCAL_LocalBase, LOCAL_TrailTop);
ta = Trail*K; /* trail area size */
fprintf(stderr, "Heap+Aux: %lu\tLocal+Global: %lu\tTrail: %lu\n",
@ -402,19 +402,19 @@ Yap_InitExStacks(int Trail, int Stack)
void
Yap_KillStacks(int wid)
{
ADDR gb = FOREIGN_ThreadHandle(wid).stack_address;
ADDR gb = REMOTE_ThreadHandle(wid).stack_address;
if (gb) {
free(gb);
FOREIGN_ThreadHandle(wid).stack_address = NULL;
REMOTE_ThreadHandle(wid).stack_address = NULL;
}
}
#else
void
Yap_KillStacks(void)
{
if (Yap_GlobalBase) {
free(Yap_GlobalBase);
Yap_GlobalBase = NULL;
if (LOCAL_GlobalBase) {
free(LOCAL_GlobalBase);
LOCAL_GlobalBase = NULL;
}
}
#endif
@ -429,15 +429,15 @@ int
Yap_ExtendWorkSpace(Int s)
{
CACHE_REGS
void *basebp = (void *)Yap_GlobalBase, *nbp;
UInt s0 = (char *)Yap_TrailTop-(char *)Yap_GlobalBase;
void *basebp = (void *)LOCAL_GlobalBase, *nbp;
UInt s0 = (char *)LOCAL_TrailTop-(char *)LOCAL_GlobalBase;
nbp = realloc(basebp, s+s0);
if (nbp == NULL)
return FALSE;
#if defined(THREADS)
MY_ThreadHandle.stack_address = (char *)nbp;
LOCAL_ThreadHandle.stack_address = (char *)nbp;
#endif
Yap_GlobalBase = (char *)nbp;
LOCAL_GlobalBase = (char *)nbp;
return TRUE;
}
@ -686,7 +686,7 @@ AllocHeap(unsigned long int size)
HeapUsed += size * sizeof(CELL) + sizeof(YAP_SEG_SIZE);
#ifdef YAPOR
if (HeapTop > Addr(Yap_GlobalBase) - MinHeapGap)
if (HeapTop > Addr(LOCAL_GlobalBase) - MinHeapGap)
Yap_Error(INTERNAL_ERROR, TermNil, "no heap left (AllocHeap)");
#else
if (HeapTop > HeapLim - MinHeapGap) {
@ -707,8 +707,8 @@ AllocHeap(unsigned long int size)
UNLOCK(HeapTopLock);
Yap_signal(YAP_CDOVF_SIGNAL);
} else {
if (size > Yap_SizeOfOverflow)
Yap_SizeOfOverflow = size*sizeof(CELL) + sizeof(YAP_SEG_SIZE);
if (size > GLOBAL_SizeOfOverflow)
GLOBAL_SizeOfOverflow = size*sizeof(CELL) + sizeof(YAP_SEG_SIZE);
/* big allocations, the caller must handle the problem */
UNLOCK(HeapUsedLock);
UNLOCK(HeapTopLock);
@ -822,9 +822,9 @@ static int
ExtendWorkSpace(Int s, int fixed_allocation)
{
LPVOID b = brk;
prolog_exec_mode OldPrologMode = Yap_PrologMode;
prolog_exec_mode OldPrologMode = LOCAL_PrologMode;
Yap_PrologMode = ExtendStackMode;
LOCAL_PrologMode = ExtendStackMode;
#if DEBUG_WIN32_ALLOC
fprintf(stderr,"trying: %p (" Int_FORMAT "K) %d\n",b, s/1024, fixed_allocation);
@ -838,7 +838,7 @@ ExtendWorkSpace(Int s, int fixed_allocation)
}
}
if (!b) {
Yap_PrologMode = OldPrologMode;
LOCAL_PrologMode = OldPrologMode;
#if DEBUG_WIN32_ALLOC
{
char msg[256];
@ -853,11 +853,11 @@ ExtendWorkSpace(Int s, int fixed_allocation)
}
b = VirtualAlloc(b, s, MEM_COMMIT, PAGE_READWRITE);
if (!b) {
Yap_ErrorMessage = Yap_ErrorSay;
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
LOCAL_ErrorMessage = LOCAL_ErrorSay;
snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"VirtualAlloc could not commit %ld bytes",
(long int)s);
Yap_PrologMode = OldPrologMode;
LOCAL_PrologMode = OldPrologMode;
#if DEBUG_WIN32_ALLOC
fprintf(stderr,"NOT OK2: %p--%p\n",b,brk);
#endif
@ -867,7 +867,7 @@ ExtendWorkSpace(Int s, int fixed_allocation)
#if DEBUG_WIN32_ALLOC
fprintf(stderr,"OK: %p--%p " Int_FORMAT "\n",b, brk, s);
#endif
Yap_PrologMode = OldPrologMode;
LOCAL_PrologMode = OldPrologMode;
return TRUE;
}
@ -1025,6 +1025,8 @@ InitWorkSpace(Int s)
return (void *) a;
}
#ifndef YAPOR
static MALLOC_T
mmap_extension(Int s, MALLOC_T base, int fixed_allocation)
{
@ -1047,13 +1049,13 @@ mmap_extension(Int s, MALLOC_T base, int fixed_allocation)
char file[256];
strncpy(file,"/tmp/YAP.TMPXXXXXX",256);
if (mkstemp(file) == -1) {
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
#if HAVE_STRERROR
snprintf5(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
snprintf5(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"mkstemp could not create temporary file %s (%s)",
file, strerror(errno));
#else
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"mkstemp could not create temporary file %s", file);
#endif /* HAVE_STRERROR */
return (MALLOC_T)-1;
@ -1069,28 +1071,28 @@ mmap_extension(Int s, MALLOC_T base, int fixed_allocation)
#endif /* HAVE_MKSTEMP */
fd = open(file, O_CREAT|O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd < 0) {
Yap_ErrorMessage = Yap_ErrorSay;
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
LOCAL_ErrorMessage = LOCAL_ErrorSay;
snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"mmap could not open %s", file);
return (MALLOC_T)-1;
}
if (lseek(fd, s, SEEK_SET) < 0) {
Yap_ErrorMessage = Yap_ErrorSay;
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
LOCAL_ErrorMessage = LOCAL_ErrorSay;
snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"mmap could not lseek in mmapped file %s", file);
close(fd);
return (MALLOC_T)-1;
}
if (write(fd, "", 1) < 0) {
Yap_ErrorMessage = Yap_ErrorSay;
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
LOCAL_ErrorMessage = LOCAL_ErrorSay;
snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"mmap could not write in mmapped file %s", file);
close(fd);
return (MALLOC_T)-1;
}
if (unlink(file) < 0) {
Yap_ErrorMessage = Yap_ErrorSay;
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
LOCAL_ErrorMessage = LOCAL_ErrorSay;
snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"mmap could not unlink mmapped file %s", file);
close(fd);
return (MALLOC_T)-1;
@ -1104,12 +1106,12 @@ mmap_extension(Int s, MALLOC_T base, int fixed_allocation)
#endif
, fd, 0);
if (close(fd) == -1) {
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
#if HAVE_STRERROR
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"mmap could not close file (%s) ]\n", strerror(errno));
#else
snprintf3(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
snprintf3(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"mmap could not close file ]\n");
#endif
return (MALLOC_T)-1;
@ -1117,6 +1119,8 @@ mmap_extension(Int s, MALLOC_T base, int fixed_allocation)
#endif
return a;
}
#endif /* !YAPOR */
static int
ExtendWorkSpace(Int s, int fixed_allocation)
@ -1126,23 +1130,23 @@ ExtendWorkSpace(Int s, int fixed_allocation)
return(FALSE);
#else
MALLOC_T a;
prolog_exec_mode OldPrologMode = Yap_PrologMode;
prolog_exec_mode OldPrologMode = LOCAL_PrologMode;
MALLOC_T base = WorkSpaceTop;
if (fixed_allocation == MAP_FIXED)
base = WorkSpaceTop;
else
base = 0L;
Yap_PrologMode = ExtendStackMode;
LOCAL_PrologMode = ExtendStackMode;
a = mmap_extension(s, base, fixed_allocation);
Yap_PrologMode = OldPrologMode;
LOCAL_PrologMode = OldPrologMode;
if (a == (MALLOC_T) - 1) {
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
#if HAVE_STRERROR
snprintf5(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
snprintf5(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"could not allocate %d bytes (%s)", (int)s, strerror(errno));
#else
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"could not allocate %d bytes", (int)s);
#endif
return FALSE;
@ -1150,10 +1154,10 @@ ExtendWorkSpace(Int s, int fixed_allocation)
if (fixed_allocation) {
if (a != WorkSpaceTop) {
munmap((void *)a, (size_t)s);
Yap_ErrorMessage = Yap_ErrorSay;
snprintf5(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
LOCAL_ErrorMessage = LOCAL_ErrorSay;
snprintf5(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"mmap could not grow memory at %p, got %p", WorkSpaceTop, a );
Yap_PrologMode = OldPrologMode;
LOCAL_PrologMode = OldPrologMode;
return FALSE;
}
} else if (a < WorkSpaceTop) {
@ -1164,7 +1168,7 @@ ExtendWorkSpace(Int s, int fixed_allocation)
return res;
}
WorkSpaceTop = (char *) a + s;
Yap_PrologMode = OldPrologMode;
LOCAL_PrologMode = OldPrologMode;
return TRUE;
#endif /* YAPOR */
}
@ -1215,33 +1219,33 @@ ExtendWorkSpace(Int s)
{
MALLOC_T ptr;
int shm_id;
prolog_exec_mode OldPrologMode = Yap_PrologMode;
prolog_exec_mode OldPrologMode = LOCAL_PrologMode;
Yap_PrologMode = ExtendStackMode;
LOCAL_PrologMode = ExtendStackMode;
/* mapping heap area */
if((shm_id = shmget(IPC_PRIVATE, (size_t)s, SHM_R|SHM_W)) == -1) {
Yap_ErrorMessage = Yap_ErrorSay;
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
LOCAL_ErrorMessage = LOCAL_ErrorSay;
snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"could not shmget %d bytes", s);
Yap_PrologMode = OldPrologMode;
LOCAL_PrologMode = OldPrologMode;
return(FALSE);
}
if((ptr = (MALLOC_T)shmat(shm_id, WorkSpaceTop, 0)) == (MALLOC_T) -1) {
Yap_ErrorMessage = Yap_ErrorSay;
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
LOCAL_ErrorMessage = LOCAL_ErrorSay;
snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"could not shmat at %p", MMAP_ADDR);
Yap_PrologMode = OldPrologMode;
LOCAL_PrologMode = OldPrologMode;
return(FALSE);
}
if (shmctl(shm_id, IPC_RMID, 0) != 0) {
Yap_ErrorMessage = Yap_ErrorSay;
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
LOCAL_ErrorMessage = LOCAL_ErrorSay;
snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"could not remove shm segment", shm_id);
Yap_PrologMode = OldPrologMode;
LOCAL_PrologMode = OldPrologMode;
return(FALSE);
}
WorkSpaceTop = (char *) ptr + s;
Yap_PrologMode = OldPrologMode;
LOCAL_PrologMode = OldPrologMode;
return(TRUE);
}
@ -1290,17 +1294,17 @@ static int
ExtendWorkSpace(Int s)
{
MALLOC_T ptr = (MALLOC_T)sbrk(s);
prolog_exec_mode OldPrologMode = Yap_PrologMode;
prolog_exec_mode OldPrologMode = LOCAL_PrologMode;
Yap_PrologMode = ExtendStackMode;
LOCAL_PrologMode = ExtendStackMode;
if (ptr == ((MALLOC_T) - 1)) {
Yap_ErrorMessage = Yap_ErrorSay;
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
LOCAL_ErrorMessage = LOCAL_ErrorSay;
snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"could not expand stacks over %d bytes", s);
Yap_PrologMode = OldPrologMode;
LOCAL_PrologMode = OldPrologMode;
return(FALSE);
}
Yap_PrologMode = OldPrologMode;
LOCAL_PrologMode = OldPrologMode;
return TRUE;
}
@ -1420,34 +1424,34 @@ static int
ExtendWorkSpace(Int s)
{
MALLOC_T ptr;
prolog_exec_mode OldPrologMode = Yap_PrologMode;
prolog_exec_mode OldPrologMode = LOCAL_PrologMode;
Yap_PrologMode = ExtendStackMode;
LOCAL_PrologMode = ExtendStackMode;
total_space += s;
if (total_space < MAX_SPACE) return TRUE;
ptr = (MALLOC_T)realloc((void *)Yap_HeapBase, total_space);
if (ptr == NULL) {
Yap_ErrorMessage = Yap_ErrorSay;
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
LOCAL_ErrorMessage = LOCAL_ErrorSay;
snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"could not allocate %d bytes", s);
Yap_PrologMode = OldPrologMode;
LOCAL_PrologMode = OldPrologMode;
return FALSE;
}
if (ptr != (MALLOC_T)Yap_HeapBase) {
Yap_ErrorMessage = Yap_ErrorSay;
snprintf4(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
LOCAL_ErrorMessage = LOCAL_ErrorSay;
snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"could not expand contiguous stacks %d bytes", s);
Yap_PrologMode = OldPrologMode;
LOCAL_PrologMode = OldPrologMode;
return FALSE;
}
if ((CELL)ptr & MBIT) {
Yap_ErrorMessage = Yap_ErrorSay;
snprintf5(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE,
LOCAL_ErrorMessage = LOCAL_ErrorSay;
snprintf5(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE,
"memory at %p conflicts with MBIT %lx", ptr, (unsigned long)MBIT);
Yap_PrologMode = OldPrologMode;
LOCAL_PrologMode = OldPrologMode;
return FALSE;
}
Yap_PrologMode = OldPrologMode;
LOCAL_PrologMode = OldPrologMode;
return TRUE;
}
@ -1479,10 +1483,6 @@ InitHeap(void *heap_addr)
#endif
FreeBlocks = NIL;
#if defined(YAPOR) || defined(TABLING)
LOCAL = REMOTE; /* point to the first area */
#endif /* YAPOR || TABLING */
}
void
@ -1521,27 +1521,27 @@ Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack)
InitHeap(addr);
Yap_TrailTop = Yap_HeapBase + pm;
Yap_LocalBase = Yap_TrailTop - ta;
Yap_TrailBase = Yap_LocalBase + sizeof(CELL);
LOCAL_TrailTop = Yap_HeapBase + pm;
LOCAL_LocalBase = LOCAL_TrailTop - ta;
LOCAL_TrailBase = LOCAL_LocalBase + sizeof(CELL);
Yap_GlobalBase = Yap_LocalBase - sa;
HeapLim = Yap_GlobalBase; /* avoid confusions while
LOCAL_GlobalBase = LOCAL_LocalBase - sa;
HeapLim = LOCAL_GlobalBase; /* avoid confusions while
* * restoring */
#if !USE_DL_MALLOC
AuxTop = (ADDR)(AuxSp = (CELL *)Yap_GlobalBase);
AuxTop = (ADDR)(AuxSp = (CELL *)LOCAL_GlobalBase);
#endif
#ifdef DEBUG
#if SIZEOF_INT_P!=SIZEOF_INT
if (Yap_output_msg) {
if (GLOBAL_output_msg) {
fprintf(stderr, "HeapBase = %p GlobalBase = %p\n LocalBase = %p TrailTop = %p\n",
Yap_HeapBase, Yap_GlobalBase, Yap_LocalBase, Yap_TrailTop);
Yap_HeapBase, LOCAL_GlobalBase, LOCAL_LocalBase, LOCAL_TrailTop);
#else
if (Yap_output_msg) {
if (GLOBAL_output_msg) {
fprintf(stderr, "HeapBase = %x GlobalBase = %x\n LocalBase = %x TrailTop = %x\n",
(UInt) Yap_HeapBase, (UInt) Yap_GlobalBase,
(UInt) Yap_LocalBase, (UInt) Yap_TrailTop);
(UInt) Yap_HeapBase, (UInt) LOCAL_GlobalBase,
(UInt) LOCAL_LocalBase, (UInt) LOCAL_TrailTop);
#endif
fprintf(stderr, "Heap+Aux: " UInt_FORMAT "\tLocal+Global: " UInt_FORMAT "\tTrail: " UInt_FORMAT "\n",
@ -1554,8 +1554,8 @@ void
Yap_InitExStacks(int Trail, int Stack)
{
#if USE_DL_MALLOC
ScratchPad.ptr = NULL;
ScratchPad.sz = ScratchPad.msz = SCRATCH_START_SIZE;
LOCAL_ScratchPad.ptr = NULL;
LOCAL_ScratchPad.sz = LOCAL_ScratchPad.msz = SCRATCH_START_SIZE;
AuxSp = NULL;
#endif
}
@ -1596,7 +1596,7 @@ Yap_ExtendWorkSpaceThroughHole(UInt s)
WorkSpaceTop += 512*1024;
if (ExtendWorkSpace(s, MAP_FIXED)) {
Yap_add_memory_hole((ADDR)WorkSpaceTop0, (ADDR)WorkSpaceTop-s);
Yap_ErrorMessage = NULL;
LOCAL_ErrorMessage = NULL;
return WorkSpaceTop-WorkSpaceTop0;
}
#if defined(_WIN32)
@ -1614,7 +1614,7 @@ Yap_ExtendWorkSpaceThroughHole(UInt s)
WorkSpaceTop += 512*1024;
if (ExtendWorkSpace(s, MAP_FIXED)) {
Yap_add_memory_hole((ADDR)WorkSpaceTop0, (ADDR)WorkSpaceTop-s);
Yap_ErrorMessage = NULL;
LOCAL_ErrorMessage = NULL;
return WorkSpaceTop-WorkSpaceTop0;
}
#if defined(_WIN32)

View File

@ -434,8 +434,8 @@ DumpOpCodes(void)
while (i < 30) {
for (j = i; j <= _std_top; j += 25)
fprintf(Yap_stderr, "%5d %6lx", j, absmadr(j));
fputc('\n',Yap_stderr);
fprintf(GLOBAL_stderr, "%5d %6lx", j, absmadr(j));
fputc('\n',GLOBAL_stderr);
++i;
}
}
@ -2196,9 +2196,9 @@ static yamop *
a_gl(op_numbers opcode, yamop *code_p, int pass_no, struct PSEUDO *cpc, struct intermediates *cip USES_REGS)
{
#ifdef YAPOR
return a_try(opcode, cpc->rnd1, IPredArity, cpc->rnd2 >> 1, cpc->rnd2 & 1, code_p, pass_no, cip);
return a_try(opcode, cpc->rnd1, LOCAL_IPredArity, cpc->rnd2 >> 1, cpc->rnd2 & 1, code_p, pass_no, cip);
#else
return a_try(opcode, cpc->rnd1, IPredArity, code_p, pass_no, cip);
return a_try(opcode, cpc->rnd1, LOCAL_IPredArity, code_p, pass_no, cip);
#endif /* YAPOR */
}
@ -2429,13 +2429,13 @@ a_fetch_vv(cmp_op_info *cmp_info, int pass_no, struct intermediates *cip)
PInstr *p = cip->cpc->nextInst;
Ventry *ve;
ve = (Ventry *) p->rnd1;
if (ve->KindOfVE != PermVar && p->op != nop_op) {
if (ve->KindOfVE != PermVar && p->op != nop_op && p->op != put_var_op) {
p->rnd2 = ve->NoOfVE & MaskVarAdrs;
p->op = nop_op;
}
p = p->nextInst;
ve = (Ventry *) p->rnd1;
if (ve->KindOfVE != PermVar && p->op != nop_op) {
if (ve->KindOfVE != PermVar && p->op != nop_op && p->op != put_var_op) {
p->rnd2 = ve->NoOfVE & MaskVarAdrs;
p->op = nop_op;
}
@ -2458,7 +2458,7 @@ a_fetch_vc(cmp_op_info *cmp_info, int pass_no, struct intermediates *cip)
PInstr *p = cip->cpc->nextInst;
Ventry *ve;
ve = (Ventry *) p->rnd1;
if (ve->KindOfVE != PermVar && p->op != nop_op) {
if (ve->KindOfVE != PermVar && p->op != nop_op && p->op != put_var_op) {
p->rnd2 = ve->NoOfVE & MaskVarAdrs;
p->op = nop_op;
}
@ -2479,7 +2479,7 @@ a_fetch_cv(cmp_op_info *cmp_info, int pass_no, struct intermediates *cip)
PInstr *p = cip->cpc->nextInst;
Ventry *ve;
ve = (Ventry *) p->rnd1;
if (ve->KindOfVE != PermVar && p->op != nop_op) {
if (ve->KindOfVE != PermVar && p->op != nop_op && p->op != put_var_op) {
p->rnd2 = ve->NoOfVE & MaskVarAdrs;
p->op = nop_op;
}
@ -2981,11 +2981,11 @@ a_special_label(yamop *code_p, int pass_no, struct intermediates *cip)
#ifdef YAPOR
#define TRYCODE(G,P) a_try((G), Unsigned(cip->code_addr) + cip->label_offset[cip->cpc->rnd1], IPredArity, cip->cpc->rnd2 >> 1, cip->cpc->rnd2 & 1, code_p, pass_no, cip)
#define TABLE_TRYCODE(G) a_try((G), (CELL)emit_ilabel(cip->cpc->rnd1, cip), IPredArity, cip->cpc->rnd2 >> 1, cip->cpc->rnd2 & 1, code_p, pass_no, cip)
#define TRYCODE(G,P) a_try((G), Unsigned(cip->code_addr) + cip->label_offset[cip->cpc->rnd1], LOCAL_IPredArity, cip->cpc->rnd2 >> 1, cip->cpc->rnd2 & 1, code_p, pass_no, cip)
#define TABLE_TRYCODE(G) a_try((G), (CELL)emit_ilabel(cip->cpc->rnd1, cip), LOCAL_IPredArity, cip->cpc->rnd2 >> 1, cip->cpc->rnd2 & 1, code_p, pass_no, cip)
#else
#define TRYCODE(G,P) a_try((G), Unsigned(cip->code_addr) + cip->label_offset[cip->cpc->rnd1], IPredArity, code_p, pass_no, cip)
#define TABLE_TRYCODE(G) a_try((G), (CELL)emit_ilabel(cip->cpc->rnd1, cip), IPredArity, code_p, pass_no, cip)
#define TRYCODE(G,P) a_try((G), Unsigned(cip->code_addr) + cip->label_offset[cip->cpc->rnd1], LOCAL_IPredArity, code_p, pass_no, cip)
#define TABLE_TRYCODE(G) a_try((G), (CELL)emit_ilabel(cip->cpc->rnd1, cip), LOCAL_IPredArity, code_p, pass_no, cip)
#endif /* YAPOR */
static yamop *
@ -3093,22 +3093,22 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
}
code_p = cl_u->sc.ClCode;
}
IPredArity = cip->CurrentPred->ArityOfPE; /* number of args */
LOCAL_IPredArity = cip->CurrentPred->ArityOfPE; /* number of args */
*entry_codep = code_p;
if (tabled) {
#if TABLING
#ifdef YAPOR
code_p = a_try(_table_try_single, (CELL)NEXTOP(code_p,Otapl), IPredArity, 1, 0, code_p, pass_no, cip);
code_p = a_try(_table_try_single, (CELL)NEXTOP(code_p,Otapl), LOCAL_IPredArity, 1, 0, code_p, pass_no, cip);
#else
code_p = a_try(_table_try_single, (CELL)NEXTOP(code_p,Otapl), IPredArity, code_p, pass_no, cip);
code_p = a_try(_table_try_single, (CELL)NEXTOP(code_p,Otapl), LOCAL_IPredArity, code_p, pass_no, cip);
#endif
#endif
}
if (dynamic) {
#ifdef YAPOR
code_p = a_try(_try_me, 0, IPredArity, 1, 0, code_p, pass_no, cip);
code_p = a_try(_try_me, 0, LOCAL_IPredArity, 1, 0, code_p, pass_no, cip);
#else
code_p = a_try(_try_me, 0, IPredArity, code_p, pass_no, cip);
code_p = a_try(_try_me, 0, LOCAL_IPredArity, code_p, pass_no, cip);
#endif /* YAPOR */
}
} else {
@ -3541,7 +3541,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
if (!pass_no) {
#if !USE_SYSTEM_MALLOC
if (CellPtr(cip->label_offset+cip->cpc->rnd1) > ASP-256) {
Yap_Error_Size = 256+((char *)(cip->label_offset+cip->cpc->rnd1) - (char *)H);
LOCAL_Error_Size = 256+((char *)(cip->label_offset+cip->cpc->rnd1) - (char *)H);
save_machine_regs();
siglongjmp(cip->CompilerBotch, 3);
}
@ -3787,9 +3787,9 @@ fetch_clause_space(Term* tp, UInt size, struct intermediates *cip, UInt *osizep
while ((x = Yap_StoreTermInDBPlusExtraSpace(*tp, size, osizep)) == NULL) {
H = h0;
switch (Yap_Error_TYPE) {
switch (LOCAL_Error_TYPE) {
case OUT_OF_STACK_ERROR:
Yap_Error_Size = 256+((char *)cip->freep - (char *)H);
LOCAL_Error_Size = 256+((char *)cip->freep - (char *)H);
save_machine_regs();
siglongjmp(cip->CompilerBotch,3);
case OUT_OF_TRAIL_ERROR:
@ -3798,15 +3798,15 @@ fetch_clause_space(Term* tp, UInt size, struct intermediates *cip, UInt *osizep
if (!Yap_growtrail(K64, FALSE)) {
return NULL;
}
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
*tp = ARG1;
break;
case OUT_OF_AUXSPACE_ERROR:
ARG1 = *tp;
if (!Yap_ExpandPreAllocCodeSpace(Yap_Error_Size, (void *)cip, TRUE)) {
if (!Yap_ExpandPreAllocCodeSpace(LOCAL_Error_Size, (void *)cip, TRUE)) {
return NULL;
}
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
*tp = ARG1;
break;
case OUT_OF_HEAP_ERROR:
@ -3815,7 +3815,7 @@ fetch_clause_space(Term* tp, UInt size, struct intermediates *cip, UInt *osizep
if (!Yap_growheap(TRUE, size, cip)) {
return NULL;
}
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
*tp = ARG1;
break;
default:
@ -3864,16 +3864,16 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
#if USE_SYSTEM_MALLOC
if (!cip->label_offset) {
if (!Yap_LabelFirstArray && max_label <= DEFAULT_NLABELS) {
Yap_LabelFirstArray = (Int *)Yap_AllocCodeSpace(sizeof(Int)*DEFAULT_NLABELS);
Yap_LabelFirstArraySz = DEFAULT_NLABELS;
if (!Yap_LabelFirstArray) {
if (!LOCAL_LabelFirstArray && max_label <= DEFAULT_NLABELS) {
LOCAL_LabelFirstArray = (Int *)Yap_AllocCodeSpace(sizeof(Int)*DEFAULT_NLABELS);
LOCAL_LabelFirstArraySz = DEFAULT_NLABELS;
if (!LOCAL_LabelFirstArray) {
save_machine_regs();
siglongjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
}
}
if (Yap_LabelFirstArray && max_label <= Yap_LabelFirstArraySz) {
cip->label_offset = Yap_LabelFirstArray;
if (LOCAL_LabelFirstArray && max_label <= LOCAL_LabelFirstArraySz) {
cip->label_offset = LOCAL_LabelFirstArray;
} else {
cip->label_offset = (Int *)Yap_AllocCodeSpace(sizeof(Int)*max_label);
if (!cip->label_offset) {
@ -3926,14 +3926,14 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
/* make sure we copy after second pass */
cl->usc.ClSource = x;
cl->ClSize = osize;
ProfEnd=code_p;
LOCAL_ProfEnd=code_p;
return entry_code;
} else {
while ((cip->code_addr = (yamop *) Yap_AllocCodeSpace(size)) == NULL) {
if (!Yap_growheap(TRUE, size, cip)) {
Yap_Error_TYPE = OUT_OF_HEAP_ERROR;
Yap_Error_Size = size;
LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR;
LOCAL_Error_Size = size;
return NULL;
}
}
@ -3950,11 +3950,11 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
}
}
code_p = do_pass(1, &entry_code, mode, &clause_has_blobs, &clause_has_dbterm, cip, size PASS_REGS);
ProfEnd=code_p;
LOCAL_ProfEnd=code_p;
#ifdef LOW_PROF
if (ProfilerOn &&
Yap_OffLineProfiler) {
Yap_inform_profiler_of_clause(entry_code, ProfEnd, ap, mode == ASSEMBLING_INDEX);
Yap_inform_profiler_of_clause(entry_code, LOCAL_ProfEnd, ap, mode == ASSEMBLING_INDEX);
}
#endif /* LOW_PROF */
return entry_code;

View File

@ -28,9 +28,7 @@ static char SccsId[] = "%W% %G%";
#include <string.h>
#endif
YAP_ULONG_LONG Yap_opcount[_std_top + 1];
YAP_ULONG_LONG Yap_2opcount[_std_top + 1][_std_top + 1];
STATIC_PROTO(Int p_reset_op_counters, (void));
@ -43,7 +41,7 @@ p_reset_op_counters()
int i;
for (i = 0; i <= _std_top; ++i)
Yap_opcount[i] = 0;
GLOBAL_opcount[i] = 0;
return TRUE;
}
@ -52,26 +50,26 @@ print_instruction(int inst)
{
int j;
fprintf(Yap_stderr, "%s", Yap_op_names[inst]);
fprintf(GLOBAL_stderr, "%s", Yap_op_names[inst]);
for (j = strlen(Yap_op_names[inst]); j < 25; j++)
putc(' ', Yap_stderr);
j = Yap_opcount[inst];
putc(' ', GLOBAL_stderr);
j = GLOBAL_opcount[inst];
if (j < 100000000) {
putc(' ', Yap_stderr);
putc(' ', GLOBAL_stderr);
if (j < 10000000) {
putc(' ', Yap_stderr);
putc(' ', GLOBAL_stderr);
if (j < 1000000) {
putc(' ', Yap_stderr);
putc(' ', GLOBAL_stderr);
if (j < 100000) {
putc(' ', Yap_stderr);
putc(' ', GLOBAL_stderr);
if (j < 10000) {
putc(' ', Yap_stderr);
putc(' ', GLOBAL_stderr);
if (j < 1000) {
putc(' ', Yap_stderr);
putc(' ', GLOBAL_stderr);
if (j < 100) {
putc(' ', Yap_stderr);
putc(' ', GLOBAL_stderr);
if (j < 10) {
putc(' ', Yap_stderr);
putc(' ', GLOBAL_stderr);
}
}
}
@ -80,7 +78,7 @@ print_instruction(int inst)
}
}
}
fprintf(Yap_stderr, "%llu\n", Yap_opcount[inst]);
fprintf(GLOBAL_stderr, "%llu\n", GLOBAL_opcount[inst]);
}
static Int
@ -98,18 +96,18 @@ p_show_op_counters()
wchar_t *program;
program = RepAtom(at1)->WStrOfAE;
fprintf(Yap_stderr, "\n Instructions Executed in %S\n", program);
fprintf(GLOBAL_stderr, "\n Instructions Executed in %S\n", program);
} else {
char *program;
program = RepAtom(at1)->StrOfAE;
fprintf(Yap_stderr, "\n Instructions Executed in %s\n", program);
fprintf(GLOBAL_stderr, "\n Instructions Executed in %s\n", program);
}
}
for (i = 0; i <= _std_top; ++i)
print_instruction(i);
fprintf(Yap_stderr, "\n Control Instructions \n");
fprintf(GLOBAL_stderr, "\n Control Instructions \n");
print_instruction(_op_fail);
print_instruction(_execute);
print_instruction(_dexecute);
@ -121,7 +119,7 @@ p_show_op_counters()
print_instruction(_allocate);
print_instruction(_deallocate);
fprintf(Yap_stderr, "\n Choice Point Manipulation Instructions\n");
fprintf(GLOBAL_stderr, "\n Choice Point Manipulation Instructions\n");
print_instruction(_try_me);
print_instruction(_retry_me);
print_instruction(_trust_me);
@ -130,38 +128,38 @@ p_show_op_counters()
print_instruction(_retry);
print_instruction(_trust);
fprintf(Yap_stderr, "\n Disjunction Instructions\n");
fprintf(GLOBAL_stderr, "\n Disjunction Instructions\n");
print_instruction(_either);
print_instruction(_or_else);
print_instruction(_or_last);
print_instruction(_jump);
print_instruction(_move_back);
fprintf(Yap_stderr, "\n Dynamic Predicates Choicepoint Instructions\n");
fprintf(GLOBAL_stderr, "\n Dynamic Predicates Choicepoint Instructions\n");
print_instruction(_try_and_mark);
print_instruction(_retry_and_mark);
fprintf(Yap_stderr, "\n C Predicates Choicepoint Instructions\n");
fprintf(GLOBAL_stderr, "\n C Predicates Choicepoint Instructions\n");
print_instruction(_try_c);
print_instruction(_retry_c);
fprintf(Yap_stderr, "\n Indexing Instructions\n");
fprintf(Yap_stderr, "\n Switch on Type\n");
fprintf(GLOBAL_stderr, "\n Indexing Instructions\n");
fprintf(GLOBAL_stderr, "\n Switch on Type\n");
print_instruction(_switch_on_type);
print_instruction(_switch_list_nl);
print_instruction(_switch_on_arg_type);
print_instruction(_switch_on_sub_arg_type);
fprintf(Yap_stderr, "\n Switch on Value\n");
fprintf(GLOBAL_stderr, "\n Switch on Value\n");
print_instruction(_if_cons);
print_instruction(_go_on_cons);
print_instruction(_switch_on_cons);
print_instruction(_if_func);
print_instruction(_go_on_func);
print_instruction(_switch_on_func);
fprintf(Yap_stderr, "\n Other Switches\n");
fprintf(GLOBAL_stderr, "\n Other Switches\n");
print_instruction(_if_not_then);
fprintf(Yap_stderr, "\n Get Instructions\n");
fprintf(GLOBAL_stderr, "\n Get Instructions\n");
print_instruction(_get_x_var);
print_instruction(_get_y_var);
print_instruction(_get_x_val);
@ -174,7 +172,7 @@ p_show_op_counters()
print_instruction(_get_6atoms);
print_instruction(_get_list);
print_instruction(_get_struct);
fprintf(Yap_stderr, "\n Optimised Get Instructions\n");
fprintf(GLOBAL_stderr, "\n Optimised Get Instructions\n");
print_instruction(_glist_valx);
print_instruction(_glist_valy);
print_instruction(_gl_void_varx);
@ -182,7 +180,7 @@ p_show_op_counters()
print_instruction(_gl_void_valx);
print_instruction(_gl_void_valy);
fprintf(Yap_stderr, "\n Unify Read Instructions\n");
fprintf(GLOBAL_stderr, "\n Unify Read Instructions\n");
print_instruction(_unify_x_var);
print_instruction(_unify_x_var2);
print_instruction(_unify_y_var);
@ -195,7 +193,7 @@ p_show_op_counters()
print_instruction(_unify_n_voids);
print_instruction(_unify_list);
print_instruction(_unify_struct);
fprintf(Yap_stderr, "\n Unify Last Read Instructions\n");
fprintf(GLOBAL_stderr, "\n Unify Last Read Instructions\n");
print_instruction(_unify_l_x_var);
print_instruction(_unify_l_x_var2);
print_instruction(_unify_l_y_var);
@ -208,7 +206,7 @@ p_show_op_counters()
print_instruction(_unify_l_list);
print_instruction(_unify_l_struc);
fprintf(Yap_stderr, "\n Unify Write Instructions\n");
fprintf(GLOBAL_stderr, "\n Unify Write Instructions\n");
print_instruction(_unify_x_var_write);
print_instruction(_unify_x_var2_write);
print_instruction(_unify_y_var_write);
@ -221,7 +219,7 @@ p_show_op_counters()
print_instruction(_unify_n_voids_write);
print_instruction(_unify_list_write);
print_instruction(_unify_struct_write);
fprintf(Yap_stderr, "\n Unify Last Read Instructions\n");
fprintf(GLOBAL_stderr, "\n Unify Last Read Instructions\n");
print_instruction(_unify_l_x_var_write);
print_instruction(_unify_l_x_var2_write);
print_instruction(_unify_l_y_var_write);
@ -234,7 +232,7 @@ p_show_op_counters()
print_instruction(_unify_l_list_write);
print_instruction(_unify_l_struc_write);
fprintf(Yap_stderr, "\n Put Instructions\n");
fprintf(GLOBAL_stderr, "\n Put Instructions\n");
print_instruction(_put_x_var);
print_instruction(_put_y_var);
print_instruction(_put_x_val);
@ -245,7 +243,7 @@ p_show_op_counters()
print_instruction(_put_list);
print_instruction(_put_struct);
fprintf(Yap_stderr, "\n Write Instructions\n");
fprintf(GLOBAL_stderr, "\n Write Instructions\n");
print_instruction(_write_x_var);
print_instruction(_write_y_var);
print_instruction(_write_x_val);
@ -257,11 +255,11 @@ p_show_op_counters()
print_instruction(_write_n_voids);
print_instruction(_write_list);
print_instruction(_write_struct);
fprintf(Yap_stderr, "\n Last Write Instructions\n");
fprintf(GLOBAL_stderr, "\n Last Write Instructions\n");
print_instruction(_write_l_list);
print_instruction(_write_l_struc);
fprintf(Yap_stderr, "\n Miscellaneous Instructions\n");
fprintf(GLOBAL_stderr, "\n Miscellaneous Instructions\n");
print_instruction(_cut);
print_instruction(_cut_t);
print_instruction(_cut_e);
@ -292,11 +290,11 @@ p_show_op_counters()
typedef struct {
int nxvar, nxval, nyvar, nyval, ncons, nlist, nstru, nmisc;
} uYap_opcount;
} uGLOBAL_opcount;
typedef struct {
int ncalls, nexecs, nproceeds, ncallbips, ncuts, nallocs, ndeallocs;
} cYap_opcount;
} cGLOBAL_opcount;
typedef struct {
int ntries, nretries, ntrusts;
@ -306,8 +304,8 @@ static Int
p_show_ops_by_group(void)
{
uYap_opcount c_get, c_unify, c_put, c_write;
cYap_opcount c_control;
uGLOBAL_opcount c_get, c_unify, c_put, c_write;
cGLOBAL_opcount c_control;
ccpcount c_cp;
int gets, unifies, puts, writes, controls, choice_pts, indexes, misc,
total;
@ -322,261 +320,261 @@ p_show_ops_by_group(void)
wchar_t *program;
program = RepAtom(at1)->WStrOfAE;
fprintf(Yap_stderr, "\n Instructions Executed in %S\n", program);
fprintf(GLOBAL_stderr, "\n Instructions Executed in %S\n", program);
} else {
char *program;
program = RepAtom(at1)->StrOfAE;
fprintf(Yap_stderr, "\n Instructions Executed in %s\n", program);
fprintf(GLOBAL_stderr, "\n Instructions Executed in %s\n", program);
}
c_get.nxvar =
Yap_opcount[_get_x_var];
GLOBAL_opcount[_get_x_var];
c_get.nyvar =
Yap_opcount[_get_y_var];
GLOBAL_opcount[_get_y_var];
c_get.nxval =
Yap_opcount[_get_x_val];
GLOBAL_opcount[_get_x_val];
c_get.nyval =
Yap_opcount[_get_y_val];
GLOBAL_opcount[_get_y_val];
c_get.ncons =
Yap_opcount[_get_atom]+
Yap_opcount[_get_2atoms]+
Yap_opcount[_get_3atoms]+
Yap_opcount[_get_4atoms]+
Yap_opcount[_get_5atoms]+
Yap_opcount[_get_6atoms];
GLOBAL_opcount[_get_atom]+
GLOBAL_opcount[_get_2atoms]+
GLOBAL_opcount[_get_3atoms]+
GLOBAL_opcount[_get_4atoms]+
GLOBAL_opcount[_get_5atoms]+
GLOBAL_opcount[_get_6atoms];
c_get.nlist =
Yap_opcount[_get_list] +
Yap_opcount[_glist_valx] +
Yap_opcount[_glist_valy] +
Yap_opcount[_gl_void_varx] +
Yap_opcount[_gl_void_vary] +
Yap_opcount[_gl_void_valx] +
Yap_opcount[_gl_void_valy];
GLOBAL_opcount[_get_list] +
GLOBAL_opcount[_glist_valx] +
GLOBAL_opcount[_glist_valy] +
GLOBAL_opcount[_gl_void_varx] +
GLOBAL_opcount[_gl_void_vary] +
GLOBAL_opcount[_gl_void_valx] +
GLOBAL_opcount[_gl_void_valy];
c_get.nstru =
Yap_opcount[_get_struct];
GLOBAL_opcount[_get_struct];
gets = c_get.nxvar + c_get.nyvar + c_get.nxval + c_get.nyval +
c_get.ncons + c_get.nlist + c_get.nstru;
c_unify.nxvar =
Yap_opcount[_unify_x_var] +
Yap_opcount[_unify_void] +
Yap_opcount[_unify_n_voids] +
2 * Yap_opcount[_unify_x_var2] +
2 * Yap_opcount[_gl_void_varx] +
Yap_opcount[_gl_void_vary] +
Yap_opcount[_gl_void_valx] +
Yap_opcount[_unify_l_x_var] +
Yap_opcount[_unify_l_void] +
Yap_opcount[_unify_l_n_voids] +
2 * Yap_opcount[_unify_l_x_var2] +
Yap_opcount[_unify_x_var_write] +
Yap_opcount[_unify_void_write] +
Yap_opcount[_unify_n_voids_write] +
2 * Yap_opcount[_unify_x_var2_write] +
Yap_opcount[_unify_l_x_var_write] +
Yap_opcount[_unify_l_void_write] +
Yap_opcount[_unify_l_n_voids_write] +
2 * Yap_opcount[_unify_l_x_var2_write];
GLOBAL_opcount[_unify_x_var] +
GLOBAL_opcount[_unify_void] +
GLOBAL_opcount[_unify_n_voids] +
2 * GLOBAL_opcount[_unify_x_var2] +
2 * GLOBAL_opcount[_gl_void_varx] +
GLOBAL_opcount[_gl_void_vary] +
GLOBAL_opcount[_gl_void_valx] +
GLOBAL_opcount[_unify_l_x_var] +
GLOBAL_opcount[_unify_l_void] +
GLOBAL_opcount[_unify_l_n_voids] +
2 * GLOBAL_opcount[_unify_l_x_var2] +
GLOBAL_opcount[_unify_x_var_write] +
GLOBAL_opcount[_unify_void_write] +
GLOBAL_opcount[_unify_n_voids_write] +
2 * GLOBAL_opcount[_unify_x_var2_write] +
GLOBAL_opcount[_unify_l_x_var_write] +
GLOBAL_opcount[_unify_l_void_write] +
GLOBAL_opcount[_unify_l_n_voids_write] +
2 * GLOBAL_opcount[_unify_l_x_var2_write];
c_unify.nyvar =
Yap_opcount[_unify_y_var] +
Yap_opcount[_gl_void_vary] +
Yap_opcount[_unify_l_y_var] +
Yap_opcount[_unify_y_var_write] +
Yap_opcount[_unify_l_y_var_write];
GLOBAL_opcount[_unify_y_var] +
GLOBAL_opcount[_gl_void_vary] +
GLOBAL_opcount[_unify_l_y_var] +
GLOBAL_opcount[_unify_y_var_write] +
GLOBAL_opcount[_unify_l_y_var_write];
c_unify.nxval =
Yap_opcount[_unify_x_val] +
Yap_opcount[_unify_x_loc] +
Yap_opcount[_glist_valx] +
Yap_opcount[_gl_void_valx] +
Yap_opcount[_unify_l_x_val] +
Yap_opcount[_unify_l_x_loc] +
Yap_opcount[_unify_x_val_write] +
Yap_opcount[_unify_x_loc_write] +
Yap_opcount[_unify_l_x_val_write] +
Yap_opcount[_unify_l_x_loc_write];
GLOBAL_opcount[_unify_x_val] +
GLOBAL_opcount[_unify_x_loc] +
GLOBAL_opcount[_glist_valx] +
GLOBAL_opcount[_gl_void_valx] +
GLOBAL_opcount[_unify_l_x_val] +
GLOBAL_opcount[_unify_l_x_loc] +
GLOBAL_opcount[_unify_x_val_write] +
GLOBAL_opcount[_unify_x_loc_write] +
GLOBAL_opcount[_unify_l_x_val_write] +
GLOBAL_opcount[_unify_l_x_loc_write];
c_unify.nyval =
Yap_opcount[_unify_y_val] +
Yap_opcount[_unify_y_loc] +
Yap_opcount[_glist_valy] +
Yap_opcount[_gl_void_valy] +
Yap_opcount[_unify_l_y_val] +
Yap_opcount[_unify_l_y_loc] +
Yap_opcount[_unify_y_val_write] +
Yap_opcount[_unify_y_loc_write] +
Yap_opcount[_unify_l_y_val_write] +
Yap_opcount[_unify_l_y_loc_write];
GLOBAL_opcount[_unify_y_val] +
GLOBAL_opcount[_unify_y_loc] +
GLOBAL_opcount[_glist_valy] +
GLOBAL_opcount[_gl_void_valy] +
GLOBAL_opcount[_unify_l_y_val] +
GLOBAL_opcount[_unify_l_y_loc] +
GLOBAL_opcount[_unify_y_val_write] +
GLOBAL_opcount[_unify_y_loc_write] +
GLOBAL_opcount[_unify_l_y_val_write] +
GLOBAL_opcount[_unify_l_y_loc_write];
c_unify.ncons =
Yap_opcount[_unify_atom] +
Yap_opcount[_unify_n_atoms] +
Yap_opcount[_unify_l_atom] +
Yap_opcount[_unify_atom_write] +
Yap_opcount[_unify_n_atoms_write] +
Yap_opcount[_unify_l_atom_write];
GLOBAL_opcount[_unify_atom] +
GLOBAL_opcount[_unify_n_atoms] +
GLOBAL_opcount[_unify_l_atom] +
GLOBAL_opcount[_unify_atom_write] +
GLOBAL_opcount[_unify_n_atoms_write] +
GLOBAL_opcount[_unify_l_atom_write];
c_unify.nlist =
Yap_opcount[_unify_list] +
Yap_opcount[_unify_l_list] +
Yap_opcount[_unify_list_write] +
Yap_opcount[_unify_l_list_write];
GLOBAL_opcount[_unify_list] +
GLOBAL_opcount[_unify_l_list] +
GLOBAL_opcount[_unify_list_write] +
GLOBAL_opcount[_unify_l_list_write];
c_unify.nstru =
Yap_opcount[_unify_struct] +
Yap_opcount[_unify_l_struc] +
Yap_opcount[_unify_struct_write] +
Yap_opcount[_unify_l_struc_write];
GLOBAL_opcount[_unify_struct] +
GLOBAL_opcount[_unify_l_struc] +
GLOBAL_opcount[_unify_struct_write] +
GLOBAL_opcount[_unify_l_struc_write];
c_unify.nmisc =
Yap_opcount[_pop] +
Yap_opcount[_pop_n];
GLOBAL_opcount[_pop] +
GLOBAL_opcount[_pop_n];
unifies = c_unify.nxvar + c_unify.nyvar + c_unify.nxval + c_unify.nyval +
c_unify.ncons + c_unify.nlist + c_unify.nstru + c_unify.nmisc;
c_put.nxvar =
Yap_opcount[_put_x_var];
GLOBAL_opcount[_put_x_var];
c_put.nyvar =
Yap_opcount[_put_y_var];
GLOBAL_opcount[_put_y_var];
c_put.nxval =
Yap_opcount[_put_x_val]+
2*Yap_opcount[_put_xx_val];
GLOBAL_opcount[_put_x_val]+
2*GLOBAL_opcount[_put_xx_val];
c_put.nyval =
Yap_opcount[_put_y_val];
GLOBAL_opcount[_put_y_val];
c_put.ncons =
Yap_opcount[_put_atom];
GLOBAL_opcount[_put_atom];
c_put.nlist =
Yap_opcount[_put_list];
GLOBAL_opcount[_put_list];
c_put.nstru =
Yap_opcount[_put_struct];
GLOBAL_opcount[_put_struct];
puts = c_put.nxvar + c_put.nyvar + c_put.nxval + c_put.nyval +
c_put.ncons + c_put.nlist + c_put.nstru;
c_write.nxvar =
Yap_opcount[_write_x_var] +
Yap_opcount[_write_void] +
Yap_opcount[_write_n_voids];
GLOBAL_opcount[_write_x_var] +
GLOBAL_opcount[_write_void] +
GLOBAL_opcount[_write_n_voids];
c_write.nyvar =
Yap_opcount[_write_y_var];
GLOBAL_opcount[_write_y_var];
c_write.nxval =
Yap_opcount[_write_x_val];
GLOBAL_opcount[_write_x_val];
c_write.nyval =
Yap_opcount[_write_y_val];
GLOBAL_opcount[_write_y_val];
c_write.ncons =
Yap_opcount[_write_atom];
GLOBAL_opcount[_write_atom];
c_write.nlist =
Yap_opcount[_write_list];
GLOBAL_opcount[_write_list];
c_write.nstru =
Yap_opcount[_write_struct];
GLOBAL_opcount[_write_struct];
writes = c_write.nxvar + c_write.nyvar + c_write.nxval + c_write.nyval +
c_write.ncons + c_write.nlist + c_write.nstru;
c_control.nexecs =
Yap_opcount[_execute] +
Yap_opcount[_dexecute];
GLOBAL_opcount[_execute] +
GLOBAL_opcount[_dexecute];
c_control.ncalls =
Yap_opcount[_call] +
Yap_opcount[_fcall];
GLOBAL_opcount[_call] +
GLOBAL_opcount[_fcall];
c_control.nproceeds =
Yap_opcount[_procceed];
GLOBAL_opcount[_procceed];
c_control.ncallbips =
Yap_opcount[_call_cpred] +
Yap_opcount[_call_c_wfail] +
Yap_opcount[_try_c] +
Yap_opcount[_retry_c] +
Yap_opcount[_op_fail] +
Yap_opcount[_trust_fail] +
Yap_opcount[_p_atom_x] +
Yap_opcount[_p_atom_y] +
Yap_opcount[_p_atomic_x] +
Yap_opcount[_p_atomic_y] +
Yap_opcount[_p_compound_x] +
Yap_opcount[_p_compound_y] +
Yap_opcount[_p_float_x] +
Yap_opcount[_p_float_y] +
Yap_opcount[_p_integer_x] +
Yap_opcount[_p_integer_y] +
Yap_opcount[_p_nonvar_x] +
Yap_opcount[_p_nonvar_y] +
Yap_opcount[_p_number_x] +
Yap_opcount[_p_number_y] +
Yap_opcount[_p_var_x] +
Yap_opcount[_p_var_y] +
Yap_opcount[_p_db_ref_x] +
Yap_opcount[_p_db_ref_y] +
Yap_opcount[_p_cut_by_x] +
Yap_opcount[_p_cut_by_y] +
Yap_opcount[_p_primitive_x] +
Yap_opcount[_p_primitive_y] +
Yap_opcount[_p_equal] +
Yap_opcount[_p_plus_vv] +
Yap_opcount[_p_plus_vc] +
Yap_opcount[_p_plus_y_vv] +
Yap_opcount[_p_plus_y_vc] +
Yap_opcount[_p_minus_vv] +
Yap_opcount[_p_minus_cv] +
Yap_opcount[_p_minus_y_vv] +
Yap_opcount[_p_minus_y_cv] +
Yap_opcount[_p_times_vv] +
Yap_opcount[_p_times_vc] +
Yap_opcount[_p_times_y_vv] +
Yap_opcount[_p_times_y_vc] +
Yap_opcount[_p_div_vv] +
Yap_opcount[_p_div_vc] +
Yap_opcount[_p_div_cv] +
Yap_opcount[_p_div_y_vv] +
Yap_opcount[_p_div_y_vc] +
Yap_opcount[_p_div_y_cv] +
Yap_opcount[_p_or_vv] +
Yap_opcount[_p_or_vc] +
Yap_opcount[_p_or_y_vv] +
Yap_opcount[_p_or_y_vc] +
Yap_opcount[_p_and_vv] +
Yap_opcount[_p_and_vc] +
Yap_opcount[_p_and_y_vv] +
Yap_opcount[_p_and_y_vc] +
Yap_opcount[_p_sll_vv] +
Yap_opcount[_p_sll_vc] +
Yap_opcount[_p_sll_y_vv] +
Yap_opcount[_p_sll_y_vc] +
Yap_opcount[_p_slr_vv] +
Yap_opcount[_p_slr_vc] +
Yap_opcount[_p_slr_y_vv] +
Yap_opcount[_p_slr_y_vc] +
Yap_opcount[_p_dif] +
Yap_opcount[_p_eq] +
Yap_opcount[_p_arg_vv] +
Yap_opcount[_p_arg_cv] +
Yap_opcount[_p_arg_y_vv] +
Yap_opcount[_p_arg_y_cv] +
Yap_opcount[_p_functor] +
Yap_opcount[_p_func2s_vv] +
Yap_opcount[_p_func2s_cv] +
Yap_opcount[_p_func2s_vc] +
Yap_opcount[_p_func2s_y_vv] +
Yap_opcount[_p_func2s_y_cv] +
Yap_opcount[_p_func2s_y_vc] +
Yap_opcount[_p_func2f_xx] +
Yap_opcount[_p_func2f_xy] +
Yap_opcount[_p_func2f_yx] +
Yap_opcount[_p_func2f_yy];
GLOBAL_opcount[_call_cpred] +
GLOBAL_opcount[_call_c_wfail] +
GLOBAL_opcount[_try_c] +
GLOBAL_opcount[_retry_c] +
GLOBAL_opcount[_op_fail] +
GLOBAL_opcount[_trust_fail] +
GLOBAL_opcount[_p_atom_x] +
GLOBAL_opcount[_p_atom_y] +
GLOBAL_opcount[_p_atomic_x] +
GLOBAL_opcount[_p_atomic_y] +
GLOBAL_opcount[_p_compound_x] +
GLOBAL_opcount[_p_compound_y] +
GLOBAL_opcount[_p_float_x] +
GLOBAL_opcount[_p_float_y] +
GLOBAL_opcount[_p_integer_x] +
GLOBAL_opcount[_p_integer_y] +
GLOBAL_opcount[_p_nonvar_x] +
GLOBAL_opcount[_p_nonvar_y] +
GLOBAL_opcount[_p_number_x] +
GLOBAL_opcount[_p_number_y] +
GLOBAL_opcount[_p_var_x] +
GLOBAL_opcount[_p_var_y] +
GLOBAL_opcount[_p_db_ref_x] +
GLOBAL_opcount[_p_db_ref_y] +
GLOBAL_opcount[_p_cut_by_x] +
GLOBAL_opcount[_p_cut_by_y] +
GLOBAL_opcount[_p_primitive_x] +
GLOBAL_opcount[_p_primitive_y] +
GLOBAL_opcount[_p_equal] +
GLOBAL_opcount[_p_plus_vv] +
GLOBAL_opcount[_p_plus_vc] +
GLOBAL_opcount[_p_plus_y_vv] +
GLOBAL_opcount[_p_plus_y_vc] +
GLOBAL_opcount[_p_minus_vv] +
GLOBAL_opcount[_p_minus_cv] +
GLOBAL_opcount[_p_minus_y_vv] +
GLOBAL_opcount[_p_minus_y_cv] +
GLOBAL_opcount[_p_times_vv] +
GLOBAL_opcount[_p_times_vc] +
GLOBAL_opcount[_p_times_y_vv] +
GLOBAL_opcount[_p_times_y_vc] +
GLOBAL_opcount[_p_div_vv] +
GLOBAL_opcount[_p_div_vc] +
GLOBAL_opcount[_p_div_cv] +
GLOBAL_opcount[_p_div_y_vv] +
GLOBAL_opcount[_p_div_y_vc] +
GLOBAL_opcount[_p_div_y_cv] +
GLOBAL_opcount[_p_or_vv] +
GLOBAL_opcount[_p_or_vc] +
GLOBAL_opcount[_p_or_y_vv] +
GLOBAL_opcount[_p_or_y_vc] +
GLOBAL_opcount[_p_and_vv] +
GLOBAL_opcount[_p_and_vc] +
GLOBAL_opcount[_p_and_y_vv] +
GLOBAL_opcount[_p_and_y_vc] +
GLOBAL_opcount[_p_sll_vv] +
GLOBAL_opcount[_p_sll_vc] +
GLOBAL_opcount[_p_sll_y_vv] +
GLOBAL_opcount[_p_sll_y_vc] +
GLOBAL_opcount[_p_slr_vv] +
GLOBAL_opcount[_p_slr_vc] +
GLOBAL_opcount[_p_slr_y_vv] +
GLOBAL_opcount[_p_slr_y_vc] +
GLOBAL_opcount[_p_dif] +
GLOBAL_opcount[_p_eq] +
GLOBAL_opcount[_p_arg_vv] +
GLOBAL_opcount[_p_arg_cv] +
GLOBAL_opcount[_p_arg_y_vv] +
GLOBAL_opcount[_p_arg_y_cv] +
GLOBAL_opcount[_p_functor] +
GLOBAL_opcount[_p_func2s_vv] +
GLOBAL_opcount[_p_func2s_cv] +
GLOBAL_opcount[_p_func2s_vc] +
GLOBAL_opcount[_p_func2s_y_vv] +
GLOBAL_opcount[_p_func2s_y_cv] +
GLOBAL_opcount[_p_func2s_y_vc] +
GLOBAL_opcount[_p_func2f_xx] +
GLOBAL_opcount[_p_func2f_xy] +
GLOBAL_opcount[_p_func2f_yx] +
GLOBAL_opcount[_p_func2f_yy];
c_control.ncuts =
Yap_opcount[_cut] +
Yap_opcount[_cut_t] +
Yap_opcount[_cut_e] +
Yap_opcount[_commit_b_x] +
Yap_opcount[_commit_b_y];
GLOBAL_opcount[_cut] +
GLOBAL_opcount[_cut_t] +
GLOBAL_opcount[_cut_e] +
GLOBAL_opcount[_commit_b_x] +
GLOBAL_opcount[_commit_b_y];
c_control.nallocs =
Yap_opcount[_allocate] +
Yap_opcount[_fcall];
GLOBAL_opcount[_allocate] +
GLOBAL_opcount[_fcall];
c_control.ndeallocs =
Yap_opcount[_dexecute] +
Yap_opcount[_deallocate];
GLOBAL_opcount[_dexecute] +
GLOBAL_opcount[_deallocate];
controls =
c_control.nexecs +
@ -585,30 +583,30 @@ p_show_ops_by_group(void)
c_control.ncuts +
c_control.nallocs +
c_control.ndeallocs +
Yap_opcount[_jump] +
Yap_opcount[_move_back] +
Yap_opcount[_try_in];
GLOBAL_opcount[_jump] +
GLOBAL_opcount[_move_back] +
GLOBAL_opcount[_try_in];
c_cp.ntries =
Yap_opcount[_try_me] +
Yap_opcount[_try_and_mark] +
Yap_opcount[_try_c] +
Yap_opcount[_try_clause] +
Yap_opcount[_either];
GLOBAL_opcount[_try_me] +
GLOBAL_opcount[_try_and_mark] +
GLOBAL_opcount[_try_c] +
GLOBAL_opcount[_try_clause] +
GLOBAL_opcount[_either];
c_cp.nretries =
Yap_opcount[_retry_me] +
Yap_opcount[_retry_and_mark] +
Yap_opcount[_retry_c] +
Yap_opcount[_retry] +
Yap_opcount[_or_else];
GLOBAL_opcount[_retry_me] +
GLOBAL_opcount[_retry_and_mark] +
GLOBAL_opcount[_retry_c] +
GLOBAL_opcount[_retry] +
GLOBAL_opcount[_or_else];
c_cp.ntrusts =
Yap_opcount[_trust_me] +
Yap_opcount[_trust] +
Yap_opcount[_or_last];
GLOBAL_opcount[_trust_me] +
GLOBAL_opcount[_trust] +
GLOBAL_opcount[_or_last];
choice_pts =
c_cp.ntries +
@ -616,70 +614,70 @@ p_show_ops_by_group(void)
c_cp.ntrusts;
indexes =
Yap_opcount[_jump_if_var] +
Yap_opcount[_switch_on_type] +
Yap_opcount[_switch_list_nl] +
Yap_opcount[_switch_on_arg_type] +
Yap_opcount[_switch_on_sub_arg_type] +
Yap_opcount[_switch_on_cons] +
Yap_opcount[_go_on_cons] +
Yap_opcount[_if_cons] +
Yap_opcount[_switch_on_func] +
Yap_opcount[_go_on_func] +
Yap_opcount[_if_func] +
Yap_opcount[_if_not_then];
GLOBAL_opcount[_jump_if_var] +
GLOBAL_opcount[_switch_on_type] +
GLOBAL_opcount[_switch_list_nl] +
GLOBAL_opcount[_switch_on_arg_type] +
GLOBAL_opcount[_switch_on_sub_arg_type] +
GLOBAL_opcount[_switch_on_cons] +
GLOBAL_opcount[_go_on_cons] +
GLOBAL_opcount[_if_cons] +
GLOBAL_opcount[_switch_on_func] +
GLOBAL_opcount[_go_on_func] +
GLOBAL_opcount[_if_func] +
GLOBAL_opcount[_if_not_then];
misc =
c_control.ncallbips +
Yap_opcount[_Ystop] +
Yap_opcount[_Nstop] +
Yap_opcount[_index_pred] +
Yap_opcount[_lock_pred] +
GLOBAL_opcount[_Ystop] +
GLOBAL_opcount[_Nstop] +
GLOBAL_opcount[_index_pred] +
GLOBAL_opcount[_lock_pred] +
#if THREADS
Yap_opcount[_thread_local] +
GLOBAL_opcount[_thread_local] +
#endif
Yap_opcount[_save_b_x] +
Yap_opcount[_save_b_y] +
Yap_opcount[_undef_p] +
Yap_opcount[_spy_pred] +
Yap_opcount[_spy_or_trymark] +
Yap_opcount[_save_pair_x] +
Yap_opcount[_save_pair_y] +
Yap_opcount[_save_pair_x_write] +
Yap_opcount[_save_pair_y_write] +
Yap_opcount[_save_appl_x] +
Yap_opcount[_save_appl_y] +
Yap_opcount[_save_appl_x_write] +
Yap_opcount[_save_appl_y_write];
GLOBAL_opcount[_save_b_x] +
GLOBAL_opcount[_save_b_y] +
GLOBAL_opcount[_undef_p] +
GLOBAL_opcount[_spy_pred] +
GLOBAL_opcount[_spy_or_trymark] +
GLOBAL_opcount[_save_pair_x] +
GLOBAL_opcount[_save_pair_y] +
GLOBAL_opcount[_save_pair_x_write] +
GLOBAL_opcount[_save_pair_y_write] +
GLOBAL_opcount[_save_appl_x] +
GLOBAL_opcount[_save_appl_y] +
GLOBAL_opcount[_save_appl_x_write] +
GLOBAL_opcount[_save_appl_y_write];
total = gets + unifies + puts + writes + controls + choice_pts + indexes + misc;
/* for (i = 0; i <= _std_top; ++i)
* print_instruction(i);
*/
fprintf(Yap_stderr, "Groups are\n\n");
fprintf(Yap_stderr, " GET instructions: %8d (%3d%%)\n", gets,
fprintf(GLOBAL_stderr, "Groups are\n\n");
fprintf(GLOBAL_stderr, " GET instructions: %8d (%3d%%)\n", gets,
(gets * 100) / total);
fprintf(Yap_stderr, " UNIFY instructions: %8d (%3d%%)\n", unifies,
fprintf(GLOBAL_stderr, " UNIFY instructions: %8d (%3d%%)\n", unifies,
(unifies * 100) / total);
fprintf(Yap_stderr, " PUT instructions: %8d (%3d%%)\n", puts,
fprintf(GLOBAL_stderr, " PUT instructions: %8d (%3d%%)\n", puts,
(puts * 100) / total);
fprintf(Yap_stderr, " WRITE instructions: %8d (%3d%%)\n", writes,
fprintf(GLOBAL_stderr, " WRITE instructions: %8d (%3d%%)\n", writes,
(writes * 100) / total);
fprintf(Yap_stderr, " CONTROL instructions: %8d (%3d%%)\n", controls,
fprintf(GLOBAL_stderr, " CONTROL instructions: %8d (%3d%%)\n", controls,
(controls * 100) / total);
fprintf(Yap_stderr, " CHOICE POINT instructions: %8d (%3d%%)\n", choice_pts,
fprintf(GLOBAL_stderr, " CHOICE POINT instructions: %8d (%3d%%)\n", choice_pts,
(choice_pts * 100) / total);
fprintf(Yap_stderr, " INDEXING instructions: %8d (%3d%%)\n", indexes,
fprintf(GLOBAL_stderr, " INDEXING instructions: %8d (%3d%%)\n", indexes,
(indexes * 100) / total);
fprintf(Yap_stderr, " MISCELLANEOUS instructions: %8d (%3d%%)\n", misc,
fprintf(GLOBAL_stderr, " MISCELLANEOUS instructions: %8d (%3d%%)\n", misc,
(misc * 100) / total);
fprintf(Yap_stderr, "_______________________________________________\n");
fprintf(Yap_stderr, " TOTAL instructions: %8d (%3d%%)\n\n", total,
fprintf(GLOBAL_stderr, "_______________________________________________\n");
fprintf(GLOBAL_stderr, " TOTAL instructions: %8d (%3d%%)\n\n", total,
(total * 100) / total);
fprintf(Yap_stderr, "\n Analysis of Unification Instructions in %s \n", program);
fprintf(Yap_stderr, " XVAR, YVAR, XVAL, YVAL, CONS, LIST, STRUCT\n");
fprintf(Yap_stderr, " GET: %8d %8d %8d %8d %8d %8d %8d\n",
fprintf(GLOBAL_stderr, "\n Analysis of Unification Instructions in %s \n", program);
fprintf(GLOBAL_stderr, " XVAR, YVAR, XVAL, YVAL, CONS, LIST, STRUCT\n");
fprintf(GLOBAL_stderr, " GET: %8d %8d %8d %8d %8d %8d %8d\n",
c_get.nxvar,
c_get.nyvar,
c_get.nxval,
@ -687,7 +685,7 @@ p_show_ops_by_group(void)
c_get.ncons,
c_get.nlist,
c_get.nstru);
fprintf(Yap_stderr, "UNIFY: %8d %8d %8d %8d %8d %8d %8d\n",
fprintf(GLOBAL_stderr, "UNIFY: %8d %8d %8d %8d %8d %8d %8d\n",
c_unify.nxvar,
c_unify.nyvar,
c_unify.nxval,
@ -695,7 +693,7 @@ p_show_ops_by_group(void)
c_unify.ncons,
c_unify.nlist,
c_unify.nstru);
fprintf(Yap_stderr, " PUT: %8d %8d %8d %8d %8d %8d %8d\n",
fprintf(GLOBAL_stderr, " PUT: %8d %8d %8d %8d %8d %8d %8d\n",
c_put.nxvar,
c_put.nyvar,
c_put.nxval,
@ -703,7 +701,7 @@ p_show_ops_by_group(void)
c_put.ncons,
c_put.nlist,
c_put.nstru);
fprintf(Yap_stderr, "WRITE: %8d %8d %8d %8d %8d %8d %8d\n",
fprintf(GLOBAL_stderr, "WRITE: %8d %8d %8d %8d %8d %8d %8d\n",
c_write.nxvar,
c_write.nyvar,
c_write.nxval,
@ -711,8 +709,8 @@ p_show_ops_by_group(void)
c_write.ncons,
c_write.nlist,
c_write.nstru);
fprintf(Yap_stderr, " ___________________________________________________\n");
fprintf(Yap_stderr, "TOTAL: %8d %8d %8d %8d %8d %8d %8d\n",
fprintf(GLOBAL_stderr, " ___________________________________________________\n");
fprintf(GLOBAL_stderr, "TOTAL: %8d %8d %8d %8d %8d %8d %8d\n",
c_get.nxvar + c_unify.nxvar + c_put.nxvar + c_write.nxvar,
c_get.nyvar + c_unify.nyvar + c_put.nyvar + c_write.nyvar,
c_get.nxval + c_unify.nxval + c_put.nxval + c_write.nxval,
@ -722,9 +720,9 @@ p_show_ops_by_group(void)
c_get.nstru + c_unify.nstru + c_put.nstru + c_write.nstru
);
fprintf(Yap_stderr, "\n Analysis of Unification Instructions in %s \n", program);
fprintf(Yap_stderr, " XVAR, YVAR, XVAL, YVAL, CONS, LIST, STRUCT\n");
fprintf(Yap_stderr, " GET: %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%%\n",
fprintf(GLOBAL_stderr, "\n Analysis of Unification Instructions in %s \n", program);
fprintf(GLOBAL_stderr, " XVAR, YVAR, XVAL, YVAL, CONS, LIST, STRUCT\n");
fprintf(GLOBAL_stderr, " GET: %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%%\n",
(((double) c_get.nxvar) * 100) / total,
(((double) c_get.nyvar) * 100) / total,
(((double) c_get.nxval) * 100) / total,
@ -732,7 +730,7 @@ p_show_ops_by_group(void)
(((double) c_get.ncons) * 100) / total,
(((double) c_get.nlist) * 100) / total,
(((double) c_get.nstru) * 100) / total);
fprintf(Yap_stderr, "UNIFY: %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%%\n",
fprintf(GLOBAL_stderr, "UNIFY: %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%%\n",
(((double) c_unify.nxvar) * 100) / total,
(((double) c_unify.nyvar) * 100) / total,
(((double) c_unify.nxval) * 100) / total,
@ -740,7 +738,7 @@ p_show_ops_by_group(void)
(((double) c_unify.ncons) * 100) / total,
(((double) c_unify.nlist) * 100) / total,
(((double) c_unify.nstru) * 100) / total);
fprintf(Yap_stderr, " PUT: %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%%\n",
fprintf(GLOBAL_stderr, " PUT: %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%%\n",
(((double) c_put.nxvar) * 100) / total,
(((double) c_put.nyvar) * 100) / total,
(((double) c_put.nxval) * 100) / total,
@ -748,7 +746,7 @@ p_show_ops_by_group(void)
(((double) c_put.ncons) * 100) / total,
(((double) c_put.nlist) * 100) / total,
(((double) c_put.nstru) * 100) / total);
fprintf(Yap_stderr, "WRITE: %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%%\n",
fprintf(GLOBAL_stderr, "WRITE: %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%%\n",
(((double) c_write.nxvar) * 100) / total,
(((double) c_write.nyvar) * 100) / total,
(((double) c_write.nxval) * 100) / total,
@ -756,8 +754,8 @@ p_show_ops_by_group(void)
(((double) c_write.ncons) * 100) / total,
(((double) c_write.nlist) * 100) / total,
(((double) c_write.nstru) * 100) / total);
fprintf(Yap_stderr, " ___________________________________________________\n");
fprintf(Yap_stderr, "TOTAL: %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%%\n",
fprintf(GLOBAL_stderr, " ___________________________________________________\n");
fprintf(GLOBAL_stderr, "TOTAL: %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%% %3.2f%%\n",
(((double) c_get.nxvar + c_unify.nxvar + c_put.nxvar + c_write.nxvar) * 100) / total,
(((double) c_get.nyvar + c_unify.nyvar + c_put.nyvar + c_write.nyvar) * 100) / total,
(((double) c_get.nxval + c_unify.nxval + c_put.nxval + c_write.nxval) * 100) / total,
@ -767,36 +765,36 @@ p_show_ops_by_group(void)
(((double) c_get.nstru + c_unify.nstru + c_put.nstru + c_write.nstru) * 100) / total
);
fprintf(Yap_stderr, "\n Control Instructions Executed in %s \n", program);
fprintf(Yap_stderr, "Grouped as\n\n");
fprintf(Yap_stderr, " CALL instructions: %8d (%3d%%)\n",
fprintf(GLOBAL_stderr, "\n Control Instructions Executed in %s \n", program);
fprintf(GLOBAL_stderr, "Grouped as\n\n");
fprintf(GLOBAL_stderr, " CALL instructions: %8d (%3d%%)\n",
c_control.ncalls, (c_control.ncalls * 100) / total);
fprintf(Yap_stderr, " PROCEED instructions: %8d (%3d%%)\n",
fprintf(GLOBAL_stderr, " PROCEED instructions: %8d (%3d%%)\n",
c_control.nproceeds, (c_control.nproceeds * 100) / total);
fprintf(Yap_stderr, " EXECUTE instructions: %8d (%3d%%)\n",
fprintf(GLOBAL_stderr, " EXECUTE instructions: %8d (%3d%%)\n",
c_control.nexecs, (c_control.nexecs * 100) / total);
fprintf(Yap_stderr, " CUT instructions: %8d (%3d%%)\n",
fprintf(GLOBAL_stderr, " CUT instructions: %8d (%3d%%)\n",
c_control.ncuts, (c_control.ncuts * 100) / total);
fprintf(Yap_stderr, " CALL_BIP instructions: %8d (%3d%%)\n",
fprintf(GLOBAL_stderr, " CALL_BIP instructions: %8d (%3d%%)\n",
c_control.ncallbips, (c_control.ncallbips * 100) / total);
fprintf(Yap_stderr, " ALLOCATE instructions: %8d (%3d%%)\n",
fprintf(GLOBAL_stderr, " ALLOCATE instructions: %8d (%3d%%)\n",
c_control.nallocs, (c_control.nallocs * 100) / total);
fprintf(Yap_stderr, " DEALLOCATE instructions: %8d (%3d%%)\n",
fprintf(GLOBAL_stderr, " DEALLOCATE instructions: %8d (%3d%%)\n",
c_control.ndeallocs, (c_control.ndeallocs * 100) / total);
fprintf(Yap_stderr, "_______________________________________________\n");
fprintf(Yap_stderr, " TOTAL instructions: %8d (%3d%%)\n\n", total,
fprintf(GLOBAL_stderr, "_______________________________________________\n");
fprintf(GLOBAL_stderr, " TOTAL instructions: %8d (%3d%%)\n\n", total,
(total * 100) / total);
fprintf(Yap_stderr, "\n Choice Point Manipulation Instructions Executed in %s \n", program);
fprintf(Yap_stderr, "Grouped as\n\n");
fprintf(Yap_stderr, " TRY instructions: %8d (%3d%%)\n",
fprintf(GLOBAL_stderr, "\n Choice Point Manipulation Instructions Executed in %s \n", program);
fprintf(GLOBAL_stderr, "Grouped as\n\n");
fprintf(GLOBAL_stderr, " TRY instructions: %8d (%3d%%)\n",
c_cp.ntries, (c_cp.ntries * 100) / total);
fprintf(Yap_stderr, " RETRY instructions: %8d (%3d%%)\n",
fprintf(GLOBAL_stderr, " RETRY instructions: %8d (%3d%%)\n",
c_cp.nretries, (c_cp.nretries * 100) / total);
fprintf(Yap_stderr, " TRUST instructions: %8d (%3d%%)\n",
fprintf(GLOBAL_stderr, " TRUST instructions: %8d (%3d%%)\n",
c_cp.ntrusts, (c_cp.ntrusts * 100) / total);
fprintf(Yap_stderr, "_______________________________________________\n");
fprintf(Yap_stderr, " TOTAL instructions: %8d (%3d%%)\n\n", total,
fprintf(GLOBAL_stderr, "_______________________________________________\n");
fprintf(GLOBAL_stderr, " TOTAL instructions: %8d (%3d%%)\n\n", total,
(total * 100) / total);
return TRUE;
@ -828,7 +826,7 @@ p_show_sequences(void)
return FALSE;
}
for (i = 0; i <= _std_top; ++i) {
sum += Yap_opcount[i];
sum += GLOBAL_opcount[i];
}
for (i = 0; i <= _std_top; ++i) {
for (j = 0; j <= _std_top; ++j) {

View File

@ -158,12 +158,11 @@ typedef struct MMAP_ARRAY_BLOCK {
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;
mmap_array_block *ptr = GLOBAL_mmap_arrays, *optr = GLOBAL_mmap_arrays;
while (ptr != NULL && ptr->start != area) {
ptr = ptr->next;
@ -193,7 +192,7 @@ CloseMmappedArray(StaticArrayEntry *pp, void *area USES_REGS)
static void
ResizeMmappedArray(StaticArrayEntry *pp, Int dim, void *area USES_REGS)
{
mmap_array_block *ptr = mmap_arrays;
mmap_array_block *ptr = GLOBAL_mmap_arrays;
size_t total_size;
while (ptr != NULL && ptr->start != area) {
ptr = ptr->next;
@ -240,16 +239,16 @@ GetTermFromArray(DBTerm *ref USES_REGS)
Term TRef;
while ((TRef = Yap_FetchTermFromDB(ref)) == 0L) {
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return TermNil;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, 3, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return TermNil;
}
}
@ -573,8 +572,8 @@ CreateNamedArray(PropEntry * pp, Int dim, AtomEntry *ae USES_REGS)
#if THREADS
p->owner_id = worker_id;
#endif
p->NextAE = DynamicArrays;
DynamicArrays = p;
p->NextAE = LOCAL_DynamicArrays;
LOCAL_DynamicArrays = p;
InitNamedArray(p, dim PASS_REGS);
}
@ -611,7 +610,7 @@ AllocateStaticArraySpace(StaticArrayEntry *p, static_array_types atype, Int arra
while ((p->ValueOfVE.floats = (Float *) Yap_AllocAtomSpace(asize) ) == NULL) {
YAPLeaveCriticalSection();
if (!Yap_growheap(FALSE, asize, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return;
}
YAPEnterCriticalSection();
@ -625,15 +624,15 @@ CreateStaticArray(AtomEntry *ae, Int dim, static_array_types type, CODEADDR star
if (EndOfPAEntr(p)) {
while ((p = (StaticArrayEntry *) Yap_AllocAtomSpace(sizeof(*p))) == NULL) {
if (!Yap_growheap(FALSE, sizeof(*p), NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return NULL;
}
}
p->KindOfPE = ArrayProperty;
p->NextOfPE = ae->PropsOfAE;
INIT_RWLOCK(p->ArRWLock);
p->NextAE = StaticArrays;
StaticArrays = p;
p->NextAE = LOCAL_StaticArrays;
LOCAL_StaticArrays = p;
}
WRITE_LOCK(p->ArRWLock);
p->ArrayEArity = -dim;
@ -900,12 +899,12 @@ p_create_array( USES_REGS1 )
farray = Yap_MkFunctor(AtomArray, size);
if (H+1+size > ASP-1024) {
if (!Yap_gcl((1+size)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR,TermNil,LOCAL_ErrorMessage);
return(FALSE);
} else {
if (H+1+size > ASP-1024) {
if (!Yap_growstack( sizeof(CELL) * (size+1-(H-ASP-1024)))) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -938,7 +937,7 @@ p_create_array( USES_REGS1 )
if (H+1+size > ASP-1024) {
WRITE_UNLOCK(ae->ARWLock);
if (!Yap_gcl((1+size)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR,TermNil,LOCAL_ErrorMessage);
return(FALSE);
} else
goto restart;
@ -960,7 +959,7 @@ p_create_array( USES_REGS1 )
} else {
if (H+1+size > ASP-1024) {
if (!Yap_gcl((1+size)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR,TermNil,LOCAL_ErrorMessage);
return(FALSE);
} else
goto restart;
@ -1383,8 +1382,8 @@ p_create_mmapped_array( USES_REGS1 )
ptr->items = size;
ptr->start = (void *)array_addr;
ptr->fd = fd;
ptr->next = mmap_arrays;
mmap_arrays = ptr;
ptr->next = GLOBAL_mmap_arrays;
GLOBAL_mmap_arrays = ptr;
WRITE_UNLOCK(pp->ArRWLock);
WRITE_UNLOCK(ae->ARWLock);
return TRUE;
@ -2244,7 +2243,7 @@ static Int
p_sync_mmapped_arrays( USES_REGS1 )
{
#ifdef HAVE_MMAP
mmap_array_block *ptr = mmap_arrays;
mmap_array_block *ptr = GLOBAL_mmap_arrays;
while (ptr != NULL) {
msync(ptr->start, ptr->size, MS_SYNC);
ptr = ptr->next;
@ -2279,12 +2278,12 @@ p_static_array_to_term( USES_REGS1 )
while (H+1+dim > ASP-1024) {
if (!Yap_gcl((1+dim)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR,TermNil,LOCAL_ErrorMessage);
return(FALSE);
} else {
if (H+1+dim > ASP-1024) {
if (!Yap_growstack( sizeof(CELL) * (dim+1-(H-ASP-1024)))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}

View File

@ -41,10 +41,10 @@ AddToQueue(attvar_record *attv USES_REGS)
t[0] = (CELL)&(attv->Done);
t[1] = attv->Value;
/* follow the chain */
WGs = Yap_ReadTimedVar(WokenGoals);
WGs = Yap_ReadTimedVar(LOCAL_WokenGoals);
ng = Yap_MkApplTerm(FunctorAttGoal, 2, t);
Yap_UpdateTimedVar(WokenGoals, MkPairTerm(ng, WGs));
Yap_UpdateTimedVar(LOCAL_WokenGoals, MkPairTerm(ng, WGs));
if ((Term)WGs == TermNil) {
/* from now on, we have to start waking up goals */
Yap_signal(YAP_WAKEUP_SIGNAL);
@ -58,9 +58,9 @@ AddFailToQueue( USES_REGS1 )
Term WGs;
/* follow the chain */
WGs = Yap_ReadTimedVar(WokenGoals);
WGs = Yap_ReadTimedVar(LOCAL_WokenGoals);
Yap_UpdateTimedVar(WokenGoals, MkPairTerm(MkAtomTerm(AtomFail), WGs));
Yap_UpdateTimedVar(LOCAL_WokenGoals, MkPairTerm(MkAtomTerm(AtomFail), WGs));
if ((Term)WGs == TermNil) {
/* from now on, we have to start waking up goals */
Yap_signal(YAP_WAKEUP_SIGNAL);
@ -205,7 +205,7 @@ BuildAttTerm(Functor mfun, UInt ar USES_REGS)
UInt i;
if (H+(1024+ar) > ASP) {
Yap_Error_Size=ar*sizeof(CELL);
LOCAL_Error_Size=ar*sizeof(CELL);
return 0L;
}
H[0] = (CELL)mfun;
@ -433,9 +433,9 @@ p_put_att( USES_REGS1 ) {
attv = RepAttVar(VarOfTerm(inp));
} else {
while (!(attv = BuildNewAttVar( PASS_REGS1 ))) {
Yap_Error_Size = sizeof(attvar_record);
if (!Yap_gcl(Yap_Error_Size, 5, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_Size = sizeof(attvar_record);
if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
inp = Deref(ARG1);
@ -445,8 +445,8 @@ p_put_att( USES_REGS1 ) {
mfun= Yap_MkFunctor(modname,ar);
if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts,mfun))) {
while (!(tatts = BuildAttTerm(mfun,ar PASS_REGS))) {
if (!Yap_gcl(Yap_Error_Size, 5, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -474,9 +474,9 @@ p_put_att_term( USES_REGS1 ) {
MaBind(&(attv->Atts), Deref(ARG2));
} else {
while (!(attv = BuildNewAttVar( PASS_REGS1 ))) {
Yap_Error_Size = sizeof(attvar_record);
if (!Yap_gcl(Yap_Error_Size, 5, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_Size = sizeof(attvar_record);
if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
inp = Deref(ARG1);
@ -508,9 +508,9 @@ p_rm_att( USES_REGS1 ) {
attv = RepAttVar(VarOfTerm(inp));
} else {
while (!(attv = BuildNewAttVar( PASS_REGS1 ))) {
Yap_Error_Size = sizeof(attvar_record);
if (!Yap_gcl(Yap_Error_Size, 5, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_Size = sizeof(attvar_record);
if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
inp = Deref(ARG1);
@ -521,8 +521,8 @@ p_rm_att( USES_REGS1 ) {
mfun= Yap_MkFunctor(modname,ar);
if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts,mfun))) {
while (!(tatts = BuildAttTerm(mfun, ar PASS_REGS))) {
if (!Yap_gcl(Yap_Error_Size, 4, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
if (!Yap_gcl(LOCAL_Error_Size, 4, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -555,9 +555,9 @@ p_put_atts( USES_REGS1 ) {
attv = RepAttVar(VarOfTerm(inp));
} else {
while (!(attv = BuildNewAttVar( PASS_REGS1 ))) {
Yap_Error_Size = sizeof(attvar_record);
if (!Yap_gcl(Yap_Error_Size, 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_Size = sizeof(attvar_record);
if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
tatts = Deref(ARG2);
@ -902,7 +902,7 @@ AllAttVars( USES_REGS1 ) {
case (CELL)FunctorAttVar:
if (IsUnboundVar(pt+1)) {
if (ASP - myH < 1024) {
Yap_Error_Size = (ASP-H)*sizeof(CELL);
LOCAL_Error_Size = (ASP-H)*sizeof(CELL);
return 0L;
}
if (myH != H) {
@ -952,8 +952,8 @@ p_all_attvars( USES_REGS1 )
Term out;
if (!(out = AllAttVars( PASS_REGS1 ))) {
if (!Yap_gcl(Yap_Error_Size, 1, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
} else {
@ -1044,11 +1044,11 @@ void Yap_InitAttVarPreds(void)
Term OldCurrentModule = CurrentModule;
CurrentModule = ATTRIBUTES_MODULE;
#ifdef COROUTINING
attas[attvars_ext].bind_op = WakeAttVar;
attas[attvars_ext].copy_term_op = CopyAttVar;
attas[attvars_ext].to_term_op = AttVarToTerm;
attas[attvars_ext].term_to_op = TermToAttVar;
attas[attvars_ext].mark_op = mark_attvar;
GLOBAL_attas[attvars_ext].bind_op = WakeAttVar;
GLOBAL_attas[attvars_ext].copy_term_op = CopyAttVar;
GLOBAL_attas[attvars_ext].to_term_op = AttVarToTerm;
GLOBAL_attas[attvars_ext].term_to_op = TermToAttVar;
GLOBAL_attas[attvars_ext].mark_op = mark_attvar;
Yap_InitCPred("get_att", 4, p_get_att, SafePredFlag);
Yap_InitCPred("get_module_atts", 2, p_get_atts, SafePredFlag);
Yap_InitCPred("has_module_atts", 2, p_has_atts, SafePredFlag);

View File

@ -233,7 +233,7 @@ p_rational( USES_REGS1 )
(mpq_numref(rat)->_mp_alloc)*(sizeof(mp_limb_t)/CellSize) +
(mpq_denref(rat)->_mp_alloc)*(sizeof(mp_limb_t)/CellSize);
if (!Yap_gcl(size, 3, ENV, P)) {
Yap_Error(OUT_OF_STACK_ERROR, t, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, t, LOCAL_ErrorMessage);
return FALSE;
}
}

View File

@ -334,6 +334,7 @@
#include "clause.h"
#include "yapio.h"
#include "attvar.h"
#include "SWI-Stream.h"
#if HAVE_STDARG_H
#include <stdarg.h>
#endif
@ -458,6 +459,7 @@ X_API int STD_PROTO(YAP_GoalHasException,(Term *));
X_API void STD_PROTO(YAP_ClearExceptions,(void));
X_API int STD_PROTO(YAP_ContinueGoal,(void));
X_API void STD_PROTO(YAP_PruneGoal,(void));
X_API IOSTREAM *STD_PROTO(YAP_TermToStream,(Term));
X_API IOSTREAM *STD_PROTO(YAP_InitConsult,(int, char *));
X_API void STD_PROTO(YAP_EndConsult,(IOSTREAM *));
X_API Term STD_PROTO(YAP_Read, (IOSTREAM *));
@ -761,7 +763,7 @@ YAP_MkBlobTerm(unsigned int sz)
while (H+(sz+sizeof(MP_INT)/sizeof(CELL)+2) > ASP-1024) {
if (!doexpand((sz+sizeof(MP_INT)/sizeof(CELL)+2)*sizeof(CELL))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "YAP failed to grow the stack while constructing a blob: %s", Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "YAP failed to grow the stack while constructing a blob: %s", LOCAL_ErrorMessage);
return TermNil;
}
}
@ -855,9 +857,9 @@ YAP_LookupAtom(char *c)
while (TRUE) {
a = Yap_LookupAtom(c);
if (a == NIL || (ActiveSignals & YAP_CDOVF_SIGNAL)) {
if (a == NIL || (LOCAL_ActiveSignals & YAP_CDOVF_SIGNAL)) {
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage);
}
} else {
return a;
@ -873,9 +875,9 @@ YAP_LookupWideAtom(wchar_t *c)
while (TRUE) {
a = Yap_LookupWideAtom(c);
if (a == NIL || (ActiveSignals & YAP_CDOVF_SIGNAL)) {
if (a == NIL || (LOCAL_ActiveSignals & YAP_CDOVF_SIGNAL)) {
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage);
}
} else {
return a;
@ -891,9 +893,9 @@ YAP_FullLookupAtom(char *c)
while (TRUE) {
at = Yap_FullLookupAtom(c);
if (at == NIL || (ActiveSignals & YAP_CDOVF_SIGNAL)) {
if (at == NIL || (LOCAL_ActiveSignals & YAP_CDOVF_SIGNAL)) {
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage);
}
} else {
return at;
@ -1563,7 +1565,7 @@ YAP_Execute(PredEntry *pe, CPredicate exec_code)
if (!ret) {
Term t;
BallTerm = EX;
LOCAL_BallTerm = EX;
EX = NULL;
if ((t = Yap_GetException())) {
Yap_JumpToEnv(t);
@ -1586,7 +1588,7 @@ YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code)
Int val;
CPredicateV codev = (CPredicateV)exec_code;
struct foreign_context *ctx = (struct foreign_context *)(&EXTRA_CBACK_ARG(pe->ArityOfPE,1));
struct open_query_struct *oexec = execution;
struct open_query_struct *oexec = LOCAL_execution;
extern void PL_close_foreign_frame(struct open_query_struct *);
PP = pe;
@ -1599,13 +1601,13 @@ YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code)
val = ((codev)(B->cp_args-LCL0,0,ctx));
}
/* make sure we clean up the frames left by the user */
while (execution != oexec)
PL_close_foreign_frame(execution);
while (LOCAL_execution != oexec)
PL_close_foreign_frame(LOCAL_execution);
PP = NULL;
if (val == 0) {
Term t;
BallTerm = EX;
LOCAL_BallTerm = EX;
EX = NULL;
if ((t = Yap_GetException())) {
cut_c_pop();
@ -1628,7 +1630,7 @@ YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code)
if (!ret) {
Term t;
BallTerm = EX;
LOCAL_BallTerm = EX;
EX = NULL;
if ((t = Yap_GetException())) {
Yap_JumpToEnv(t);
@ -1651,7 +1653,7 @@ YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code, struct cut_c_str *top)
Int val;
CPredicateV codev = (CPredicateV)exec_code;
struct foreign_context *ctx = (struct foreign_context *)(&EXTRA_CBACK_ARG(pe->ArityOfPE,1));
struct open_query_struct *oexec = execution;
struct open_query_struct *oexec = LOCAL_execution;
extern void PL_close_foreign_frame(struct open_query_struct *);
CELL *args = B->cp_args;
@ -1667,15 +1669,15 @@ YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code, struct cut_c_str *top)
val = ((codev)(args-LCL0,0,ctx));
}
/* make sure we clean up the frames left by the user */
while (execution != oexec)
PL_close_foreign_frame(execution);
while (LOCAL_execution != oexec)
PL_close_foreign_frame(LOCAL_execution);
PP = NULL;
// B = LCL0-(CELL*)oB;
if (val == 0) {
Term t;
BallTerm = EX;
LOCAL_BallTerm = EX;
EX = NULL;
if ((t = Yap_GetException())) {
cut_c_pop();
@ -1693,7 +1695,7 @@ YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code, struct cut_c_str *top)
if (!ret) {
Term t;
BallTerm = EX;
LOCAL_BallTerm = EX;
EX = NULL;
if ((t = Yap_GetException())) {
Yap_JumpToEnv(t);
@ -1713,7 +1715,7 @@ YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code)
Int val;
CPredicateV codev = (CPredicateV)exec_code;
struct foreign_context *ctx = (struct foreign_context *)(&EXTRA_CBACK_ARG(pe->ArityOfPE,1));
struct open_query_struct *oexec = execution;
struct open_query_struct *oexec = LOCAL_execution;
extern void PL_close_foreign_frame(struct open_query_struct *);
PP = pe;
@ -1724,13 +1726,13 @@ YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code)
val = ((codev)(B->cp_args-LCL0,0,ctx));
}
/* make sure we clean up the frames left by the user */
while (execution != oexec)
PL_close_foreign_frame(execution);
while (LOCAL_execution != oexec)
PL_close_foreign_frame(LOCAL_execution);
PP = NULL;
if (val == 0) {
Term t;
BallTerm = EX;
LOCAL_BallTerm = EX;
EX = NULL;
if ((t = Yap_GetException())) {
cut_c_pop();
@ -1754,7 +1756,7 @@ YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code)
if (!ret) {
Term t;
BallTerm = EX;
LOCAL_BallTerm = EX;
EX = NULL;
if ((t = Yap_GetException())) {
Yap_JumpToEnv(t);
@ -1794,7 +1796,7 @@ YAP_ReallocSpaceFromYap(void *ptr,unsigned int size) {
BACKUP_MACHINE_REGS();
while ((new_ptr = Yap_ReallocCodeSpace(ptr,size)) == NULL) {
if (!Yap_growheap(FALSE, size, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return NULL;
}
}
@ -1810,7 +1812,7 @@ YAP_AllocSpaceFromYap(unsigned int size)
while ((ptr = Yap_AllocCodeSpace(size)) == NULL) {
if (!Yap_growheap(FALSE, size, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return NULL;
}
}
@ -1927,35 +1929,35 @@ YAP_ReadBuffer(char *s, Term *tp)
BACKUP_H();
while ((t = Yap_StringToTerm(s,tp)) == 0L) {
if (Yap_ErrorMessage) {
if (!strcmp(Yap_ErrorMessage,"Stack Overflow")) {
if (LOCAL_ErrorMessage) {
if (!strcmp(LOCAL_ErrorMessage,"Stack Overflow")) {
if (!dogc()) {
*tp = MkAtomTerm(Yap_LookupAtom(Yap_ErrorMessage));
Yap_ErrorMessage = NULL;
*tp = MkAtomTerm(Yap_LookupAtom(LOCAL_ErrorMessage));
LOCAL_ErrorMessage = NULL;
RECOVER_H();
return 0L;
}
} else if (!strcmp(Yap_ErrorMessage,"Heap Overflow")) {
} else if (!strcmp(LOCAL_ErrorMessage,"Heap Overflow")) {
if (!Yap_growheap(FALSE, 0, NULL)) {
*tp = MkAtomTerm(Yap_LookupAtom(Yap_ErrorMessage));
Yap_ErrorMessage = NULL;
*tp = MkAtomTerm(Yap_LookupAtom(LOCAL_ErrorMessage));
LOCAL_ErrorMessage = NULL;
RECOVER_H();
return 0L;
}
} else if (!strcmp(Yap_ErrorMessage,"Trail Overflow")) {
} else if (!strcmp(LOCAL_ErrorMessage,"Trail Overflow")) {
if (!Yap_growtrail (0, FALSE)) {
*tp = MkAtomTerm(Yap_LookupAtom(Yap_ErrorMessage));
Yap_ErrorMessage = NULL;
*tp = MkAtomTerm(Yap_LookupAtom(LOCAL_ErrorMessage));
LOCAL_ErrorMessage = NULL;
RECOVER_H();
return 0L;
}
} else {
*tp = MkAtomTerm(Yap_LookupAtom(Yap_ErrorMessage));
Yap_ErrorMessage = NULL;
*tp = MkAtomTerm(Yap_LookupAtom(LOCAL_ErrorMessage));
LOCAL_ErrorMessage = NULL;
RECOVER_H();
return 0L;
}
Yap_ErrorMessage = NULL;
LOCAL_ErrorMessage = NULL;
continue;
} else {
break;
@ -2138,9 +2140,9 @@ run_emulator(YAP_dogoalinfo *dgi)
int out;
BACKUP_MACHINE_REGS();
Yap_PrologMode = UserMode;
LOCAL_PrologMode = UserMode;
out = Yap_absmi(0);
Yap_PrologMode = UserCCallMode;
LOCAL_PrologMode = UserCCallMode;
myB = (choiceptr)(LCL0-dgi->b);
CP = myB->cp_cp;
if (!out ) {
@ -2196,9 +2198,6 @@ YAP_EnterGoal(PredEntry *pe, Term *ptr, YAP_dogoalinfo *dgi)
CP = YESCODE;
B = myB;
HB = H;
#if defined(YAPOR) || defined(THREADS)
WPP = NULL;
#endif
ASP = YENV = (CELL *)B;
YENV[E_CB] = Unsigned (B);
out = run_emulator(dgi);
@ -2276,19 +2275,19 @@ YAP_RunGoal(Term t)
yamop *old_CP = CP;
BACKUP_MACHINE_REGS();
Yap_AllowRestart = FALSE;
Yap_PrologMode = UserMode;
LOCAL_AllowRestart = FALSE;
LOCAL_PrologMode = UserMode;
out = Yap_RunTopGoal(t);
Yap_PrologMode = UserCCallMode;
LOCAL_PrologMode = UserCCallMode;
if (out) {
P = (yamop *)ENV[E_CP];
ENV = (CELL *)ENV[E_E];
CP = old_CP;
Yap_AllowRestart = TRUE;
LOCAL_AllowRestart = TRUE;
} else {
ENV = B->cp_env;
B = B->cp_b;
Yap_AllowRestart = FALSE;
LOCAL_AllowRestart = FALSE;
}
RECOVER_MACHINE_REGS();
@ -2303,9 +2302,9 @@ YAP_RunGoalOnce(Term t)
yamop *old_CP = CP;
BACKUP_MACHINE_REGS();
Yap_PrologMode = UserMode;
LOCAL_PrologMode = UserMode;
out = Yap_RunTopGoal(t);
Yap_PrologMode = UserCCallMode;
LOCAL_PrologMode = UserCCallMode;
if (out) {
choiceptr cut_pt;
@ -2327,7 +2326,7 @@ YAP_RunGoalOnce(Term t)
#endif
P = (yamop *)ASP[E_CP];
CP = old_CP;
Yap_AllowRestart = FALSE;
LOCAL_AllowRestart = FALSE;
RECOVER_MACHINE_REGS();
return(out);
}
@ -2338,17 +2337,17 @@ YAP_RestartGoal(void)
CACHE_REGS
int out;
BACKUP_MACHINE_REGS();
if (Yap_AllowRestart) {
if (LOCAL_AllowRestart) {
P = (yamop *)FAILCODE;
do_putcf = myputc;
Yap_PrologMode = UserMode;
LOCAL_PrologMode = UserMode;
out = Yap_exec_absmi(TRUE);
Yap_PrologMode = UserCCallMode;
LOCAL_PrologMode = UserCCallMode;
if (out == FALSE) {
/* cleanup */
Yap_CloseSlots( PASS_REGS1 );
Yap_trust_last();
Yap_AllowRestart = FALSE;
LOCAL_AllowRestart = FALSE;
}
} else {
out = FALSE;
@ -2363,7 +2362,7 @@ YAP_ShutdownGoal(int backtrack)
CACHE_REGS
BACKUP_MACHINE_REGS();
if (Yap_AllowRestart) {
if (LOCAL_AllowRestart) {
choiceptr cut_pt;
cut_pt = B;
@ -2390,7 +2389,7 @@ YAP_ShutdownGoal(int backtrack)
#ifdef DEPTH_LIMIT
DEPTH = ASP[E_DEPTH];
#endif
Yap_AllowRestart = FALSE;
LOCAL_AllowRestart = FALSE;
}
RECOVER_MACHINE_REGS();
return TRUE;
@ -2399,12 +2398,13 @@ YAP_ShutdownGoal(int backtrack)
X_API int
YAP_ContinueGoal(void)
{
CACHE_REGS
int out;
BACKUP_MACHINE_REGS();
Yap_PrologMode = UserMode;
LOCAL_PrologMode = UserMode;
out = Yap_exec_absmi(TRUE);
Yap_PrologMode = UserCCallMode;
LOCAL_PrologMode = UserCCallMode;
RECOVER_MACHINE_REGS();
return(out);
@ -2435,22 +2435,22 @@ YAP_GoalHasException(Term *t)
BACKUP_MACHINE_REGS();
if (EX) {
do {
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
*t = Yap_FetchTermFromDB(EX);
if (Yap_Error_TYPE == YAP_NO_ERROR) {
if (LOCAL_Error_TYPE == YAP_NO_ERROR) {
RECOVER_MACHINE_REGS();
return TRUE;
} else if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
} else if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
RECOVER_MACHINE_REGS();
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growstack(EX->NOfCells*CellSize)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
RECOVER_MACHINE_REGS();
return FALSE;
}
@ -2468,11 +2468,11 @@ YAP_ClearExceptions(void)
CACHE_REGS
Yap_ResetExceptionTerm();
if (EX) {
BallTerm = EX;
LOCAL_BallTerm = EX;
}
EX = NULL;
Yap_ResetExceptionTerm();
UncaughtThrow = FALSE;
LOCAL_UncaughtThrow = FALSE;
}
X_API IOSTREAM *
@ -2490,6 +2490,22 @@ YAP_InitConsult(int mode, char *filename)
return st;
}
X_API IOSTREAM *
YAP_TermToStream(Term t)
{
CACHE_REGS
IOSTREAM *s;
int rc;
BACKUP_MACHINE_REGS();
if ( (rc=PL_get_stream_handle(Yap_InitSlot(t PASS_REGS), &s)) ) {
RECOVER_MACHINE_REGS();
return s;
}
RECOVER_MACHINE_REGS();
return NULL;
}
X_API void
YAP_EndConsult(IOSTREAM *s)
{
@ -2511,20 +2527,20 @@ YAP_Read(IOSTREAM *inp)
BACKUP_MACHINE_REGS();
tokstart = Yap_tokptr = Yap_toktide = Yap_tokenizer(inp, &tpos);
if (Yap_ErrorMessage)
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(inp, &tpos);
if (LOCAL_ErrorMessage)
{
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
RECOVER_MACHINE_REGS();
return 0;
}
if (inp->flags & (SIO_FEOF|SIO_FEOF2)) {
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
RECOVER_MACHINE_REGS();
return MkAtomTerm (AtomEof);
}
t = Yap_Parse();
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
RECOVER_MACHINE_REGS();
return t;
@ -2575,7 +2591,7 @@ YAP_CompileClause(Term t)
BACKUP_MACHINE_REGS();
/* allow expansion during stack initialization */
Yap_ErrorMessage = NULL;
LOCAL_ErrorMessage = NULL;
ARG1 = t;
YAPEnterCriticalSection();
codeaddr = Yap_cclause (t,0, mod, t);
@ -2583,18 +2599,18 @@ YAP_CompileClause(Term t)
t = Deref(ARG1); /* just in case there was an heap overflow */
if (!Yap_addclause (t, codeaddr, TRUE, mod, &tn)) {
YAPLeaveCriticalSection();
return Yap_ErrorMessage;
return LOCAL_ErrorMessage;
}
}
YAPLeaveCriticalSection();
if (ActiveSignals & YAP_CDOVF_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_CDOVF_SIGNAL) {
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage);
}
}
RECOVER_MACHINE_REGS();
return(Yap_ErrorMessage);
return(LOCAL_ErrorMessage);
}
static int eof_found = FALSE;
@ -2711,8 +2727,14 @@ YAP_Init(YAP_init_args *yap_init)
CELL Trail = 0, Stack = 0, Heap = 0, Atts = 0;
static char boot_file[256];
Yap_argv = yap_init->Argv;
Yap_argc = yap_init->Argc;
Yap_InitPageSize(); /* init memory page size, required by later functions */
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
Yap_init_yapor_global_local_memory();
LOCAL = REMOTE(0);
#endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA */
Yap_InitSysbits(); /* init signal handling and time, required by later functions */
GLOBAL_argv = yap_init->Argv;
GLOBAL_argc = yap_init->Argc;
#if !BOOT_FROM_SAVED_STATE
if (yap_init->SavedState) {
fprintf(stderr,"[ WARNING: threaded YAP will ignore saved state %s ]\n",yap_init->SavedState);
@ -2721,8 +2743,8 @@ YAP_Init(YAP_init_args *yap_init)
#endif
if (BOOT_FROM_SAVED_STATE && !do_bootstrap) {
if (Yap_SavedInfo (yap_init->SavedState, yap_init->YapLibDir, &Trail, &Stack, &Heap) != 1) {
yap_init->ErrorNo = Yap_Error_TYPE;
yap_init->ErrorCause = Yap_ErrorMessage;
yap_init->ErrorNo = LOCAL_Error_TYPE;
yap_init->ErrorCause = LOCAL_ErrorMessage;
return YAP_BOOT_ERROR;
}
}
@ -2757,7 +2779,7 @@ YAP_Init(YAP_init_args *yap_init)
} else {
Heap = yap_init->HeapSize;
}
Yap_PrologShouldHandleInterrupts = yap_init->PrologShouldHandleInterrupts;
GLOBAL_PrologShouldHandleInterrupts = yap_init->PrologShouldHandleInterrupts;
Yap_InitWorkspace(Heap, Stack, Trail, Atts,
yap_init->MaxTableSpaceSize,
yap_init->NumberWorkers,
@ -2773,20 +2795,20 @@ YAP_Init(YAP_init_args *yap_init)
Trail = MinTrailSpace;
if (Stack < MinStackSpace)
Stack = MinStackSpace;
if (!(Yap_GlobalBase = (ADDR)malloc((Trail+Stack)*1024))) {
if (!(LOCAL_GlobalBase = (ADDR)malloc((Trail+Stack)*1024))) {
yap_init->ErrorNo = RESOURCE_ERROR_MEMORY;
yap_init->ErrorCause = "could not allocate stack space for main thread";
return YAP_BOOT_ERROR;
}
#if THREADS
/* don't forget this is a thread */
MY_ThreadHandle.stack_address = Yap_GlobalBase;
MY_ThreadHandle.ssize = Trail+Stack;
LOCAL_ThreadHandle.stack_address = LOCAL_GlobalBase;
LOCAL_ThreadHandle.ssize = Trail+Stack;
#endif
#endif
Yap_AllowGlobalExpansion = TRUE;
Yap_AllowLocalExpansion = TRUE;
Yap_AllowTrailExpansion = TRUE;
GLOBAL_AllowGlobalExpansion = TRUE;
GLOBAL_AllowLocalExpansion = TRUE;
GLOBAL_AllowTrailExpansion = TRUE;
Yap_InitExStacks (Trail, Stack);
if (yap_init->QuietMode) {
yap_flags[QUIET_MODE_FLAG] = TRUE;
@ -2816,8 +2838,8 @@ YAP_Init(YAP_init_args *yap_init)
} else if (BOOT_FROM_SAVED_STATE) {
restore_result = Yap_Restore(yap_init->SavedState, yap_init->YapLibDir);
if (restore_result == FAIL_RESTORE) {
yap_init->ErrorNo = Yap_Error_TYPE;
yap_init->ErrorCause = Yap_ErrorMessage;
yap_init->ErrorNo = LOCAL_Error_TYPE;
yap_init->ErrorCause = LOCAL_ErrorMessage;
/* shouldn't RECOVER_MACHINE_REGS(); be here ??? */
return YAP_BOOT_ERROR;
}
@ -2826,27 +2848,21 @@ YAP_Init(YAP_init_args *yap_init)
}
yap_flags[FAST_BOOT_FLAG] = yap_init->FastBoot;
#if defined(YAPOR) || defined(TABLING)
#ifdef TABLING
/* make sure we initialise this field */
Yap_root_dep_fr = NULL;
#endif
make_root_frames();
#ifdef YAPOR
init_workers();
#endif /* YAPOR */
Yap_init_local();
Yap_init_root_frames();
#endif /* YAPOR || TABLING */
#ifdef YAPOR
Yap_init_yapor_workers();
if (worker_id != 0) {
#if YAPOR_SBA||YAPOR_COPY
#if defined(YAPOR_COPY) || defined(YAPOR_SBA)
/*
In the SBA we cannot just happily inherit registers
from the other workers
*/
Yap_InitYaamRegs();
#endif /* YAPOR_SBA */
#ifndef THREADS
#endif /* YAPOR_COPY || YAPOR_SBA */
#ifndef YAPOR_THREADS
Yap_InitPreAllocCodeSpace();
#endif
#endif /* YAPOR_THREADS */
/* slaves, waiting for work */
CurrentModule = USER_MODULE;
P = GETWORK_FIRST_TIME;
@ -2854,24 +2870,23 @@ YAP_Init(YAP_init_args *yap_init)
Yap_Error(INTERNAL_ERROR, TermNil, "abstract machine unexpected exit (YAP_Init)");
}
#endif /* YAPOR */
#endif /* YAPOR || TABLING */
RECOVER_MACHINE_REGS();
}
/* make sure we do this after restore */
if (yap_init->MaxStackSize) {
Yap_AllowLocalExpansion = FALSE;
GLOBAL_AllowLocalExpansion = FALSE;
} else {
Yap_AllowLocalExpansion = TRUE;
GLOBAL_AllowLocalExpansion = TRUE;
}
if (yap_init->MaxGlobalSize) {
Yap_AllowGlobalExpansion = FALSE;
GLOBAL_AllowGlobalExpansion = FALSE;
} else {
Yap_AllowGlobalExpansion = TRUE;
GLOBAL_AllowGlobalExpansion = TRUE;
}
if (yap_init->MaxTrailSize) {
Yap_AllowTrailExpansion = FALSE;
GLOBAL_AllowTrailExpansion = FALSE;
} else {
Yap_AllowTrailExpansion = TRUE;
GLOBAL_AllowTrailExpansion = TRUE;
}
if (yap_init->YapPrologRCFile) {
Yap_PutValue(AtomConsultOnBoot, MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologRCFile)));
@ -2910,8 +2925,8 @@ YAP_Init(YAP_init_args *yap_init)
}
if (BOOT_FROM_SAVED_STATE && !do_bootstrap) {
if (restore_result == FAIL_RESTORE) {
yap_init->ErrorNo = Yap_Error_TYPE;
yap_init->ErrorCause = Yap_ErrorMessage;
yap_init->ErrorNo = LOCAL_Error_TYPE;
yap_init->ErrorCause = LOCAL_ErrorMessage;
return YAP_BOOT_ERROR;
}
if (Atts && Atts*1024 > 2048*sizeof(CELL))
@ -3039,7 +3054,7 @@ YAP_Reset(void)
}
/* reinitialise the engine */
Yap_InitYaamRegs();
Yap_Initialised = TRUE;
GLOBAL_Initialised = TRUE;
RECOVER_MACHINE_REGS();
return(TRUE);
@ -3060,7 +3075,7 @@ X_API void
YAP_SetOutputMessage(void)
{
#if DEBUG
Yap_output_msg = TRUE;
GLOBAL_output_msg = TRUE;
#endif
}
@ -3100,11 +3115,12 @@ YAP_Throw(Term t)
X_API void
YAP_AsyncThrow(Term t)
{
{
CACHE_REGS
BACKUP_MACHINE_REGS();
Yap_PrologMode |= AsyncIntMode;
LOCAL_PrologMode |= AsyncIntMode;
Yap_JumpToEnv(t);
Yap_PrologMode &= ~AsyncIntMode;
LOCAL_PrologMode &= ~AsyncIntMode;
RECOVER_MACHINE_REGS();
}
@ -3300,8 +3316,8 @@ YAP_AtomReleaseHold(Atom at)
X_API Agc_hook
YAP_AGCRegisterHook(Agc_hook hook)
{
Agc_hook old = Yap_AGCHook;
Yap_AGCHook = hook;
Agc_hook old = GLOBAL_AGCHook;
GLOBAL_AGCHook = hook;
return old;
}
@ -3317,13 +3333,13 @@ YAP_cwd(void)
CACHE_REGS
char *buf;
int len;
if (!Yap_getcwd(Yap_FileNameBuf, YAP_FILENAME_MAX))
if (!Yap_getcwd(LOCAL_FileNameBuf, YAP_FILENAME_MAX))
return FALSE;
len = strlen(Yap_FileNameBuf);
len = strlen(LOCAL_FileNameBuf);
buf = Yap_AllocCodeSpace(len+1);
if (!buf)
return NULL;
strncpy(buf, Yap_FileNameBuf, len);
strncpy(buf, LOCAL_FileNameBuf, len);
return buf;
}
@ -3455,22 +3471,22 @@ YAP_Recorded(void *handle)
BACKUP_MACHINE_REGS();
do {
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
t = Yap_FetchTermFromDB(dbterm);
if (Yap_Error_TYPE == YAP_NO_ERROR) {
if (LOCAL_Error_TYPE == YAP_NO_ERROR) {
RECOVER_MACHINE_REGS();
return t;
} else if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
} else if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
RECOVER_MACHINE_REGS();
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growstack(dbterm->NOfCells*CellSize)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
RECOVER_MACHINE_REGS();
return FALSE;
}
@ -3537,9 +3553,9 @@ YAP_SetYAPFlag(yap_flag_t flag, int val)
return TRUE;
case YAPC_ENABLE_AGC:
if (val) {
Yap_AGcThreshold = 10000;
GLOBAL_AGcThreshold = 10000;
} else {
Yap_AGcThreshold = 0;
GLOBAL_AGcThreshold = 0;
}
return TRUE;
default:

286
C/cdmgr.c
View File

@ -483,9 +483,6 @@ STATIC_PROTO(void assertz_dynam_clause, (PredEntry *, yamop *));
STATIC_PROTO(void expand_consult, ( void ));
STATIC_PROTO(int not_was_reconsulted, (PredEntry *, Term, int));
STATIC_PROTO(int RemoveIndexation, (PredEntry *));
#if EMACS
STATIC_PROTO(int last_clause_number, (PredEntry *));
#endif
STATIC_PROTO(int static_in_use, (PredEntry *, int));
#if !defined(YAPOR) && !defined(THREADS)
STATIC_PROTO(Int search_for_static_predicate_in_use, (PredEntry *, int));
@ -635,26 +632,26 @@ static void
InitConsultStack( void )
{
CACHE_REGS
ConsultLow = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj)*InitialConsultCapacity);
if (ConsultLow == NULL) {
LOCAL_ConsultLow = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj)*InitialConsultCapacity);
if (LOCAL_ConsultLow == NULL) {
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"No Heap Space in InitCodes");
return;
}
ConsultCapacity = InitialConsultCapacity;
ConsultBase = ConsultSp =
ConsultLow + ConsultCapacity;
LOCAL_ConsultCapacity = InitialConsultCapacity;
LOCAL_ConsultBase = LOCAL_ConsultSp =
LOCAL_ConsultLow + LOCAL_ConsultCapacity;
}
void
Yap_ResetConsultStack( void )
{
CACHE_REGS
Yap_FreeCodeSpace((char *)ConsultLow);
ConsultBase =
ConsultSp =
ConsultLow =
Yap_FreeCodeSpace((char *)LOCAL_ConsultLow);
LOCAL_ConsultBase =
LOCAL_ConsultSp =
LOCAL_ConsultLow =
NULL;
ConsultCapacity = InitialConsultCapacity;
LOCAL_ConsultCapacity = InitialConsultCapacity;
}
@ -780,9 +777,9 @@ static Term BlobTermInCodeAdjust(Term t)
{
CACHE_REGS
#if TAGS_FAST_OPS
return t-ClDiff;
return t-LOCAL_ClDiff;
#else
return t+ClDiff;
return t+LOCAL_ClDiff;
#endif
}
@ -863,7 +860,7 @@ Yap_BuildMegaClause(PredEntry *ap)
while (TRUE) {
memcpy((void *)ptr, (void *)cl->ClCode, sz);
if (has_blobs) {
ClDiff = (char *)(ptr)-(char *)cl->ClCode;
LOCAL_ClDiff = (char *)(ptr)-(char *)cl->ClCode;
restore_opcodes(ptr, NULL PASS_REGS);
}
ptr = (yamop *)((char *)ptr + sz);
@ -961,13 +958,13 @@ IPred(PredEntry *ap, UInt NSlots, yamop *next_pc)
#ifdef DEBUG
CACHE_REGS
if (Yap_Option['i' - 'a' + 1]) {
if (GLOBAL_Option['i' - 'a' + 1]) {
Term tmod = ap->ModuleOfPred;
if (!tmod)
tmod = TermProlog;
Yap_DebugPutc(Yap_c_error_stream,'\t');
Yap_DebugPutc(LOCAL_c_error_stream,'\t');
Yap_DebugPlWrite(tmod);
Yap_DebugPutc(Yap_c_error_stream,':');
Yap_DebugPutc(LOCAL_c_error_stream,':');
if (ap->ModuleOfPred == IDB_MODULE) {
Term t = Deref(ARG1);
if (IsAtomTerm(t)) {
@ -978,7 +975,7 @@ IPred(PredEntry *ap, UInt NSlots, yamop *next_pc)
Functor f = FunctorOfTerm(t);
Atom At = NameOfFunctor(f);
Yap_DebugPlWrite(MkAtomTerm(At));
Yap_DebugPutc(Yap_c_error_stream,'/');
Yap_DebugPutc(LOCAL_c_error_stream,'/');
Yap_DebugPlWrite(MkIntTerm(ArityOfFunctor(f)));
}
} else {
@ -989,11 +986,11 @@ IPred(PredEntry *ap, UInt NSlots, yamop *next_pc)
Functor f = ap->FunctorOfPred;
Atom At = NameOfFunctor(f);
Yap_DebugPlWrite(MkAtomTerm(At));
Yap_DebugPutc(Yap_c_error_stream,'/');
Yap_DebugPutc(LOCAL_c_error_stream,'/');
Yap_DebugPlWrite(MkIntTerm(ArityOfFunctor(f)));
}
}
Yap_DebugPutc(Yap_c_error_stream,'\n');
Yap_DebugPutc(LOCAL_c_error_stream,'\n');
}
#endif
/* Do not try to index a dynamic predicate or one whithout args */
@ -1020,8 +1017,8 @@ IPred(PredEntry *ap, UInt NSlots, yamop *next_pc)
ap->OpcodeOfPred = ap->CodeOfPred->opc;
}
#ifdef DEBUG
if (Yap_Option['i' - 'a' + 1])
Yap_DebugPutc(Yap_c_error_stream,'\n');
if (GLOBAL_Option['i' - 'a' + 1])
Yap_DebugPutc(LOCAL_c_error_stream,'\n');
#endif
}
@ -1954,30 +1951,30 @@ static void expand_consult( void )
{
CACHE_REGS
consult_obj *new_cl, *new_cs;
UInt OldConsultCapacity = ConsultCapacity;
UInt OldConsultCapacity = LOCAL_ConsultCapacity;
/* now double consult capacity */
ConsultCapacity += InitialConsultCapacity;
LOCAL_ConsultCapacity += InitialConsultCapacity;
/* I assume it always works ;-) */
while ((new_cl = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj)*ConsultCapacity)) == NULL) {
if (!Yap_growheap(FALSE, sizeof(consult_obj)*ConsultCapacity, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,Yap_ErrorMessage);
while ((new_cl = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj)*LOCAL_ConsultCapacity)) == NULL) {
if (!Yap_growheap(FALSE, sizeof(consult_obj)*LOCAL_ConsultCapacity, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,LOCAL_ErrorMessage);
return;
}
}
new_cs = new_cl + InitialConsultCapacity;
/* start copying */
memcpy((void *)new_cs, (void *)ConsultLow, OldConsultCapacity*sizeof(consult_obj));
memcpy((void *)new_cs, (void *)LOCAL_ConsultLow, OldConsultCapacity*sizeof(consult_obj));
/* copying done, release old space */
Yap_FreeCodeSpace((char *)ConsultLow);
Yap_FreeCodeSpace((char *)LOCAL_ConsultLow);
/* next, set up pointers correctly */
new_cs += (ConsultSp-ConsultLow);
/* put ConsultBase at same offset as before move */
ConsultBase = ConsultBase+(new_cs-ConsultSp);
new_cs += (LOCAL_ConsultSp-LOCAL_ConsultLow);
/* put LOCAL_ConsultBase at same offset as before move */
LOCAL_ConsultBase = LOCAL_ConsultBase+(new_cs-LOCAL_ConsultSp);
/* new consult pointer */
ConsultSp = new_cs;
LOCAL_ConsultSp = new_cs;
/* new end of memory */
ConsultLow = new_cl;
LOCAL_ConsultLow = new_cl;
}
/* p was already locked */
@ -1988,28 +1985,28 @@ not_was_reconsulted(PredEntry *p, Term t, int mode)
register consult_obj *fp;
Prop p0 = AbsProp((PropEntry *)p);
if (p == LastAssertedPred)
if (p == LOCAL_LastAssertedPred)
return FALSE;
LastAssertedPred = p;
if (!ConsultSp) {
LOCAL_LastAssertedPred = p;
if (!LOCAL_ConsultSp) {
InitConsultStack();
}
if (p->cs.p_code.NOfClauses) {
for (fp = ConsultSp; fp < ConsultBase; ++fp)
for (fp = LOCAL_ConsultSp; fp < LOCAL_ConsultBase; ++fp)
if (fp->p == p0)
break;
} else {
fp = ConsultBase;
fp = LOCAL_ConsultBase;
}
if (fp != ConsultBase)
if (fp != LOCAL_ConsultBase)
return FALSE;
if (mode) {
if (ConsultSp == ConsultLow+1) {
if (LOCAL_ConsultSp == LOCAL_ConsultLow+1) {
expand_consult();
}
--ConsultSp;
ConsultSp->p = p0;
if (ConsultBase[1].mode &&
--LOCAL_ConsultSp;
LOCAL_ConsultSp->p = p0;
if (LOCAL_ConsultBase[1].mode &&
!(p->PredFlags & MultiFileFlag)) /* we are in reconsult mode */ {
retract_all(p, static_in_use(p,TRUE));
}
@ -2027,21 +2024,21 @@ addcl_permission_error(AtomEntry *ap, Int Arity, int in_use)
ti[0] = MkAtomTerm(AbsAtom(ap));
ti[1] = MkIntegerTerm(Arity);
t = Yap_MkApplTerm(FunctorSlash, 2, ti);
Yap_ErrorMessage = Yap_ErrorSay;
Yap_Error_Term = t;
Yap_Error_TYPE = PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
LOCAL_Error_Term = t;
LOCAL_Error_TYPE = PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE;
if (in_use) {
if (Arity == 0)
sprintf(Yap_ErrorMessage, "static predicate %s is in use", ap->StrOfAE);
sprintf(LOCAL_ErrorMessage, "static predicate %s is in use", ap->StrOfAE);
else
sprintf(Yap_ErrorMessage,
sprintf(LOCAL_ErrorMessage,
"static predicate %s/" Int_FORMAT " is in use",
ap->StrOfAE, Arity);
} else {
if (Arity == 0)
sprintf(Yap_ErrorMessage, "system predicate %s", ap->StrOfAE);
sprintf(LOCAL_ErrorMessage, "system predicate %s", ap->StrOfAE);
else
sprintf(Yap_ErrorMessage,
sprintf(LOCAL_ErrorMessage,
"system predicate %s/" Int_FORMAT,
ap->StrOfAE, Arity);
}
@ -2199,7 +2196,7 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
if (mode == consult)
not_was_reconsulted(p, t, TRUE);
/* always check if we have a valid error first */
if (Yap_ErrorMessage && Yap_Error_TYPE == PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE) {
if (LOCAL_ErrorMessage && LOCAL_Error_TYPE == PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE) {
UNLOCKPE(31,p);
return TermNil;
}
@ -2438,25 +2435,6 @@ Yap_add_logupd_clause(PredEntry *pe, LogUpdClause *cl, int mode) {
}
}
#if EMACS
/*
* the place where one would add a new clause for the propriety pred_prop
*/
int
where_new_clause(pred_prop, mode)
Prop pred_prop;
int mode;
{
PredEntry *p = RepPredProp(pred_prop);
if (mode == consult && not_was_reconsulted(p, TermNil, FALSE))
return (1);
else
return (p->cs.p_code.NOfClauses + 1);
}
#endif
static Int
p_compile( USES_REGS1 )
{ /* '$compile'(+C,+Flags, Mod) */
@ -2475,15 +2453,15 @@ p_compile( USES_REGS1 )
codeadr = Yap_cclause(t, 4, mod, Deref(ARG3)); /* vsc: give the number of arguments
to cclause in case there is overflow */
t = Deref(ARG1); /* just in case there was an heap overflow */
if (!Yap_ErrorMessage)
if (!LOCAL_ErrorMessage)
addclause(t, codeadr, (int) (IntOfTerm(t1) & 3), mod, &tn);
YAPLeaveCriticalSection();
if (Yap_ErrorMessage) {
if (LOCAL_ErrorMessage) {
if (IntOfTerm(t1) & 4) {
Yap_Error(Yap_Error_TYPE, Yap_Error_Term,
"in line %d, %s", Yap_FirstLineInParse(), Yap_ErrorMessage);
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term,
"in line %d, %s", Yap_FirstLineInParse(), LOCAL_ErrorMessage);
} else {
Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage);
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
}
return FALSE;
}
@ -2507,24 +2485,26 @@ p_compile_dynamic( USES_REGS1 )
if (RepAtom(AtomOfTerm(t1))->StrOfAE[0] == 'f') mode = asserta;
else mode = assertz;
} else mode = IntegerOfTerm(t1);
if (mode == assertz && consult_level)
mode = consult;
/* separate assert in current file from reconsult
if (mode == assertz && LOCAL_consult_level && mod == CurrentModule)
mode = consult;
*/
old_optimize = optimizer_on;
optimizer_on = FALSE;
YAPEnterCriticalSection();
code_adr = Yap_cclause(t, 5, mod, Deref(ARG3)); /* vsc: give the number of arguments to
cclause() in case there is a overflow */
t = Deref(ARG1); /* just in case there was an heap overflow */
if (!Yap_ErrorMessage) {
if (!LOCAL_ErrorMessage) {
optimizer_on = old_optimize;
addclause(t, code_adr, mode , mod, &ARG5);
}
if (Yap_ErrorMessage) {
if (!Yap_Error_Term)
Yap_Error_Term = TermNil;
Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage);
if (LOCAL_ErrorMessage) {
if (!LOCAL_Error_Term)
LOCAL_Error_Term = TermNil;
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
YAPLeaveCriticalSection();
return FALSE;
}
@ -2535,10 +2515,10 @@ p_compile_dynamic( USES_REGS1 )
static Atom
YapConsultingFile ( USES_REGS1 )
{
if (consult_level == 0) {
if (LOCAL_consult_level == 0) {
return(AtomUser);
} else {
return(Yap_LookupAtom(ConsultBase[2].filename));
return(Yap_LookupAtom(LOCAL_ConsultBase[2].filename));
}
}
@ -2554,22 +2534,22 @@ static void
init_consult(int mode, char *file)
{
CACHE_REGS
if (!ConsultSp) {
if (!LOCAL_ConsultSp) {
InitConsultStack();
}
ConsultSp--;
ConsultSp->filename = file;
ConsultSp--;
ConsultSp->mode = mode;
ConsultSp--;
ConsultSp->c = (ConsultBase-ConsultSp);
ConsultBase = ConsultSp;
LOCAL_ConsultSp--;
LOCAL_ConsultSp->filename = file;
LOCAL_ConsultSp--;
LOCAL_ConsultSp->mode = mode;
LOCAL_ConsultSp--;
LOCAL_ConsultSp->c = (LOCAL_ConsultBase-LOCAL_ConsultSp);
LOCAL_ConsultBase = LOCAL_ConsultSp;
#if !defined(YAPOR) && !defined(YAPOR_SBA)
/* if (consult_level == 0)
/* if (LOCAL_consult_level == 0)
do_toggle_static_predicates_in_use(TRUE); */
#endif
consult_level++;
LastAssertedPred = NULL;
LOCAL_consult_level++;
LOCAL_LastAssertedPred = NULL;
}
void
@ -2587,7 +2567,7 @@ p_startconsult( USES_REGS1 )
mode = strcmp("consult",smode);
init_consult(mode, RepAtom(AtomOfTerm(Deref(ARG2)))->StrOfAE);
t = MkIntTerm(consult_level);
t = MkIntTerm(LOCAL_consult_level);
return (Yap_unify_constant(ARG3, t));
}
@ -2596,20 +2576,20 @@ p_showconslultlev( USES_REGS1 )
{
Term t;
t = MkIntTerm(consult_level);
t = MkIntTerm(LOCAL_consult_level);
return (Yap_unify_constant(ARG1, t));
}
static void
end_consult( USES_REGS1 )
{
ConsultSp = ConsultBase;
ConsultBase = ConsultSp+ConsultSp->c;
ConsultSp += 3;
consult_level--;
LastAssertedPred = NULL;
LOCAL_ConsultSp = LOCAL_ConsultBase;
LOCAL_ConsultBase = LOCAL_ConsultSp+LOCAL_ConsultSp->c;
LOCAL_ConsultSp += 3;
LOCAL_consult_level--;
LOCAL_LastAssertedPred = NULL;
#if !defined(YAPOR) && !defined(YAPOR_SBA)
/* if (consult_level == 0)
/* if (LOCAL_consult_level == 0)
do_toggle_static_predicates_in_use(FALSE);*/
#endif
}
@ -3406,9 +3386,9 @@ all_envs(CELL *env_ptr USES_REGS)
bp[0] = MkIntegerTerm(LCL0-env_ptr);
if (H >= ASP-1024) {
H = start;
Yap_Error_Size = (ASP-1024)-H;
LOCAL_Error_Size = (ASP-1024)-H;
while (env_ptr) {
Yap_Error_Size += 2;
LOCAL_Error_Size += 2;
env_ptr = (CELL *)(env_ptr[E_E]);
}
return 0L;
@ -3435,9 +3415,9 @@ all_cps(choiceptr b_ptr USES_REGS)
bp[0] = MkIntegerTerm((Int)(LCL0-(CELL *)b_ptr));
if (H >= ASP-1024) {
H = start;
Yap_Error_Size = (ASP-1024)-H;
LOCAL_Error_Size = (ASP-1024)-H;
while (b_ptr) {
Yap_Error_Size += 2;
LOCAL_Error_Size += 2;
b_ptr = b_ptr->cp_b;
}
return 0L;
@ -3483,7 +3463,7 @@ p_all_choicepoints( USES_REGS1 )
{
Term t;
while ((t = all_cps(B PASS_REGS)) == 0L) {
if (!Yap_gcl(Yap_Error_Size, 1, ENV, gc_P(P,CP))) {
if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while dumping choicepoints");
return FALSE;
}
@ -3496,7 +3476,7 @@ p_all_envs( USES_REGS1 )
{
Term t;
while ((t = all_envs(ENV PASS_REGS)) == 0L) {
if (!Yap_gcl(Yap_Error_Size, 1, ENV, gc_P(P,CP))) {
if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while dumping environments");
return FALSE;
}
@ -3509,7 +3489,7 @@ p_current_stack( USES_REGS1 )
{
Term t;
while ((t = all_calls( PASS_REGS1 )) == 0L) {
if (!Yap_gcl(Yap_Error_Size, 1, ENV, gc_P(P,CP))) {
if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while dumping stack");
return FALSE;
}
@ -4141,20 +4121,20 @@ p_is_call_counted( USES_REGS1 )
static Int
p_call_count_info( USES_REGS1 )
{
return(Yap_unify(MkIntegerTerm(ReductionsCounter),ARG1) &&
Yap_unify(MkIntegerTerm(PredEntriesCounter),ARG2) &&
Yap_unify(MkIntegerTerm(PredEntriesCounter),ARG3));
return(Yap_unify(MkIntegerTerm(LOCAL_ReductionsCounter),ARG1) &&
Yap_unify(MkIntegerTerm(LOCAL_PredEntriesCounter),ARG2) &&
Yap_unify(MkIntegerTerm(LOCAL_PredEntriesCounter),ARG3));
}
static Int
p_call_count_reset( USES_REGS1 )
{
ReductionsCounter = 0;
ReductionsCounterOn = FALSE;
PredEntriesCounter = 0;
PredEntriesCounterOn = FALSE;
RetriesCounter = 0;
RetriesCounterOn = FALSE;
LOCAL_ReductionsCounter = 0;
LOCAL_ReductionsCounterOn = FALSE;
LOCAL_PredEntriesCounter = 0;
LOCAL_PredEntriesCounterOn = FALSE;
LOCAL_RetriesCounter = 0;
LOCAL_RetriesCounterOn = FALSE;
return(TRUE);
}
@ -4166,14 +4146,14 @@ p_call_count_set( USES_REGS1 )
int do_entries = IntOfTerm(ARG6);
if (do_calls)
ReductionsCounter = IntegerOfTerm(Deref(ARG1));
ReductionsCounterOn = do_calls;
LOCAL_ReductionsCounter = IntegerOfTerm(Deref(ARG1));
LOCAL_ReductionsCounterOn = do_calls;
if (do_retries)
RetriesCounter = IntegerOfTerm(Deref(ARG3));
RetriesCounterOn = do_retries;
LOCAL_RetriesCounter = IntegerOfTerm(Deref(ARG3));
LOCAL_RetriesCounterOn = do_retries;
if (do_entries)
PredEntriesCounter = IntegerOfTerm(Deref(ARG5));
PredEntriesCounterOn = do_entries;
LOCAL_PredEntriesCounter = IntegerOfTerm(Deref(ARG5));
LOCAL_PredEntriesCounterOn = do_entries;
return(TRUE);
}
@ -4482,18 +4462,18 @@ fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, ya
ARG5 = th;
ARG6 = tb;
ARG7 = tr;
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
UNLOCK(pe->PELock);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, 7, ENV, gc_P(P,CP))) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 7, ENV, gc_P(P,CP))) {
UNLOCK(pe->PELock);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -4504,9 +4484,9 @@ fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, ya
ARG6 = th;
ARG7 = tb;
ARG8 = tr;
if (!Yap_gcl(Yap_Error_Size, 8, ENV, gc_P(P,CP))) {
if (!Yap_gcl(LOCAL_Error_Size, 8, ENV, gc_P(P,CP))) {
UNLOCK(pe->PELock);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
th = ARG6;
@ -4630,18 +4610,18 @@ fetch_next_lu_clause_erase(PredEntry *pe, yamop *i_code, Term th, Term tb, Term
ARG5 = th;
ARG6 = tb;
ARG7 = tr;
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
UNLOCK(pe->PELock);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, 7, ENV, gc_P(P,CP))) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 7, ENV, gc_P(P,CP))) {
UNLOCK(pe->PELock);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -4652,9 +4632,9 @@ fetch_next_lu_clause_erase(PredEntry *pe, yamop *i_code, Term th, Term tb, Term
ARG6 = th;
ARG7 = tb;
ARG8 = tr;
if (!Yap_gcl(Yap_Error_Size, 8, ENV, CP)) {
if (!Yap_gcl(LOCAL_Error_Size, 8, ENV, CP)) {
UNLOCK(pe->PELock);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
th = ARG6;
@ -4868,7 +4848,7 @@ Yap_UpdateTimestamps(PredEntry *ap)
return;
overflow:
if (!Yap_growstack(64*1024)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return;
}
goto restart;
@ -4967,19 +4947,19 @@ fetch_next_static_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr
}
while ((t = Yap_FetchTermFromDB(cl->usc.ClSource)) == 0L) {
if (first_time) {
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
ARG5 = th;
ARG6 = tb;
ARG7 = tr;
if (!Yap_gc(7, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
th = ARG5;
@ -4987,12 +4967,12 @@ fetch_next_static_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr
tr = ARG7;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
ARG6 = th;
ARG7 = tb;
ARG8 = tr;
if (!Yap_gcl(Yap_Error_Size, 8, ENV, CP)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
if (!Yap_gcl(LOCAL_Error_Size, 8, ENV, CP)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
th = ARG6;

View File

@ -481,14 +481,14 @@ flt_cmp(Float dif)
static inline Int
a_cmp(Term t1, Term t2 USES_REGS)
{
ArithError = FALSE;
LOCAL_ArithError = FALSE;
if (IsVarTerm(t1)) {
ArithError = TRUE;
LOCAL_ArithError = TRUE;
Yap_Error(INSTANTIATION_ERROR, t1, "=:=/2");
return FALSE;
}
if (IsVarTerm(t2)) {
ArithError = TRUE;
LOCAL_ArithError = TRUE;
Yap_Error(INSTANTIATION_ERROR, t2, "=:=/2");
return FALSE;
}
@ -513,10 +513,10 @@ a_cmp(Term t1, Term t2 USES_REGS)
Float f2 = FloatOfTerm(t2);
#if HAVE_ISNAN
if (isnan(f2)) {
Yap_Error_TYPE = EVALUATION_ERROR_UNDEFINED;
Yap_Error_Term = t2;
Yap_ErrorMessage = "trying to evaluate nan";
ArithError = TRUE;
LOCAL_Error_TYPE = EVALUATION_ERROR_UNDEFINED;
LOCAL_Error_Term = t2;
LOCAL_ErrorMessage = "trying to evaluate nan";
LOCAL_ArithError = TRUE;
}
#endif
return flt_cmp(i1-f2);
@ -531,10 +531,10 @@ a_cmp(Term t1, Term t2 USES_REGS)
Float f1 = FloatOfTerm(t1);
#if HAVE_ISNAN
if (isnan(f1)) {
Yap_Error_TYPE = EVALUATION_ERROR_UNDEFINED;
Yap_Error_Term = t1;
Yap_ErrorMessage = "trying to evaluate nan";
ArithError = TRUE;
LOCAL_Error_TYPE = EVALUATION_ERROR_UNDEFINED;
LOCAL_Error_Term = t1;
LOCAL_ErrorMessage = "trying to evaluate nan";
LOCAL_ArithError = TRUE;
}
#endif
t2 = Yap_Eval(t2);
@ -550,10 +550,10 @@ a_cmp(Term t1, Term t2 USES_REGS)
Float f2 = FloatOfTerm(t2);
#if HAVE_ISNAN
if (isnan(f2)) {
Yap_Error_TYPE = EVALUATION_ERROR_UNDEFINED;
Yap_Error_Term = t2;
Yap_ErrorMessage = "trying to evaluate nan";
ArithError = TRUE;
LOCAL_Error_TYPE = EVALUATION_ERROR_UNDEFINED;
LOCAL_Error_Term = t2;
LOCAL_ErrorMessage = "trying to evaluate nan";
LOCAL_ArithError = TRUE;
}
#endif
return flt_cmp(f1-f2);
@ -575,10 +575,10 @@ a_cmp(Term t1, Term t2 USES_REGS)
Float f2 = FloatOfTerm(t2);
#if HAVE_ISNAN
if (isnan(f2)) {
Yap_Error_TYPE = EVALUATION_ERROR_UNDEFINED;
Yap_Error_Term = t2;
Yap_ErrorMessage = "trying to evaluate nan";
ArithError = TRUE;
LOCAL_Error_TYPE = EVALUATION_ERROR_UNDEFINED;
LOCAL_Error_Term = t2;
LOCAL_ErrorMessage = "trying to evaluate nan";
LOCAL_ArithError = TRUE;
}
#endif
return Yap_gmp_cmp_big_float(t1, f2);
@ -603,7 +603,7 @@ p_acomp( USES_REGS1 )
Int out;
out = a_cmp(t1, t2 PASS_REGS);
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
if (LOCAL_ArithError) { Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage); return FALSE; }
return out;
}
@ -637,7 +637,7 @@ a_eq(Term t1, Term t2)
}
}
out = a_cmp(t1,t2 PASS_REGS);
if (ArithError) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); return FALSE; }
if (LOCAL_ArithError) { Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage); return FALSE; }
return out == 0;
}
@ -646,7 +646,7 @@ a_dif(Term t1, Term 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 (LOCAL_ArithError) { Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage); return FALSE; }
return out != 0;
}
@ -655,7 +655,7 @@ a_gt(Term t1, Term t2)
{ /* A > B */
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 (LOCAL_ArithError) { Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage); return FALSE; }
return out > 0;
}
@ -664,7 +664,7 @@ a_ge(Term t1, Term t2)
{ /* A >= B */
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 (LOCAL_ArithError) { Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage); return FALSE; }
return out >= 0;
}
@ -673,7 +673,7 @@ a_lt(Term t1, Term t2)
{ /* A < B */
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 (LOCAL_ArithError) { Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage); return FALSE; }
return out < 0;
}
@ -682,7 +682,7 @@ a_le(Term t1, Term t2)
{ /* A <= B */
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 (LOCAL_ArithError) { Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage); return FALSE; }
return out <= 0;
}

View File

@ -286,7 +286,7 @@ active_branch(int i, int onbranch)
return(i==onbranch);*/
}
#define FAIL(M,T,E) { Yap_ErrorMessage=M; Yap_Error_TYPE = T; Yap_Error_Term = E; return; }
#define FAIL(M,T,E) { LOCAL_ErrorMessage=M; LOCAL_Error_TYPE = T; LOCAL_Error_Term = E; return; }
#if USE_SYSTEM_MALLOC
#define IsNewVar(v) ((CELL *)(v) >= H0 && (CELL *)(v) < LCL0)
@ -567,9 +567,9 @@ compile_sf_term(Term t, int argno, int level)
if (IsAtomicTerm(t))
Yap_emit((cglobs->onhead ? unify_s_a_op : write_s_a_op), t, (CELL) argno, &cglobs->cint);
else if (!IsVarTerm(t)) {
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
Yap_Error_Term = TermNil;
Yap_ErrorMessage = "illegal argument of soft functor";
LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR;
LOCAL_Error_Term = TermNil;
LOCAL_ErrorMessage = "illegal argument of soft functor";
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
}
@ -595,9 +595,9 @@ c_args(Term app, unsigned int level, compiler_struct *cglobs)
if (level == 0) {
if (Arity >= MaxTemps) {
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
Yap_Error_Term = TermNil;
Yap_ErrorMessage = "exceed maximum arity of compiled goal";
LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR;
LOCAL_Error_Term = TermNil;
LOCAL_ErrorMessage = "exceed maximum arity of compiled goal";
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
}
@ -619,7 +619,7 @@ try_store_as_dbterm(Term t, Int argno, unsigned int arity, int level, compiler_s
while ((g=Yap_SizeGroundTerm(t,TRUE)) < 0) {
/* oops, too deep a term */
save_machine_regs();
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
siglongjmp(cglobs->cint.CompilerBotch, OUT_OF_AUX_BOTCH);
}
if (g < 16)
@ -628,18 +628,18 @@ try_store_as_dbterm(Term t, Int argno, unsigned int arity, int level, compiler_s
H = CellPtr(cglobs->cint.freep);
if ((dbt = Yap_StoreTermInDB(t, -1)) == NULL) {
H = h0;
switch(Yap_Error_TYPE) {
switch(LOCAL_Error_TYPE) {
case OUT_OF_STACK_ERROR:
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_STACK_BOTCH);
case OUT_OF_TRAIL_ERROR:
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TRAIL_BOTCH);
case OUT_OF_HEAP_ERROR:
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_HEAP_BOTCH);
case OUT_OF_AUXSPACE_ERROR:
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_AUX_BOTCH);
default:
siglongjmp(cglobs->cint.CompilerBotch,COMPILER_ERR_BOTCH);
@ -1010,11 +1010,11 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
} else {
char s[32];
Yap_Error_TYPE = TYPE_ERROR_NUMBER;
Yap_Error_Term = t2;
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_Error_TYPE = TYPE_ERROR_NUMBER;
LOCAL_Error_Term = t2;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
Yap_bip_name(Op, s);
sprintf(Yap_ErrorMessage, "compiling %s/2 with output bound", s);
sprintf(LOCAL_ErrorMessage, "compiling %s/2 with output bound", s);
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,1);
}
@ -1025,11 +1025,11 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
if (IsNewVar(t2)) {
char s[32];
Yap_Error_TYPE = INSTANTIATION_ERROR;
Yap_Error_Term = t2;
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_Error_TYPE = INSTANTIATION_ERROR;
LOCAL_Error_Term = t2;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
Yap_bip_name(Op, s);
sprintf(Yap_ErrorMessage, "compiling %s/3",s);
sprintf(LOCAL_ErrorMessage, "compiling %s/3",s);
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,1);
}
@ -1041,11 +1041,11 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
if (!IsIntegerTerm(t2)) {
char s[32];
Yap_Error_TYPE = TYPE_ERROR_INTEGER;
Yap_Error_Term = t2;
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_Error_TYPE = TYPE_ERROR_INTEGER;
LOCAL_Error_Term = t2;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
Yap_bip_name(Op, s);
sprintf(Yap_ErrorMessage, "compiling functor/3");
sprintf(LOCAL_ErrorMessage, "compiling functor/3");
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,1);
}
@ -1053,11 +1053,11 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
if (i2 < 0) {
char s[32];
Yap_Error_TYPE = DOMAIN_ERROR_NOT_LESS_THAN_ZERO;
Yap_Error_Term = t2;
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_Error_TYPE = DOMAIN_ERROR_NOT_LESS_THAN_ZERO;
LOCAL_Error_Term = t2;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
Yap_bip_name(Op, s);
sprintf(Yap_ErrorMessage, "compiling functor/3");
sprintf(LOCAL_ErrorMessage, "compiling functor/3");
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,1);
}
@ -1068,11 +1068,11 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
} else if (!IsAtomTerm(t1)) {
char s[32];
Yap_Error_TYPE = TYPE_ERROR_ATOM;
Yap_Error_Term = t2;
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_Error_TYPE = TYPE_ERROR_ATOM;
LOCAL_Error_Term = t2;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
Yap_bip_name(Op, s);
sprintf(Yap_ErrorMessage, "compiling functor/3");
sprintf(LOCAL_ErrorMessage, "compiling functor/3");
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,1);
}
@ -1126,11 +1126,11 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
else {
char s[32];
Yap_Error_TYPE = TYPE_ERROR_INTEGER;
Yap_Error_Term = t2;
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_Error_TYPE = TYPE_ERROR_INTEGER;
LOCAL_Error_Term = t2;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
Yap_bip_name(Op, s);
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
sprintf(LOCAL_ErrorMessage, "compiling %s/2", s);
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,1);
}
@ -1138,11 +1138,11 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
(IsApplTerm(t2) && IsExtensionFunctor(FunctorOfTerm(t2)))) {
char s[32];
Yap_Error_TYPE = TYPE_ERROR_COMPOUND;
Yap_Error_Term = t2;
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_Error_TYPE = TYPE_ERROR_COMPOUND;
LOCAL_Error_Term = t2;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
Yap_bip_name(Op, s);
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
sprintf(LOCAL_ErrorMessage, "compiling %s/2", s);
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,1);
} else if (IsApplTerm(t2)) {
@ -1169,11 +1169,11 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
} else {
char s[32];
Yap_Error_TYPE = TYPE_ERROR_INTEGER;
Yap_Error_Term = t2;
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_Error_TYPE = TYPE_ERROR_INTEGER;
LOCAL_Error_Term = t2;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
Yap_bip_name(Op, s);
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
sprintf(LOCAL_ErrorMessage, "compiling %s/2", s);
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,1);
}
@ -1182,11 +1182,11 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
if (!IsAtomicTerm(t1)) {
char s[32];
Yap_Error_TYPE = TYPE_ERROR_ATOM;
Yap_Error_Term = t1;
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_Error_TYPE = TYPE_ERROR_ATOM;
LOCAL_Error_Term = t1;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
Yap_bip_name(Op, s);
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
sprintf(LOCAL_ErrorMessage, "compiling %s/2", s);
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,1);
} else {
@ -1197,11 +1197,11 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
if (!IsIntegerTerm(t2)) {
char s[32];
Yap_Error_TYPE = TYPE_ERROR_INTEGER;
Yap_Error_Term = t2;
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_Error_TYPE = TYPE_ERROR_INTEGER;
LOCAL_Error_Term = t2;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
Yap_bip_name(Op, s);
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
sprintf(LOCAL_ErrorMessage, "compiling %s/2", s);
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,1);
}
@ -1215,11 +1215,11 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
if (!IsAtomTerm(t1)) {
char s[32];
Yap_Error_TYPE = TYPE_ERROR_ATOM;
Yap_Error_Term = t1;
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_Error_TYPE = TYPE_ERROR_ATOM;
LOCAL_Error_Term = t1;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
Yap_bip_name(Op, s);
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
sprintf(LOCAL_ErrorMessage, "compiling %s/2", s);
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,1);
}
@ -1259,11 +1259,11 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
} else {
char s[32];
Yap_Error_TYPE = TYPE_ERROR_VARIABLE;
Yap_Error_Term = t1;
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_Error_TYPE = TYPE_ERROR_VARIABLE;
LOCAL_Error_Term = t1;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
Yap_bip_name(Op, s);
sprintf(Yap_ErrorMessage, "compiling %s/2 with output bound", s);
sprintf(LOCAL_ErrorMessage, "compiling %s/2 with output bound", s);
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,1);
}
@ -1282,11 +1282,11 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
} else {
char s[32];
Yap_Error_TYPE = TYPE_ERROR_VARIABLE;
Yap_Error_Term = t3;
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_Error_TYPE = TYPE_ERROR_VARIABLE;
LOCAL_Error_Term = t3;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
Yap_bip_name(Op, s);
sprintf(Yap_ErrorMessage, "compiling %s/2 with input unbound", s);
sprintf(LOCAL_ErrorMessage, "compiling %s/2 with input unbound", s);
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,1);
}
@ -1450,12 +1450,12 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
if (IsVarTerm(M) || !IsAtomTerm(M)) {
CACHE_REGS
if (IsVarTerm(M)) {
Yap_Error_TYPE = INSTANTIATION_ERROR;
LOCAL_Error_TYPE = INSTANTIATION_ERROR;
} else {
Yap_Error_TYPE = TYPE_ERROR_ATOM;
LOCAL_Error_TYPE = TYPE_ERROR_ATOM;
}
Yap_Error_Term = M;
Yap_ErrorMessage = "in module name";
LOCAL_Error_Term = M;
LOCAL_ErrorMessage = "in module name";
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
}
@ -1469,8 +1469,8 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
FAIL("goal can not be a number", TYPE_ERROR_CALLABLE, Goal);
} else if (IsRefTerm(Goal)) {
CACHE_REGS
Yap_Error_TYPE = TYPE_ERROR_DBREF;
Yap_Error_Term = Goal;
LOCAL_Error_TYPE = TYPE_ERROR_DBREF;
LOCAL_Error_Term = Goal;
FAIL("goal argument in static procedure can not be a data base reference", TYPE_ERROR_CALLABLE, Goal);
}
else if (IsPairTerm(Goal)) {
@ -1906,10 +1906,10 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
Term a2 = ArgOfTerm(2,Goal);
if (IsVarTerm(a2) && !IsNewVar(a2)) {
if (IsNewVar(a2)) {
Yap_Error_TYPE = INSTANTIATION_ERROR;
Yap_Error_Term = a2;
Yap_ErrorMessage = Yap_ErrorSay;
sprintf(Yap_ErrorMessage, "compiling %s/2 with second arg unbound", RepAtom(NameOfFunctor(p->FunctorOfPred))->StrOfAE);
LOCAL_Error_TYPE = INSTANTIATION_ERROR;
LOCAL_Error_Term = a2;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
sprintf(LOCAL_ErrorMessage, "compiling %s/2 with second arg unbound", RepAtom(NameOfFunctor(p->FunctorOfPred))->StrOfAE);
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,1);
}
@ -2314,9 +2314,9 @@ clear_bvarray(int var, CELL *bvarray
if (*bvarray & nbit) {
CACHE_REGS
/* someone had already marked this variable: complain */
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
Yap_Error_Term = TermNil;
Yap_ErrorMessage = "compiler internal error: variable initialised twice";
LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR;
LOCAL_Error_Term = TermNil;
LOCAL_ErrorMessage = "compiler internal error: variable initialised twice";
fprintf(stderr," vsc: compiling7\n");
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
@ -2357,9 +2357,9 @@ push_bvmap(int label, PInstr *pcpc, compiler_struct *cglobs)
{
if (bvindex == MAX_DISJUNCTIONS) {
CACHE_REGS
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
Yap_Error_Term = TermNil;
Yap_ErrorMessage = "Too many embedded disjunctions";
LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR;
LOCAL_Error_Term = TermNil;
LOCAL_ErrorMessage = "Too many embedded disjunctions";
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
}
@ -2381,9 +2381,9 @@ reset_bvmap(CELL *bvarray, int nperm, compiler_struct *cglobs)
if (bvindex == 0) {
CACHE_REGS
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
Yap_Error_Term = TermNil;
Yap_ErrorMessage = "No embedding in disjunctions";
LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR;
LOCAL_Error_Term = TermNil;
LOCAL_ErrorMessage = "No embedding in disjunctions";
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
}
@ -2402,9 +2402,9 @@ pop_bvmap(CELL *bvarray, int nperm, compiler_struct *cglobs)
{
if (bvindex == 0) {
CACHE_REGS
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
Yap_Error_Term = TermNil;
Yap_ErrorMessage = "Too few embedded disjunctions";
LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR;
LOCAL_Error_Term = TermNil;
LOCAL_ErrorMessage = "Too few embedded disjunctions";
/* save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH); */
}
@ -2673,9 +2673,9 @@ checktemp(Int arg, Int rn, compiler_vm_op ic, compiler_struct *cglobs)
}
if (target1 == cglobs->MaxCTemps) {
CACHE_REGS
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
Yap_Error_Term = TermNil;
Yap_ErrorMessage = "too many temporaries";
LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR;
LOCAL_Error_Term = TermNil;
LOCAL_ErrorMessage = "too many temporaries";
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
}
@ -2807,9 +2807,9 @@ c_layout(compiler_struct *cglobs)
#ifdef DEBUG
if (cglobs->pbvars != nperm) {
CACHE_REGS
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
Yap_Error_Term = TermNil;
Yap_ErrorMessage = "wrong number of variables found in bitmap";
LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR;
LOCAL_Error_Term = TermNil;
LOCAL_ErrorMessage = "wrong number of variables found in bitmap";
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
}
@ -3357,7 +3357,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
compiler_struct cglobs;
/* make sure we know there was no error yet */
Yap_ErrorMessage = NULL;
LOCAL_ErrorMessage = NULL;
if ((botch_why = sigsetjmp(cglobs.cint.CompilerBotch, 0))) {
restore_machine_regs();
reset_vars(cglobs.vtable);
@ -3371,14 +3371,14 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
ARG3 = src;
YAPLeaveCriticalSection();
if (!Yap_gcl(Yap_Error_Size, NOfArgs, ENV, gc_P(P,CP))) {
Yap_Error_TYPE = OUT_OF_STACK_ERROR;
Yap_Error_Term = inp_clause;
if (!Yap_gcl(LOCAL_Error_Size, NOfArgs, ENV, gc_P(P,CP))) {
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
LOCAL_Error_Term = inp_clause;
}
if (osize > ASP-H) {
if (!Yap_growstack(2*sizeof(CELL)*(ASP-H))) {
Yap_Error_TYPE = OUT_OF_STACK_ERROR;
Yap_Error_Term = inp_clause;
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
LOCAL_Error_Term = inp_clause;
}
}
YAPEnterCriticalSection();
@ -3391,9 +3391,9 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
YAPLeaveCriticalSection();
ARG1 = inp_clause;
ARG3 = src;
if (!Yap_ExpandPreAllocCodeSpace(Yap_Error_Size, NULL, TRUE)) {
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
Yap_Error_Term = inp_clause;
if (!Yap_ExpandPreAllocCodeSpace(LOCAL_Error_Size, NULL, TRUE)) {
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_Error_Term = inp_clause;
}
YAPEnterCriticalSection();
src = ARG3;
@ -3412,9 +3412,9 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
ARG1 = inp_clause;
ARG3 = src;
YAPLeaveCriticalSection();
if (!Yap_growheap(FALSE, Yap_Error_Size, NULL)) {
Yap_Error_TYPE = OUT_OF_HEAP_ERROR;
Yap_Error_Term = inp_clause;
if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) {
LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR;
LOCAL_Error_Term = inp_clause;
return NULL;
}
YAPEnterCriticalSection();
@ -3426,9 +3426,9 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
ARG1 = inp_clause;
ARG3 = src;
YAPLeaveCriticalSection();
if (!Yap_growtrail(Yap_TrailTop-(ADDR)TR, FALSE)) {
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
Yap_Error_Term = inp_clause;
if (!Yap_growtrail(LOCAL_TrailTop-(ADDR)TR, FALSE)) {
LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR;
LOCAL_Error_Term = inp_clause;
return NULL;
}
YAPEnterCriticalSection();
@ -3441,9 +3441,9 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
}
my_clause = inp_clause;
HB = H;
Yap_ErrorMessage = NULL;
Yap_Error_Size = 0;
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_ErrorMessage = NULL;
LOCAL_Error_Size = 0;
LOCAL_Error_TYPE = YAP_NO_ERROR;
/* initialize variables for code generation */
cglobs.cint.CodeStart = cglobs.cint.cpc = NULL;
@ -3457,7 +3457,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
cglobs.cint.success_handler = 0L;
if (ASP <= CellPtr (cglobs.cint.freep) + 256) {
cglobs.vtable = NULL;
Yap_Error_Size = (256+maxvnum)*sizeof(CELL);
LOCAL_Error_Size = (256+maxvnum)*sizeof(CELL);
save_machine_regs();
siglongjmp(cglobs.cint.CompilerBotch,3);
}
@ -3481,9 +3481,9 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
cglobs.is_a_fact = FALSE;
cglobs.hasdbrefs = FALSE;
if (IsVarTerm(my_clause)) {
Yap_Error_TYPE = INSTANTIATION_ERROR;
Yap_Error_Term = my_clause;
Yap_ErrorMessage = "in compiling clause";
LOCAL_Error_TYPE = INSTANTIATION_ERROR;
LOCAL_Error_Term = my_clause;
LOCAL_ErrorMessage = "in compiling clause";
return 0;
}
if (IsApplTerm(my_clause) && FunctorOfTerm(my_clause) == FunctorAssert) {
@ -3494,9 +3494,9 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
head = my_clause, body = MkAtomTerm(AtomTrue);
}
if (IsVarTerm(head) || IsPairTerm(head) || IsIntTerm(head) || IsFloatTerm(head) || IsRefTerm(head)) {
Yap_Error_TYPE = TYPE_ERROR_CALLABLE;
Yap_Error_Term = my_clause;
Yap_ErrorMessage = "clause should be atom or term";
LOCAL_Error_TYPE = TYPE_ERROR_CALLABLE;
LOCAL_Error_Term = my_clause;
LOCAL_ErrorMessage = "clause should be atom or term";
return (0);
} else {
@ -3544,10 +3544,10 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
cglobs.cint.cpc->nextInst = cglobs.cint.BlobsStart;
cglobs.cint.BlobsStart = NULL;
}
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return (0);
#ifdef DEBUG
if (Yap_Option['g' - 96])
if (GLOBAL_Option['g' - 96])
Yap_ShowCode(&cglobs.cint);
#endif
} else {
@ -3577,10 +3577,10 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
if (B != NULL) {
HB = B->cp_h;
}
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return (0);
#ifdef DEBUG
if (Yap_Option['g' - 96])
if (GLOBAL_Option['g' - 96])
Yap_ShowCode(&cglobs.cint);
#endif
/* phase 2: classify variables and optimize temporaries */
@ -3596,7 +3596,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
/* eliminate superfluous pop's and unify_var's */
c_optimize(cglobs.cint.CodeStart);
#ifdef DEBUG
if (Yap_Option['f' - 96])
if (GLOBAL_Option['f' - 96])
Yap_ShowCode(&cglobs.cint);
#endif
@ -3618,7 +3618,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
#ifdef LOW_PROF
if (ProfilerOn &&
Yap_OffLineProfiler) {
Yap_inform_profiler_of_clause(acode, ProfEnd, cglobs.cint.CurrentPred,0);
Yap_inform_profiler_of_clause(acode, LOCAL_ProfEnd, cglobs.cint.CurrentPred,0);
}
#endif /* LOW_PROF */
return(acode);

View File

@ -75,12 +75,7 @@ STATIC_PROTO (void ShowOp, (char *, struct PSEUDO *));
* afterwards
*/
#ifdef DEBUG
char Yap_Option[20];
YP_FILE *Yap_logfile;
#endif
typedef struct mem_blk {
union {
@ -112,27 +107,27 @@ AllocCMem (UInt size, struct intermediates *cip)
blksz = CMEM_BLK_SIZE;
if (!cip->blks) {
CACHE_REGS
if (Yap_CMemFirstBlock) {
p = Yap_CMemFirstBlock;
blksz = Yap_CMemFirstBlockSz;
if (LOCAL_CMemFirstBlock) {
p = LOCAL_CMemFirstBlock;
blksz = LOCAL_CMemFirstBlockSz;
p->u.next = NULL;
} else {
if (blksz < FIRST_CMEM_BLK_SIZE)
blksz = FIRST_CMEM_BLK_SIZE;
p = (struct mem_blk *)Yap_AllocCodeSpace(blksz);
if (!p) {
Yap_Error_Size = size;
LOCAL_Error_Size = size;
save_machine_regs();
siglongjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
}
Yap_CMemFirstBlock = p;
Yap_CMemFirstBlockSz = blksz;
LOCAL_CMemFirstBlock = p;
LOCAL_CMemFirstBlockSz = blksz;
}
} else {
p = (struct mem_blk *)Yap_AllocCodeSpace(blksz);
if (!p) {
CACHE_REGS
Yap_Error_Size = size;
LOCAL_Error_Size = size;
save_machine_regs();
siglongjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
}
@ -153,7 +148,7 @@ AllocCMem (UInt size, struct intermediates *cip)
cip->freep += size;
if (ASP <= CellPtr (cip->freep) + 256) {
CACHE_REGS
Yap_Error_Size = 256+((char *)cip->freep - (char *)H);
LOCAL_Error_Size = 256+((char *)cip->freep - (char *)H);
save_machine_regs();
siglongjmp(cip->CompilerBotch, OUT_OF_STACK_BOTCH);
}
@ -169,13 +164,13 @@ Yap_ReleaseCMem (struct intermediates *cip)
struct mem_blk *p = cip->blks;
while (p) {
struct mem_blk *nextp = p->u.next;
if (p != Yap_CMemFirstBlock)
if (p != LOCAL_CMemFirstBlock)
Yap_FreeCodeSpace((ADDR)p);
p = nextp;
}
cip->blks = NULL;
if (cip->label_offset &&
cip->label_offset != Yap_LabelFirstArray) {
cip->label_offset != LOCAL_LabelFirstArray) {
Yap_FreeCodeSpace((ADDR)cip->label_offset);
}
#endif

View File

@ -505,7 +505,7 @@ static Int p_coroutining( USES_REGS1 )
#if COROUTINING
static Term
ListOfWokenGoals( USES_REGS1 ) {
return Yap_ReadTimedVar(WokenGoals);
return Yap_ReadTimedVar(LOCAL_WokenGoals);
}
Term
@ -519,12 +519,12 @@ Yap_ListOfWokenGoals(void) {
static Int p_awoken_goals( USES_REGS1 )
{
#ifdef COROUTINING
Term WGs = Yap_ReadTimedVar(WokenGoals);
Term WGs = Yap_ReadTimedVar(LOCAL_WokenGoals);
if (WGs == TermNil) {
return(FALSE);
}
WGs = ListOfWokenGoals( PASS_REGS1 );
Yap_UpdateTimedVar(WokenGoals, TermNil);
Yap_UpdateTimedVar(LOCAL_WokenGoals, TermNil);
return(Yap_unify(ARG1,WGs));
#else
return(FALSE);

View File

@ -6,14 +6,14 @@
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)LOCAL_LocalBase;
}
/*Removes a choice_point from the stack*/
void cut_c_pop(void){
CACHE_REGS
cut_c_str_ptr to_delete = NULL;
if (((CELL *)Yap_REGS.CUT_C_TOP) == ((CELL *)Yap_LocalBase))
if (((CELL *)Yap_REGS.CUT_C_TOP) == ((CELL *)LOCAL_LocalBase))
{
return;
}

329
C/dbase.c
View File

@ -160,7 +160,6 @@ typedef struct db_globs {
UInt sz; /* total size */
} dbglobs;
static dbglobs *s_dbg;
#ifdef SUPPORT_HASH_TABLES
typedef struct {
@ -249,7 +248,7 @@ STATIC_PROTO(DBProp find_int_key, (Int));
static UInt new_trail_size(void)
{
CACHE_REGS
UInt sz = (Yap_TrailTop-(ADDR)TR)/2;
UInt sz = (LOCAL_TrailTop-(ADDR)TR)/2;
if (sz < K64)
return K64;
if (sz > M1)
@ -261,10 +260,10 @@ static int
recover_from_record_error(int nargs)
{
CACHE_REGS
switch(Yap_Error_TYPE) {
switch(LOCAL_Error_TYPE) {
case OUT_OF_STACK_ERROR:
if (!Yap_gcl(Yap_Error_Size, nargs, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
if (!Yap_gcl(LOCAL_Error_Size, nargs, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
goto recover_record;
@ -275,24 +274,24 @@ recover_from_record_error(int nargs)
}
goto recover_record;
case OUT_OF_HEAP_ERROR:
if (!Yap_growheap(FALSE, Yap_Error_Size, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, Yap_Error_Term, Yap_ErrorMessage);
if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, LOCAL_Error_Term, LOCAL_ErrorMessage);
return FALSE;
}
goto recover_record;
case OUT_OF_AUXSPACE_ERROR:
if (!Yap_ExpandPreAllocCodeSpace(Yap_Error_Size, NULL, TRUE)) {
Yap_Error(OUT_OF_AUXSPACE_ERROR, Yap_Error_Term, Yap_ErrorMessage);
if (!Yap_ExpandPreAllocCodeSpace(LOCAL_Error_Size, NULL, TRUE)) {
Yap_Error(OUT_OF_AUXSPACE_ERROR, LOCAL_Error_Term, LOCAL_ErrorMessage);
return FALSE;
}
goto recover_record;
default:
Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage);
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
return FALSE;
}
recover_record:
Yap_Error_Size = 0;
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_Size = 0;
LOCAL_Error_TYPE = YAP_NO_ERROR;
return TRUE;
}
@ -368,7 +367,7 @@ static Int cmpclls(CELL *a,CELL *b,Int n)
#if !THREADS
int Yap_DBTrailOverflow()
{
return((CELL *)s_dbg->lr > (CELL *)s_dbg->tofref - 2048);
return((CELL *)LOCAL_s_dbg->lr > (CELL *)LOCAL_s_dbg->tofref - 2048);
}
#endif
@ -906,7 +905,7 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end,
the variable, the constraint in some cannonical form, what type
of constraint, and a list pointer */
t[0] = (CELL)ptd0;
t[1] = attas[ExtFromCell(ptd0)].to_term_op(ptd0);
t[1] = GLOBAL_attas[ExtFromCell(ptd0)].to_term_op(ptd0);
t[2] = MkIntegerTerm(ExtFromCell(ptd0));
t[3] = ConstraintsTerm;
ConstraintsTerm = Yap_MkApplTerm(FunctorClist, 4, t);
@ -975,8 +974,8 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end,
return CodeMax;
error:
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
Yap_Error_Size = 1024+((char *)AuxSp-(char *)CodeMaxBase);
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_Error_Size = 1024+((char *)AuxSp-(char *)CodeMaxBase);
*vars_foundp = vars_found;
#ifdef RATIONAL_TREES
while (to_visit > to_visit_base) {
@ -994,7 +993,7 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end,
return NULL;
error2:
Yap_Error_TYPE = OUT_OF_STACK_ERROR;
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
*vars_foundp = vars_found;
#ifdef RATIONAL_TREES
while (to_visit > to_visit_base) {
@ -1012,7 +1011,7 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end,
return NULL;
error_tr_overflow:
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR;
*vars_foundp = vars_found;
#ifdef RATIONAL_TREES
while (to_visit > to_visit_base) {
@ -1078,9 +1077,9 @@ sf_include(SFKeep *sfp, struct db_globs *dbg)
*StoPoint++ = tvalue;
j += 2;
} else {
Yap_Error_TYPE = TYPE_ERROR_DBTERM;
Yap_Error_Term = d0;
Yap_ErrorMessage = "wrong term in SF";
LOCAL_Error_TYPE = TYPE_ERROR_DBTERM;
LOCAL_Error_Term = d0;
LOCAL_ErrorMessage = "wrong term in SF";
return(NULL);
}
}
@ -1208,10 +1207,10 @@ static DBRef
generate_dberror_msg(int errnumb, UInt sz, char *msg)
{
CACHE_REGS
Yap_Error_Size = sz;
Yap_Error_TYPE = errnumb;
Yap_Error_Term = TermNil;
Yap_ErrorMessage = msg;
LOCAL_Error_Size = sz;
LOCAL_Error_TYPE = errnumb;
LOCAL_Error_Term = TermNil;
LOCAL_ErrorMessage = msg;
return NULL;
}
@ -1365,11 +1364,11 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc
SMALLUNSGN flag;
int NOfLinks = 0;
/* place DBRefs in ConsultStack */
DBRef *TmpRefBase = (DBRef *)Yap_TrailTop;
DBRef *TmpRefBase = (DBRef *)LOCAL_TrailTop;
CELL *CodeAbs; /* how much code did we find */
int vars_found = FALSE;
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (p == NULL) {
if (IsVarTerm(Tm)) {
@ -1420,15 +1419,15 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc
ppt0 = &(pp0->DBT);
}
if ((ADDR)ppt0 >= (ADDR)AuxSp-1024) {
Yap_Error_Size = (UInt)(extra_size+sizeof(ppt0));
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_Error_Size = (UInt)(extra_size+sizeof(ppt0));
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
return NULL;
}
ntp0 = ppt0->Contents;
if ((ADDR)TR >= Yap_TrailTop-1024) {
Yap_Error_Size = 0;
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
if ((ADDR)TR >= LOCAL_TrailTop-1024) {
LOCAL_Error_Size = 0;
LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR;
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
return NULL;
}
@ -1501,7 +1500,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc
}
}
CodeAbs = (CELL *)((CELL)ntp-(CELL)ntp0);
if (Yap_Error_TYPE) {
if (LOCAL_Error_TYPE) {
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
return NULL; /* Error Situation */
}
@ -1517,8 +1516,8 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc
flag = DBComplex;
CodeAbs += CellPtr(dbg->lr) - CellPtr(dbg->LinkAr);
if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) {
Yap_Error_Size = (UInt)DBLength(CodeAbs);
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_Error_Size = (UInt)DBLength(CodeAbs);
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
return NULL;
}
@ -1536,8 +1535,8 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc
if (dbg->tofref != TmpRefBase) {
CodeAbs += (TmpRefBase - dbg->tofref) + 1;
if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) {
Yap_Error_Size = (UInt)DBLength(CodeAbs);
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_Error_Size = (UInt)DBLength(CodeAbs);
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
return NULL;
}
@ -1647,7 +1646,7 @@ record(int Flag, Term key, Term t_data, Term t_code USES_REGS)
int needs_vars;
struct db_globs dbg;
s_dbg = &dbg;
LOCAL_s_dbg = &dbg;
dbg.found_one = NULL;
#ifdef SFUNC
FathersPlace = NIL;
@ -1724,7 +1723,7 @@ record_at(int Flag, DBRef r0, Term t_data, Term t_code USES_REGS)
int needs_vars;
struct db_globs dbg;
s_dbg = &dbg;
LOCAL_s_dbg = &dbg;
#ifdef SFUNC
FathersPlace = NIL;
#endif
@ -1799,6 +1798,7 @@ record_at(int Flag, DBRef r0, Term t_data, Term t_code USES_REGS)
static LogUpdClause *
new_lu_db_entry(Term t, PredEntry *pe)
{
CACHE_REGS
DBTerm *x;
LogUpdClause *cl;
yamop *ipc;
@ -1811,7 +1811,7 @@ new_lu_db_entry(Term t, PredEntry *pe)
if (!(pe->PredFlags & ThreadLocalPredFlag))
d_flag |= InQueue;
#endif
s_dbg = &dbg;
LOCAL_s_dbg = &dbg;
ipc = NEXTOP(((LogUpdClause *)NULL)->ClCode,e);
if ((x = (DBTerm *)CreateDBStruct(t, NULL, d_flag, &needs_vars, (UInt)ipc, &dbg)) == NULL) {
return NULL; /* crash */
@ -1859,9 +1859,9 @@ Yap_new_ludbe(Term t, PredEntry *pe, UInt nargs)
CACHE_REGS
LogUpdClause *x;
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
while ((x = new_lu_db_entry(t, pe)) == NULL) {
if (Yap_Error_TYPE == YAP_NO_ERROR) {
if (LOCAL_Error_TYPE == YAP_NO_ERROR) {
break;
} else {
XREGS[nargs+1] = t;
@ -1951,7 +1951,7 @@ p_rcda( USES_REGS1 )
if (!IsVarTerm(Deref(ARG3)))
return (FALSE);
pe = find_lu_entry(t1);
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
restart_record:
if (pe) {
LogUpdClause *cl;
@ -1973,7 +1973,7 @@ p_rcda( USES_REGS1 )
} else {
TRef = MkDBRefTerm(record(MkFirst, t1, Deref(ARG2), Unsigned(0) PASS_REGS));
}
if (Yap_Error_TYPE != YAP_NO_ERROR) {
if (LOCAL_Error_TYPE != YAP_NO_ERROR) {
if (recover_from_record_error(3)) {
goto restart_record;
} else {
@ -1993,11 +1993,11 @@ p_rcdap( USES_REGS1 )
if (!IsVarTerm(Deref(ARG3)))
return FALSE;
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
restart_record:
TRef = MkDBRefTerm(record(MkFirst | MkCode, t1, t2, Unsigned(0) PASS_REGS));
if (Yap_Error_TYPE != YAP_NO_ERROR) {
if (LOCAL_Error_TYPE != YAP_NO_ERROR) {
if (recover_from_record_error(3)) {
t1 = Deref(ARG1);
t2 = Deref(ARG2);
@ -2027,7 +2027,7 @@ p_rcda_at( USES_REGS1 )
Yap_Error(TYPE_ERROR_DBREF, t1, "recorda_at/3");
return FALSE;
}
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
restart_record:
dbr = DBRefOfTerm(t1);
if (dbr->Flags & ErasedMask) {
@ -2039,7 +2039,7 @@ p_rcda_at( USES_REGS1 )
} else {
TRef = MkDBRefTerm(record_at(MkFirst, DBRefOfTerm(t1), t2, Unsigned(0) PASS_REGS));
}
if (Yap_Error_TYPE != YAP_NO_ERROR) {
if (LOCAL_Error_TYPE != YAP_NO_ERROR) {
if (recover_from_record_error(3)) {
t1 = Deref(ARG1);
t2 = Deref(ARG2);
@ -2061,7 +2061,7 @@ p_rcdz( USES_REGS1 )
if (!IsVarTerm(Deref(ARG3)))
return (FALSE);
pe = find_lu_entry(t1);
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
restart_record:
if (pe) {
LogUpdClause *cl;
@ -2083,7 +2083,7 @@ p_rcdz( USES_REGS1 )
} else {
TRef = MkDBRefTerm(record(MkLast, t1, t2, Unsigned(0) PASS_REGS));
}
if (Yap_Error_TYPE != YAP_NO_ERROR) {
if (LOCAL_Error_TYPE != YAP_NO_ERROR) {
if (recover_from_record_error(3)) {
t1 = Deref(ARG1);
t2 = Deref(ARG2);
@ -2105,14 +2105,14 @@ Yap_Recordz(Atom at, Term t2)
PredEntry *pe;
pe = find_lu_entry(MkAtomTerm(at));
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
restart_record:
if (pe) {
record_lu(pe, t2, MkLast);
} else {
record(MkLast, MkAtomTerm(at), t2, Unsigned(0) PASS_REGS);
}
if (Yap_Error_TYPE != YAP_NO_ERROR) {
if (LOCAL_Error_TYPE != YAP_NO_ERROR) {
ARG1 = t2;
if (recover_from_record_error(1)) {
t2 = ARG1;
@ -2132,10 +2132,10 @@ p_rcdzp( USES_REGS1 )
if (!IsVarTerm(Deref(ARG3)))
return (FALSE);
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
restart_record:
TRef = MkDBRefTerm(record(MkLast | MkCode, t1, t2, Unsigned(0) PASS_REGS));
if (Yap_Error_TYPE != YAP_NO_ERROR) {
if (LOCAL_Error_TYPE != YAP_NO_ERROR) {
if (recover_from_record_error(3)) {
t1 = Deref(ARG1);
t2 = Deref(ARG2);
@ -2165,7 +2165,7 @@ p_rcdz_at( USES_REGS1 )
Yap_Error(TYPE_ERROR_DBREF, t1, "recordz_at/3");
return FALSE;
}
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
restart_record:
dbr = DBRefOfTerm(t1);
if (dbr->Flags & ErasedMask) {
@ -2177,7 +2177,7 @@ p_rcdz_at( USES_REGS1 )
} else {
TRef = MkDBRefTerm(record_at(MkLast, dbr, t2, Unsigned(0) PASS_REGS));
}
if (Yap_Error_TYPE != YAP_NO_ERROR) {
if (LOCAL_Error_TYPE != YAP_NO_ERROR) {
if (recover_from_record_error(3)) {
t1 = Deref(ARG1);
t2 = Deref(ARG2);
@ -2202,13 +2202,13 @@ p_rcdstatp( USES_REGS1 )
if (IsVarTerm(t3) || !IsIntTerm(t3))
return (FALSE);
mk_first = ((IntOfTerm(t3) % 4) == 2);
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
restart_record:
if (mk_first)
TRef = MkDBRefTerm(record(MkFirst | MkCode, t1, t2, MkIntTerm(0) PASS_REGS));
else
TRef = MkDBRefTerm(record(MkLast | MkCode, t1, t2, MkIntTerm(0) PASS_REGS));
if (Yap_Error_TYPE != YAP_NO_ERROR) {
if (LOCAL_Error_TYPE != YAP_NO_ERROR) {
if (recover_from_record_error(4)) {
t1 = Deref(ARG1);
t2 = Deref(ARG2);
@ -2231,11 +2231,11 @@ p_drcdap( USES_REGS1 )
return (FALSE);
if (IsVarTerm(t4) || !IsIntegerTerm(t4))
return (FALSE);
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
restart_record:
TRef = MkDBRefTerm(record(MkFirst | MkCode | WithRef,
t1, t2, t4 PASS_REGS));
if (Yap_Error_TYPE != YAP_NO_ERROR) {
if (LOCAL_Error_TYPE != YAP_NO_ERROR) {
if (recover_from_record_error(4)) {
t1 = Deref(ARG1);
t2 = Deref(ARG2);
@ -2259,10 +2259,10 @@ p_drcdzp( USES_REGS1 )
if (IsVarTerm(t4) || !IsIntegerTerm(t4))
return (FALSE);
restart_record:
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
TRef = MkDBRefTerm(record(MkLast | MkCode | WithRef,
t1, t2, t4 PASS_REGS));
if (Yap_Error_TYPE != YAP_NO_ERROR) {
if (LOCAL_Error_TYPE != YAP_NO_ERROR) {
if (recover_from_record_error(4)) {
t1 = Deref(ARG1);
t2 = Deref(ARG2);
@ -2358,7 +2358,7 @@ copy_attachments(CELL *ts USES_REGS)
while (TRUE) {
/* store away in case there is an overflow */
if (attas[IntegerOfTerm(ts[2])].term_to_op(ts[1], ts[0] PASS_REGS) == FALSE) {
if (GLOBAL_attas[IntegerOfTerm(ts[2])].term_to_op(ts[1], ts[0] PASS_REGS) == FALSE) {
/* oops, we did not have enough space to copy the elements */
/* reset queue of woken up goals */
TR = tr0;
@ -2466,13 +2466,13 @@ GetDBTerm(DBTerm *DBSP USES_REGS)
}
pt = CellPtr(DBSP->Contents);
if (H+NOf > ASP-CalculateStackGap()/sizeof(CELL)) {
if (Yap_PrologMode & InErrorMode) {
if (LOCAL_PrologMode & InErrorMode) {
if (H+NOf > ASP)
fprintf(Yap_stderr, "\n\n [ FATAL ERROR: No Stack for Error Handling ]\n");
fprintf(GLOBAL_stderr, "\n\n [ FATAL ERROR: No Stack for Error Handling ]\n");
Yap_exit( 1);
} else {
Yap_Error_TYPE = OUT_OF_STACK_ERROR;
Yap_Error_Size = NOf*sizeof(CELL);
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
LOCAL_Error_Size = NOf*sizeof(CELL);
return (Term)0;
}
}
@ -2487,8 +2487,8 @@ GetDBTerm(DBTerm *DBSP USES_REGS)
if (DBSP->ag.attachments != 0L) {
if (!copy_attachments((CELL *)AdjustIDBPtr(DBSP->ag.attachments,(CELL)HOld-(CELL)(DBSP->Contents)) PASS_REGS)) {
H = HOld;
Yap_Error_TYPE = OUT_OF_ATTVARS_ERROR;
Yap_Error_Size = 0;
LOCAL_Error_TYPE = OUT_OF_ATTVARS_ERROR;
LOCAL_Error_Size = 0;
return (Term)0;
}
}
@ -2549,9 +2549,9 @@ resize_int_keys(UInt new_size) {
new = (Prop *)Yap_AllocCodeSpace(sizeof(Prop)*new_size);
if (new == NULL) {
YAPLeaveCriticalSection();
Yap_Error_TYPE = OUT_OF_HEAP_ERROR;
Yap_Error_Term = TermNil;
Yap_ErrorMessage = "could not allocate space";
LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR;
LOCAL_Error_Term = TermNil;
LOCAL_ErrorMessage = "could not allocate space";
return FALSE;
}
Yap_LUClauseSpace += sizeof(Prop)*new_size;
@ -2642,9 +2642,9 @@ new_lu_int_key(Int key)
init_int_lu_keys();
if (INT_LU_KEYS == NULL) {
CACHE_REGS
Yap_Error_TYPE = OUT_OF_HEAP_ERROR;
Yap_Error_Term = TermNil;
Yap_ErrorMessage = "could not allocate space";
LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR;
LOCAL_Error_Term = TermNil;
LOCAL_ErrorMessage = "could not allocate space";
return NULL;
}
}
@ -2765,9 +2765,9 @@ FetchIntDBPropFromKey(Int key, int flag, int new, char *error_mssg)
init_int_keys();
if (INT_KEYS == NULL) {
CACHE_REGS
Yap_Error_TYPE = OUT_OF_HEAP_ERROR;
Yap_Error_Term = TermNil;
Yap_ErrorMessage = "could not allocate space";
LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR;
LOCAL_Error_Term = TermNil;
LOCAL_ErrorMessage = "could not allocate space";
return NULL;
}
}
@ -3182,20 +3182,20 @@ i_recorded(DBProp AtProp, Term t3 USES_REGS)
/* make sure the garbage collector sees what we want it to see! */
EXTRA_CBACK_ARG(3,1) = (CELL)ref;
/* oops, we are in trouble, not enough stack space */
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, 3, ENV, CP)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, CP)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
twork = Deref(ARG2);
t3 = Deref(ARG3);
}
@ -3254,16 +3254,16 @@ i_recorded(DBProp AtProp, Term t3 USES_REGS)
EXTRA_CBACK_ARG(3,2) = MkIntegerTerm(((Int)mask));
EXTRA_CBACK_ARG(3,3) = MkIntegerTerm(((Int)key));
/* oops, we are in trouble, not enough stack space */
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, 3, ENV, CP)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, CP)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -3350,20 +3350,20 @@ c_recorded(int flags USES_REGS)
/* make sure the garbage collector sees what we want it to see! */
EXTRA_CBACK_ARG(3,1) = (CELL)ref;
/* oops, we are in trouble, not enough stack space */
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, 3, ENV, CP)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, CP)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
PreviousHeap = H;
}
Yap_unify(ARG2, TermDB);
@ -3393,20 +3393,20 @@ c_recorded(int flags USES_REGS)
/* make sure the garbage collector sees what we want it to see! */
EXTRA_CBACK_ARG(3,1) = (CELL)ref;
/* oops, we are in trouble, not enough stack space */
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, 3, ENV, CP)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, CP)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
PreviousHeap = H;
}
if (Yap_unify(ARG2, TermDB))
@ -3530,16 +3530,16 @@ p_recorded( USES_REGS1 )
Term TermDB;
while ((TermDB = GetDBTermFromDBEntry(ref PASS_REGS)) == (CELL)0) {
/* oops, we are in trouble, not enough stack space */
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, 3, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -3677,16 +3677,16 @@ p_first_instance( USES_REGS1 )
UNLOCK(ref->lock);
while ((TermDB = GetDBTermFromDBEntry(ref PASS_REGS)) == (CELL)0) {
/* oops, we are in trouble, not enough stack space */
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, 3, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -4197,7 +4197,7 @@ MyEraseClause(DynamicClause *clau USES_REGS)
Yap_FreeCodeSpace((char *)clau);
#ifdef DEBUG
if (ref->NOfRefsTo)
fprintf(Yap_stderr, "Error: references to dynamic clause\n");
fprintf(GLOBAL_stderr, "Error: references to dynamic clause\n");
#endif
RemoveDBEntry(ref PASS_REGS);
}
@ -4622,16 +4622,16 @@ static_instance(StaticClause *cl USES_REGS)
while ((TermDB = GetDBTerm(cl->usc.ClSource PASS_REGS)) == 0L) {
/* oops, we are in trouble, not enough stack space */
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -4735,17 +4735,17 @@ p_instance( USES_REGS1 )
Term TermDB;
while ((TermDB = GetDBTerm(cl->ClSource PASS_REGS)) == 0L) {
/* oops, we are in trouble, not enough stack space */
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
UNLOCK(ap->PELock);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
UNLOCK(ap->PELock);
return FALSE;
}
@ -4758,16 +4758,16 @@ p_instance( USES_REGS1 )
Term TermDB;
while ((TermDB = GetDBTermFromDBEntry(dbr PASS_REGS)) == 0L) {
/* oops, we are in trouble, not enough stack space */
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -4790,16 +4790,16 @@ Yap_LUInstance(LogUpdClause *cl, UInt arity)
CACHE_REGS
while ((TermDB = GetDBTerm(cl->ClSource PASS_REGS)) == 0L) {
/* oops, we are in trouble, not enough stack space */
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return 0L;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, arity, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, arity, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return 0L;
}
}
@ -5048,11 +5048,11 @@ StoreTermInDB(Term t, int nargs USES_REGS)
int needs_vars;
struct db_globs dbg;
s_dbg = &dbg;
Yap_Error_Size = 0;
LOCAL_s_dbg = &dbg;
LOCAL_Error_Size = 0;
while ((x = (DBTerm *)CreateDBStruct(t, (DBProp)NULL,
InQueue, &needs_vars, 0, &dbg)) == NULL) {
if (Yap_Error_TYPE == YAP_NO_ERROR) {
if (LOCAL_Error_TYPE == YAP_NO_ERROR) {
break;
} else if (nargs == -1) {
return NULL;
@ -5076,11 +5076,12 @@ Yap_StoreTermInDB(Term t, int nargs) {
DBTerm *
Yap_StoreTermInDBPlusExtraSpace(Term t, UInt extra_size, UInt *sz) {
CACHE_REGS
int needs_vars;
struct db_globs dbg;
DBTerm *o;
s_dbg = &dbg;
LOCAL_s_dbg = &dbg;
o = (DBTerm *)CreateDBStruct(t, (DBProp)NULL,
InQueue, &needs_vars, extra_size, &dbg);
*sz = dbg.sz;
@ -5249,16 +5250,16 @@ p_dequeue( USES_REGS1 )
father_key->FirstInQueue = cur_instance->next;
WRITE_UNLOCK(father_key->QRWLock);
while ((TDB = GetDBTerm(cur_instance->DBT PASS_REGS)) == 0L) {
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -5293,16 +5294,16 @@ p_dequeue_unlocked( USES_REGS1 )
while (cur_instance) {
Term TDB;
while ((TDB = GetDBTerm(cur_instance->DBT PASS_REGS)) == 0L) {
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -5350,16 +5351,16 @@ p_peek_queue( USES_REGS1 )
while (cur_instance) {
Term TDB;
while ((TDB = GetDBTerm(cur_instance->DBT PASS_REGS)) == 0L) {
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}

View File

@ -12,7 +12,7 @@
static struct malloc_chunk *
ChunkPtrAdjust (struct malloc_chunk *ptr)
{
return (struct malloc_chunk *) ((char *) (ptr) + HDiff);
return (struct malloc_chunk *) ((char *) (ptr) + LOCAL_HDiff);
}
@ -212,8 +212,8 @@ yapsbrk(long size)
UNLOCK(HeapTopLock);
Yap_signal(YAP_CDOVF_SIGNAL);
} else {
if (size > Yap_SizeOfOverflow)
Yap_SizeOfOverflow = size;
if (size > GLOBAL_SizeOfOverflow)
GLOBAL_SizeOfOverflow = size;
/* big allocations, the caller must handle the problem */
UNLOCK(HeapUsedLock);
UNLOCK(HeapTopLock);

View File

@ -38,7 +38,7 @@ 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 ONLOCAL(ptr) (CellPtr(ptr) > CellPtr(H) && CellPtr(ptr) < CellPtr(Yap_LocalBase))
#define ONLOCAL(ptr) (CellPtr(ptr) > CellPtr(H) && CellPtr(ptr) < CellPtr(LOCAL_LocalBase))
static int
hidden (Atom at)
@ -118,15 +118,15 @@ DumpActiveGoals ( USES_REGS1 )
fprintf(stderr,"Active ancestors:\n");
if (pe->ModuleOfPred) mod = pe->ModuleOfPred;
Yap_DebugPlWrite (mod);
Yap_DebugPutc (Yap_c_error_stream,':');
Yap_DebugPutc (LOCAL_c_error_stream,':');
if (pe->ArityOfPE == 0) {
Yap_DebugPlWrite (MkAtomTerm ((Atom)f));
} else {
Yap_DebugPlWrite (MkAtomTerm (NameOfFunctor (f)));
Yap_DebugPutc (Yap_c_error_stream,'/');
Yap_DebugPutc (LOCAL_c_error_stream,'/');
Yap_DebugPlWrite (MkIntTerm (ArityOfFunctor (f)));
}
Yap_DebugPutc (Yap_c_error_stream,'\n');
Yap_DebugPutc (LOCAL_c_error_stream,'\n');
} else {
UNLOCK(pe->PELock);
}
@ -152,21 +152,21 @@ DumpActiveGoals ( USES_REGS1 )
mod = pe->ModuleOfPred;
else mod = TermProlog;
Yap_DebugPlWrite (mod);
Yap_DebugPutc (Yap_c_error_stream,':');
Yap_DebugPutc (LOCAL_c_error_stream,':');
if (pe->ArityOfPE == 0) {
Yap_DebugPlWrite (MkAtomTerm (NameOfFunctor(f)));
} else {
Int i = 0, arity = pe->ArityOfPE;
Term *args = &(b_ptr->cp_a1);
Yap_DebugPlWrite (MkAtomTerm (NameOfFunctor (f)));
Yap_DebugPutc (Yap_c_error_stream,'(');
Yap_DebugPutc (LOCAL_c_error_stream,'(');
for (i= 0; i < arity; i++) {
if (i > 0) Yap_DebugPutc (Yap_c_error_stream,',');
if (i > 0) Yap_DebugPutc (LOCAL_c_error_stream,',');
Yap_DebugPlWrite(args[i]);
}
Yap_DebugPutc (Yap_c_error_stream,')');
Yap_DebugPutc (LOCAL_c_error_stream,')');
}
Yap_DebugPutc (Yap_c_error_stream,'\n');
Yap_DebugPutc (LOCAL_c_error_stream,'\n');
}
UNLOCK(pe->PELock);
b_ptr = b_ptr->cp_b;
@ -264,14 +264,14 @@ dump_stack( USES_REGS1 )
return;
#if DEBUG
fprintf(stderr,"%% YAP regs: P=%p, CP=%p, ASP=%p, H=%p, TR=%p, HeapTop=%p\n",P,CP,ASP,H,TR,HeapTop);
fprintf(stderr,"%% YAP mode: %ux\n",(unsigned int)Yap_PrologMode);
if (Yap_ErrorMessage)
fprintf(stderr,"%% YAP_ErrorMessage: %s\n",Yap_ErrorMessage);
fprintf(stderr,"%% YAP mode: %ux\n",(unsigned int)LOCAL_PrologMode);
if (LOCAL_ErrorMessage)
fprintf(stderr,"%% LOCAL_ErrorMessage: %s\n",LOCAL_ErrorMessage);
#endif
if (H > ASP || H > LCL0) {
fprintf(stderr,"%% YAP ERROR: Global Collided against Local (%p--%p)\n",H,ASP);
} else if (HeapTop > (ADDR)Yap_GlobalBase) {
fprintf(stderr,"%% YAP ERROR: Code Space Collided against Global (%p--%p)\n", HeapTop, Yap_GlobalBase);
} else if (HeapTop > (ADDR)LOCAL_GlobalBase) {
fprintf(stderr,"%% YAP ERROR: Code Space Collided against Global (%p--%p)\n", HeapTop, LOCAL_GlobalBase);
} else {
#if !USE_SYSTEM_MALLOC
fprintf (stderr,"%ldKB of Code Space (%p--%p)\n",(long int)((CELL)HeapTop-(CELL)Yap_HeapBase)/1024,Yap_HeapBase,HeapTop);
@ -292,8 +292,8 @@ dump_stack( USES_REGS1 )
fprintf (stderr,"%% Continuation: %s\n",(char *)H);
fprintf (stderr,"%% %luKB of Global Stack (%p--%p)\n",(unsigned long int)(sizeof(CELL)*(H-H0))/1024,H0,H);
fprintf (stderr,"%% %luKB of Local Stack (%p--%p)\n",(unsigned long int)(sizeof(CELL)*(LCL0-ASP))/1024,ASP,LCL0);
fprintf (stderr,"%% %luKB of Trail (%p--%p)\n",(unsigned long int)((ADDR)TR-Yap_TrailBase)/1024,Yap_TrailBase,TR);
fprintf (stderr,"%% Performed %ld garbage collections\n", (unsigned long int)GcCalls);
fprintf (stderr,"%% %luKB of Trail (%p--%p)\n",(unsigned long int)((ADDR)TR-LOCAL_TrailBase)/1024,LOCAL_TrailBase,TR);
fprintf (stderr,"%% Performed %ld garbage collections\n", (unsigned long int)LOCAL_GcCalls);
#if LOW_LEVEL_TRACER
{
extern long long vsc_count;
@ -352,7 +352,7 @@ static void
error_exit_yap (int value)
{
CACHE_REGS
if (!(Yap_PrologMode & BootMode)) {
if (!(LOCAL_PrologMode & BootMode)) {
dump_stack( PASS_REGS1 );
#if DEBUG
#endif
@ -391,14 +391,14 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
char *tp = tmpbuf;
int psize = YAP_BUF_SIZE;
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (where == 0L)
where = TermNil;
#if DEBUG_STRICT
if (Yap_heap_regs && !(Yap_PrologMode & BootMode))
fprintf(stderr,"***** Processing Error %d (%lx,%x) %s***\n", type, (unsigned long int)ActiveSignals,Yap_PrologMode,format);
if (Yap_heap_regs && !(LOCAL_PrologMode & BootMode))
fprintf(stderr,"***** Processing Error %d (%lx,%x) %s***\n", type, (unsigned long int)LOCAL_ActiveSignals,LOCAL_PrologMode,format);
else
fprintf(stderr,"***** Processing Error %d (%x) %s***\n", type,Yap_PrologMode,format);
fprintf(stderr,"***** Processing Error %d (%x) %s***\n", type,LOCAL_PrologMode,format);
#endif
if (type == INTERRUPT_ERROR) {
fprintf(stderr,"%% YAP exiting: cannot handle signal %d\n",
@ -406,7 +406,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
Yap_exit(1);
}
/* disallow recursive error handling */
if (Yap_PrologMode & InErrorMode) {
if (LOCAL_PrologMode & InErrorMode) {
/* error within error */
va_start (ap, format);
/* now build the error string */
@ -444,7 +444,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
} else {
tmpbuf[0] = '\0';
}
if (Yap_PrologMode == UserCCallMode) {
if (LOCAL_PrologMode == UserCCallMode) {
fprintf(stderr,"%%\n%%\n");
fprintf(stderr,"%% YAP OOOPS in USER C-CODE: %s.\n",tmpbuf);
fprintf(stderr,"%%\n%%\n");
@ -458,12 +458,12 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
if (P == (yamop *)(FAILCODE))
return P;
/* PURE_ABORT may not have set where correctly, BootMode may not have the data terms ready */
if (type == PURE_ABORT || Yap_PrologMode & BootMode) {
if (type == PURE_ABORT || LOCAL_PrologMode & BootMode) {
where = TermNil;
Yap_PrologMode &= ~AbortMode;
Yap_PrologMode |= InErrorMode;
LOCAL_PrologMode &= ~AbortMode;
LOCAL_PrologMode |= InErrorMode;
/* make sure failure will be seen at next port */
if (Yap_PrologMode & AsyncIntMode)
if (LOCAL_PrologMode & AsyncIntMode)
Yap_signal(YAP_FAIL_SIGNAL);
P = FAILCODE;
} else {
@ -474,8 +474,8 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
where = Deref(where);
}
/* Exit Abort Mode, if we were there */
Yap_PrologMode &= ~AbortMode;
Yap_PrologMode |= InErrorMode;
LOCAL_PrologMode &= ~AbortMode;
LOCAL_PrologMode |= InErrorMode;
if (!(where = Yap_CopyTerm(where))) {
where = TermNil;
}
@ -493,7 +493,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
else
tmpbuf[0] = '\0';
va_end (ap);
if (Yap_PrologMode & BootMode) {
if (LOCAL_PrologMode & BootMode) {
/* crash in flames! */
fprintf(stderr,"%% YAP Fatal Error: %s exiting....\n",tmpbuf);
error_exit_yap (1);
@ -506,7 +506,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
{
fprintf(stderr,"%% Internal YAP Error: %s exiting....\n",tmpbuf);
serious = TRUE;
if (Yap_PrologMode & BootMode) {
if (LOCAL_PrologMode & BootMode) {
fprintf(stderr,"%% YAP crashed while booting %s\n",tmpbuf);
} else {
detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, tmpbuf, YAP_BUF_SIZE);
@ -530,30 +530,30 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
break;
case CALL_COUNTER_UNDERFLOW:
/* Do a long jump */
ReductionsCounterOn = FALSE;
PredEntriesCounterOn = FALSE;
RetriesCounterOn = FALSE;
LOCAL_ReductionsCounterOn = FALSE;
LOCAL_PredEntriesCounterOn = FALSE;
LOCAL_RetriesCounterOn = FALSE;
Yap_JumpToEnv(MkAtomTerm(AtomCallCounter));
P = (yamop *)FAILCODE;
Yap_PrologMode &= ~InErrorMode;
LOCAL_PrologMode &= ~InErrorMode;
return(P);
case PRED_ENTRY_COUNTER_UNDERFLOW:
/* Do a long jump */
ReductionsCounterOn = FALSE;
PredEntriesCounterOn = FALSE;
RetriesCounterOn = FALSE;
LOCAL_ReductionsCounterOn = FALSE;
LOCAL_PredEntriesCounterOn = FALSE;
LOCAL_RetriesCounterOn = FALSE;
Yap_JumpToEnv(MkAtomTerm(AtomCallAndRetryCounter));
P = (yamop *)FAILCODE;
Yap_PrologMode &= ~InErrorMode;
LOCAL_PrologMode &= ~InErrorMode;
return(P);
case RETRY_COUNTER_UNDERFLOW:
/* Do a long jump */
ReductionsCounterOn = FALSE;
PredEntriesCounterOn = FALSE;
RetriesCounterOn = FALSE;
LOCAL_ReductionsCounterOn = FALSE;
LOCAL_PredEntriesCounterOn = FALSE;
LOCAL_RetriesCounterOn = FALSE;
Yap_JumpToEnv(MkAtomTerm(AtomRetryCounter));
P = (yamop *)FAILCODE;
Yap_PrologMode &= ~InErrorMode;
LOCAL_PrologMode &= ~InErrorMode;
return(P);
case CONSISTENCY_ERROR:
{
@ -1831,13 +1831,13 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
if (type != PURE_ABORT) {
/* This is used by some complex procedures to detect there was an error */
if (IsAtomTerm(nt[0])) {
strncpy(Yap_ErrorSay, RepAtom(AtomOfTerm(nt[0]))->StrOfAE, MAX_ERROR_MSG_SIZ\
strncpy(LOCAL_ErrorSay, RepAtom(AtomOfTerm(nt[0]))->StrOfAE, MAX_ERROR_MSG_SIZ\
E);
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
} else {
strncpy(Yap_ErrorSay, RepAtom(NameOfFunctor(FunctorOfTerm(nt[0])))->StrOfAE,\
strncpy(LOCAL_ErrorSay, RepAtom(NameOfFunctor(FunctorOfTerm(nt[0])))->StrOfAE,\
MAX_ERROR_MSG_SIZE);
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
}
}
switch (type) {
@ -1852,35 +1852,35 @@ E);
if ((stack_dump = Yap_all_calls()) == 0L) {
stack_dump = TermNil;
Yap_Error_Size = 0L;
LOCAL_Error_Size = 0L;
}
nt[1] = MkPairTerm(MkAtomTerm(Yap_LookupAtom(tmpbuf)), stack_dump);
}
}
if (serious) {
/* disable active signals at this point */
ActiveSignals = 0;
LOCAL_ActiveSignals = 0;
CreepFlag = CalculateStackGap();
Yap_PrologMode &= ~InErrorMode;
LOCK(SignalLock);
LOCAL_PrologMode &= ~InErrorMode;
LOCK(LOCAL_SignalLock);
/* we might be in the middle of a critical region */
if (Yap_InterruptsDisabled) {
Yap_InterruptsDisabled = 0;
UncaughtThrow = TRUE;
UNLOCK(SignalLock);
if (LOCAL_InterruptsDisabled) {
LOCAL_InterruptsDisabled = 0;
LOCAL_UncaughtThrow = TRUE;
UNLOCK(LOCAL_SignalLock);
#if PUSH_REGS
restore_absmi_regs(&Yap_standard_regs);
#endif
siglongjmp(Yap_RestartEnv,1);
siglongjmp(LOCAL_RestartEnv,1);
}
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
/* wait if we we are in user code,
it's up to her to decide */
if (Yap_PrologMode & UserCCallMode) {
if (LOCAL_PrologMode & UserCCallMode) {
if (!(EX = Yap_StoreTermInDB(Yap_MkApplTerm(fun, 2, nt), 0))) {
/* fat chance */
siglongjmp(Yap_RestartEnv,1);
siglongjmp(LOCAL_RestartEnv,1);
}
} else {
if (type == PURE_ABORT) {
@ -1890,7 +1890,7 @@ E);
P = (yamop *)FAILCODE;
}
} else {
Yap_PrologMode &= ~InErrorMode;
LOCAL_PrologMode &= ~InErrorMode;
}
return P;
}

View File

@ -34,13 +34,13 @@ static char SccsId[] = "%W% %G%";
#include <unistd.h>
#endif
yap_error_number Yap_matherror = YAP_NO_ERROR;
static Term
Eval(Term t USES_REGS)
{
if (IsVarTerm(t)) {
ArithError = TRUE;
LOCAL_ArithError = TRUE;
return Yap_ArithError(INSTANTIATION_ERROR,t,"in arithmetic");
} else if (IsNumTerm(t)) {
return t;
@ -131,14 +131,14 @@ p_is( USES_REGS1 )
Term out = 0L;
while (!(out = Eval(Deref(ARG2) PASS_REGS))) {
if (Yap_Error_TYPE == RESOURCE_ERROR_STACK) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, 2, ENV, CP)) {
Yap_Error(RESOURCE_ERROR_STACK, ARG2, Yap_ErrorMessage);
if (LOCAL_Error_TYPE == RESOURCE_ERROR_STACK) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, CP)) {
Yap_Error(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage);
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -151,20 +151,20 @@ Yap_ArithError(yap_error_number type, Term where, char *format,...)
CACHE_REGS
va_list ap;
ArithError = TRUE;
Yap_Error_TYPE = type;
Yap_Error_Term = where;
if (!Yap_ErrorMessage)
Yap_ErrorMessage = Yap_ErrorSay;
LOCAL_ArithError = TRUE;
LOCAL_Error_TYPE = type;
LOCAL_Error_Term = where;
if (!LOCAL_ErrorMessage)
LOCAL_ErrorMessage = LOCAL_ErrorSay;
va_start (ap, format);
if (format != NULL) {
#if HAVE_VSNPRINTF
(void) vsnprintf(Yap_ErrorMessage, MAX_ERROR_MSG_SIZE, format, ap);
(void) vsnprintf(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, format, ap);
#else
(void) vsprintf(Yap_ErrorMessage, format, ap);
(void) vsprintf(LOCAL_ErrorMessage, format, ap);
#endif
} else {
Yap_ErrorMessage[0] = '\0';
LOCAL_ErrorMessage[0] = '\0';
}
va_end (ap);
return 0L;

View File

View File

171
C/exec.c
View File

@ -160,15 +160,15 @@ do_execute(Term t, Term mod USES_REGS)
/* first do predicate expansion, even before you process signals.
This way you don't get to spy goal_expansion(). */
if (PRED_GOAL_EXPANSION_ALL) {
LOCK(SignalLock);
LOCK(LOCAL_SignalLock);
/* disable creeping when we do goal expansion */
if (ActiveSignals & YAP_CREEP_SIGNAL && !Yap_InterruptsDisabled) {
ActiveSignals &= ~YAP_CREEP_SIGNAL;
if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL && !LOCAL_InterruptsDisabled) {
LOCAL_ActiveSignals &= ~YAP_CREEP_SIGNAL;
CreepFlag = CalculateStackGap();
}
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return CallMetaCall(mod PASS_REGS);
} else if (ActiveSignals && !Yap_InterruptsDisabled) {
} else if (LOCAL_ActiveSignals && !LOCAL_InterruptsDisabled) {
return EnterCreepMode(t, mod PASS_REGS);
}
restart_exec:
@ -331,16 +331,16 @@ do_execute_n(Term t, Term mod, unsigned int n USES_REGS)
return CallError(TYPE_ERROR_CALLABLE, mod PASS_REGS);
}
if (PRED_GOAL_EXPANSION_ALL) {
LOCK(SignalLock);
LOCK(LOCAL_SignalLock);
/* disable creeping when we do goal expansion */
if (ActiveSignals & YAP_CREEP_SIGNAL && !Yap_InterruptsDisabled) {
ActiveSignals &= ~YAP_CREEP_SIGNAL;
if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL && !LOCAL_InterruptsDisabled) {
LOCAL_ActiveSignals &= ~YAP_CREEP_SIGNAL;
CreepFlag = CalculateStackGap();
}
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
ARG1 = copy_execn_to_heap(f, pt, n, arity, mod PASS_REGS);
return CallMetaCall(mod PASS_REGS);
} else if (ActiveSignals && !Yap_InterruptsDisabled) {
} else if (LOCAL_ActiveSignals && !LOCAL_InterruptsDisabled) {
return EnterCreepMode(copy_execn_to_heap(f, pt, n, arity, CurrentModule PASS_REGS), mod PASS_REGS);
}
if (arity > MaxTemps) {
@ -378,12 +378,12 @@ static Int
EnterCreepMode(Term t, Term mod USES_REGS) {
PredEntry *PredCreep;
if (ActiveSignals & YAP_CDOVF_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_CDOVF_SIGNAL) {
ARG1 = t;
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap at meta-call");
}
if (!ActiveSignals) {
if (!LOCAL_ActiveSignals) {
return do_execute(ARG1, mod PASS_REGS);
}
}
@ -394,9 +394,9 @@ EnterCreepMode(Term t, Term mod USES_REGS) {
} else {
ARG1 = MkPairTerm(TermProlog,t);
}
LOCK(SignalLock);
LOCK(LOCAL_SignalLock);
CreepFlag = CalculateStackGap();
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
P_before_spy = P;
return CallPredicate(PredCreep, B, PredCreep->CodeOfPred PASS_REGS);
}
@ -631,7 +631,7 @@ p_execute_clause( USES_REGS1 )
} else {
code = Yap_ClauseFromTerm(clt)->ClCode;
}
if (ActiveSignals & YAP_CREEP_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL) {
Yap_signal(YAP_CREEP_SIGNAL);
}
return CallPredicate(RepPredProp(pe), cut_cp, code PASS_REGS);
@ -651,7 +651,7 @@ p_execute0( USES_REGS1 )
unsigned int arity;
Prop pe;
if (ActiveSignals && !Yap_InterruptsDisabled) {
if (LOCAL_ActiveSignals && !LOCAL_InterruptsDisabled) {
return EnterCreepMode(t, mod PASS_REGS);
}
restart_exec:
@ -781,7 +781,7 @@ p_execute_nonstop( USES_REGS1 )
/* N = arity; */
/* call may not define new system predicates!! */
if (RepPredProp(pe)->PredFlags & SpiedPredFlag) {
if (ActiveSignals & YAP_CREEP_SIGNAL && !Yap_InterruptsDisabled) {
if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL && !LOCAL_InterruptsDisabled) {
Yap_signal(YAP_CREEP_SIGNAL);
}
#if defined(YAPOR) || defined(THREADS)
@ -791,8 +791,8 @@ p_execute_nonstop( USES_REGS1 )
}
#endif
return CallPredicate(RepPredProp(pe), B, RepPredProp(pe)->cs.p_code.TrueCodeOfPred PASS_REGS);
} else { if (ActiveSignals & YAP_CREEP_SIGNAL &&
!Yap_InterruptsDisabled &&
} else { if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL &&
!LOCAL_InterruptsDisabled &&
(!(RepPredProp(pe)->PredFlags & (AsmPredFlag|CPredFlag)) ||
RepPredProp(pe)->OpcodeOfPred == Yap_opcode(_call_bfunc_xx))) {
Yap_signal(YAP_CREEP_SIGNAL);
@ -946,12 +946,12 @@ exec_absmi(int top USES_REGS)
{
int lval, out;
if (top && (lval = sigsetjmp (Yap_RestartEnv, 1)) != 0) {
if (top && (lval = sigsetjmp (LOCAL_RestartEnv, 1)) != 0) {
switch(lval) {
case 1:
{ /* restart */
/* otherwise, SetDBForThrow will fail entering critical mode */
Yap_PrologMode = UserMode;
LOCAL_PrologMode = UserMode;
/* find out where to cut to */
/* siglongjmp resets the TR hardware register */
/* TR and B are crucial, they might have been changed, or not */
@ -962,12 +962,12 @@ exec_absmi(int top USES_REGS)
/* set stack */
ASP = (CELL *)PROTECT_FROZEN_B(B);
Yap_StartSlots( PASS_REGS1 );
LOCK(SignalLock);
LOCK(LOCAL_SignalLock);
/* forget any signals active, we're reborne */
ActiveSignals = 0;
LOCAL_ActiveSignals = 0;
CreepFlag = CalculateStackGap();
Yap_PrologMode = UserMode;
UNLOCK(SignalLock);
LOCAL_PrologMode = UserMode;
UNLOCK(LOCAL_SignalLock);
P = (yamop *)FAILCODE;
}
break;
@ -975,11 +975,11 @@ exec_absmi(int top USES_REGS)
{
/* arithmetic exception */
/* must be done here, otherwise siglongjmp will clobber all the registers */
Yap_Error(Yap_matherror,TermNil,NULL);
Yap_Error(LOCAL_matherror ,TermNil,NULL);
/* reset the registers so that we don't have trash in abstract machine */
Yap_set_fpu_exceptions(yap_flags[LANGUAGE_MODE_FLAG] == 1);
P = (yamop *)FAILCODE;
Yap_PrologMode = UserMode;
LOCAL_PrologMode = UserMode;
}
break;
case 3:
@ -988,10 +988,10 @@ exec_absmi(int top USES_REGS)
}
default:
/* do nothing */
Yap_PrologMode = UserMode;
LOCAL_PrologMode = UserMode;
}
} else {
Yap_PrologMode = UserMode;
LOCAL_PrologMode = UserMode;
}
Yap_CloseSlots( PASS_REGS1 );
YENV = ASP;
@ -999,8 +999,8 @@ exec_absmi(int top USES_REGS)
out = Yap_absmi(0);
Yap_StartSlots( PASS_REGS1 );
/* make sure we don't leave a FAIL signal hanging around */
ActiveSignals &= ~YAP_FAIL_SIGNAL;
if (!ActiveSignals)
LOCAL_ActiveSignals &= ~YAP_FAIL_SIGNAL;
if (!LOCAL_ActiveSignals)
CreepFlag = CalculateStackGap();
return out;
}
@ -1048,9 +1048,6 @@ init_stack(int arity, CELL *pt, int top, choiceptr saved_b USES_REGS)
#endif /* DEPTH_LIMIT */
YENV = ASP = (CELL *)B;
HB = H;
#if defined(YAPOR) || defined(THREADS)
WPP = NULL;
#endif
/* start with some slots so that we can use them */
Yap_StartSlots( PASS_REGS1 );
CP = YESCODE;
@ -1282,8 +1279,8 @@ Yap_RunTopGoal(Term t)
CodeAdr = ppe->CodeOfPred;
UNLOCK(ppe->PELock);
#if !USE_SYSTEM_MALLOC
if (Yap_TrailTop - HeapTop < 2048) {
Yap_PrologMode = BootMode;
if (LOCAL_TrailTop - HeapTop < 2048) {
LOCAL_PrologMode = BootMode;
Yap_Error(OUT_OF_TRAIL_ERROR,TermNil,
"unable to boot because of too little Trail space");
}
@ -1475,9 +1472,9 @@ JumpToEnv(Term t USES_REGS) {
if (EX)
return FALSE;
/* just keep the throwed object away, we don't need to care about it */
if (!(BallTerm = Yap_StoreTermInDB(t, 0))) {
if (!(LOCAL_BallTerm = Yap_StoreTermInDB(t, 0))) {
/* fat chance */
siglongjmp(Yap_RestartEnv,1);
siglongjmp(LOCAL_RestartEnv,1);
}
/* careful, previous step may have caused a stack shift,
so get pointers here */
@ -1509,16 +1506,16 @@ JumpToEnv(Term t USES_REGS) {
/* we reached C-Code */
if (handler->cp_ap == NOCODE) {
/* up to the C-code to deal with this! */
UncaughtThrow = TRUE;
LOCAL_UncaughtThrow = TRUE;
if (previous == NULL)
B = handler;
else
previous->cp_b = handler;
EX = BallTerm;
BallTerm = NULL;
EX = LOCAL_BallTerm;
LOCAL_BallTerm = NULL;
P = (yamop *)FAILCODE;
/* make sure failure will be seen at next port */
if (Yap_PrologMode & AsyncIntMode) {
if (LOCAL_PrologMode & AsyncIntMode) {
Yap_signal(YAP_FAIL_SIGNAL);
}
HB = B->cp_h;
@ -1528,11 +1525,11 @@ JumpToEnv(Term t USES_REGS) {
}
/* uncaught throw */
if (handler == NULL) {
UncaughtThrow = TRUE;
LOCAL_UncaughtThrow = TRUE;
#if PUSH_REGS
restore_absmi_regs(&Yap_standard_regs);
#endif
siglongjmp(Yap_RestartEnv,1);
siglongjmp(LOCAL_RestartEnv,1);
}
/* is it a continuation? */
env = handler->cp_env;
@ -1563,7 +1560,7 @@ JumpToEnv(Term t USES_REGS) {
/* B->cp_h = H; */
/* I could backtrack here, but it is easier to leave the unwinding
to the emulator */
if (Yap_PrologMode & AsyncIntMode) {
if (LOCAL_PrologMode & AsyncIntMode) {
Yap_signal(YAP_FAIL_SIGNAL);
}
P = (yamop *)FAILCODE;
@ -1578,7 +1575,7 @@ JumpToEnv(Term t USES_REGS) {
Int
Yap_JumpToEnv(Term t) {
CACHE_REGS
if (Yap_PrologMode & BootMode) {
if (LOCAL_PrologMode & BootMode) {
return FALSE;
}
return JumpToEnv(t PASS_REGS);
@ -1605,27 +1602,26 @@ Yap_InitYaamRegs(void)
{
CACHE_REGS
Term h0var;
#if PUSH_REGS
/* Guarantee that after a longjmp we go back to the original abstract
machine registers */
#ifdef THREADS
int myworker_id = worker_id;
pthread_setspecific(Yap_yaamregs_key, (const void *)FOREIGN_ThreadHandle(myworker_id).default_yaam_regs);
FOREIGN_ThreadHandle(myworker_id).current_yaam_regs = FOREIGN_ThreadHandle(myworker_id).default_yaam_regs;
worker_id = myworker_id;
pthread_setspecific(Yap_yaamregs_key, (const void *)REMOTE_ThreadHandle(myworker_id).default_yaam_regs);
REMOTE_ThreadHandle(myworker_id).current_yaam_regs = REMOTE_ThreadHandle(myworker_id).default_yaam_regs;
worker_id = myworker_id; /* ricroc: for what I understand, this shouldn't be necessary */
#else
Yap_regp = &Yap_standard_regs;
#endif
#endif /* PUSH_REGS */
Yap_ResetExceptionTerm ();
Yap_PutValue (AtomBreak, MkIntTerm (0));
TR = (tr_fr_ptr)Yap_TrailBase;
if (Yap_AttsSize > (Yap_LocalBase-Yap_GlobalBase)/8)
Yap_AttsSize = (Yap_LocalBase-Yap_GlobalBase)/8;
H = H0 = ((CELL *) Yap_GlobalBase)+ Yap_AttsSize/sizeof(CELL);
TR = (tr_fr_ptr)LOCAL_TrailBase;
if (Yap_AttsSize > (LOCAL_LocalBase-LOCAL_GlobalBase)/8)
Yap_AttsSize = (LOCAL_LocalBase-LOCAL_GlobalBase)/8;
H = H0 = ((CELL *) LOCAL_GlobalBase)+ Yap_AttsSize/sizeof(CELL);
RESET_VARIABLE(H0-1);
LCL0 = ASP = (CELL *) Yap_LocalBase;
LCL0 = ASP = (CELL *) LOCAL_LocalBase;
/* notice that an initial choice-point and environment
*must* be created since for the garbage collector to work */
B = NULL;
@ -1640,29 +1636,28 @@ Yap_InitYaamRegs(void)
#ifdef YAPOR_SBA
BSEG =
#endif /* YAPOR_SBA */
BBREG = B_FZ = (choiceptr) Yap_LocalBase;
TR = TR_FZ = (tr_fr_ptr) Yap_TrailBase;
BBREG = B_FZ = (choiceptr) LOCAL_LocalBase;
TR = TR_FZ = (tr_fr_ptr) LOCAL_TrailBase;
#endif /* FROZEN_STACKS */
LOCK(SignalLock);
LOCK(LOCAL_SignalLock);
CreepFlag = CalculateStackGap();
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
EX = NULL;
init_stack(0, NULL, TRUE, NULL PASS_REGS);
/* the first real choice-point will also have AP=FAIL */
/* always have an empty slots for people to use */
CurSlot = 0;
GlobalArena = TermNil;
LOCAL_GlobalArena = TermNil;
h0var = MkVarTerm();
#if COROUTINING
WokenGoals = Yap_NewTimedVar(TermNil);
AttsMutableList = Yap_NewTimedVar(h0var);
LOCAL_WokenGoals = Yap_NewTimedVar(TermNil);
LOCAL_AttsMutableList = Yap_NewTimedVar(h0var);
#endif
GcGeneration = Yap_NewTimedVar(h0var);
GcCurrentPhase = 0L;
GcPhase = Yap_NewTimedVar(MkIntTerm(GcCurrentPhase));
LOCAL_GcGeneration = Yap_NewTimedVar(h0var);
LOCAL_GcCurrentPhase = 0L;
LOCAL_GcPhase = Yap_NewTimedVar(MkIntTerm(LOCAL_GcCurrentPhase));
#if defined(YAPOR) || defined(THREADS)
PP = NULL;
WPP = NULL;
PREG_ADDR = NULL;
#endif
Yap_AllocateDefaultArena(128*1024, 2);
@ -1678,8 +1673,8 @@ Yap_InitYaamRegs(void)
static Int
p_uncaught_throw( USES_REGS1 )
{
Int out = UncaughtThrow;
UncaughtThrow = FALSE; /* just caught it */
Int out = LOCAL_UncaughtThrow;
LOCAL_UncaughtThrow = FALSE; /* just caught it */
return out;
}
@ -1687,14 +1682,14 @@ static Int
p_creep_allowed( USES_REGS1 )
{
if (PP != NULL) {
LOCK(SignalLock);
if (ActiveSignals & YAP_CREEP_SIGNAL && !Yap_InterruptsDisabled) {
ActiveSignals &= ~YAP_CREEP_SIGNAL;
if (!ActiveSignals)
LOCK(LOCAL_SignalLock);
if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL && !LOCAL_InterruptsDisabled) {
LOCAL_ActiveSignals &= ~YAP_CREEP_SIGNAL;
if (!LOCAL_ActiveSignals)
CreepFlag = CalculateStackGap();
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
} else {
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
}
return TRUE;
}
@ -1706,15 +1701,15 @@ p_debug_on( USES_REGS1 )
{
Term t = Deref(ARG1);
if (IsVarTerm(t)) {
if (DebugOn)
if (LOCAL_DebugOn)
return Yap_unify(MkAtomTerm(AtomTrue),ARG1);
else
return Yap_unify(MkAtomTerm(AtomFalse),ARG1);
}
if (t == MkAtomTerm(AtomTrue))
DebugOn = TRUE;
LOCAL_DebugOn = TRUE;
else
DebugOn = FALSE;
LOCAL_DebugOn = FALSE;
return TRUE;
}
@ -1723,26 +1718,26 @@ Yap_GetException(void)
{
CACHE_REGS
Term t = 0L;
if (BallTerm) {
if (LOCAL_BallTerm) {
do {
t = Yap_PopTermFromDB(BallTerm);
t = Yap_PopTermFromDB(LOCAL_BallTerm);
if (t == 0) {
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growstack(BallTerm->NOfCells*CellSize)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growstack(LOCAL_BallTerm->NOfCells*CellSize)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
}
} while (t == 0);
BallTerm = NULL;
LOCAL_BallTerm = NULL;
}
return t;
}
@ -1762,8 +1757,8 @@ void
Yap_ResetExceptionTerm(void)
{
CACHE_REGS
Yap_ReleaseTermFromDB(BallTerm);
BallTerm = NULL;
Yap_ReleaseTermFromDB(LOCAL_BallTerm);
LOCAL_BallTerm = NULL;
}
static Int

View File

@ -111,7 +111,7 @@ NewArena(UInt size, UInt arity, CELL *where USES_REGS)
if (where == NULL || where == H) {
while (H+size > ASP-1024) {
if (!Yap_gcl(size*sizeof(CELL), arity, ENV, P)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return TermNil;
}
}
@ -146,7 +146,7 @@ p_allocate_arena( USES_REGS1 )
static Int
p_default_arena_size( USES_REGS1 )
{
return Yap_unify(ARG1,MkIntegerTerm(ArenaSz(GlobalArena)));
return Yap_unify(ARG1,MkIntegerTerm(ArenaSz(LOCAL_GlobalArena)));
}
@ -154,7 +154,7 @@ void
Yap_AllocateDefaultArena(Int gsize, Int attsize)
{
CACHE_REGS
GlobalArena = NewArena(gsize, 2, NULL PASS_REGS);
LOCAL_GlobalArena = NewArena(gsize, 2, NULL PASS_REGS);
}
static void
@ -172,7 +172,7 @@ adjust_cps(UInt size USES_REGS)
static int
GrowArena(Term arena, CELL *pt, UInt old_size, UInt size, UInt arity USES_REGS)
{
ArenaOverflows++;
LOCAL_ArenaOverflows++;
if (size == 0) {
if (old_size < 128*1024) {
size = old_size;
@ -188,7 +188,7 @@ GrowArena(Term arena, CELL *pt, UInt old_size, UInt size, UInt arity USES_REGS)
XREGS[arity+1] = arena;
if (!Yap_gcl(size*sizeof(CELL), arity+1, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
arena = XREGS[arity+1];
@ -201,9 +201,9 @@ GrowArena(Term arena, CELL *pt, UInt old_size, UInt size, UInt arity USES_REGS)
} else {
XREGS[arity+1] = arena;
/* try to recover some room */
if (arena == GlobalArena && 10*(pt-H0) > 8*(H-H0)) {
if (arena == LOCAL_GlobalArena && 10*(pt-H0) > 8*(H-H0)) {
if (!Yap_gcl(size*sizeof(CELL), arity+1, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR,TermNil,LOCAL_ErrorMessage);
return FALSE;
}
}
@ -474,12 +474,12 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
CELL new;
bp = to_visit;
if (!attas[ExtFromCell(ptd0)].copy_term_op(ptd0, &bp, ptf PASS_REGS)) {
if (!GLOBAL_attas[ExtFromCell(ptd0)].copy_term_op(ptd0, &bp, ptf PASS_REGS)) {
goto overflow;
}
to_visit = bp;
new = *ptf;
if (TR > (tr_fr_ptr)Yap_TrailTop - 256) {
if (TR > (tr_fr_ptr)LOCAL_TrailTop - 256) {
/* Trail overflow */
if (!Yap_growtrail((TR-TR0)*sizeof(tr_fr_ptr *), TRUE)) {
goto trail_overflow;
@ -491,7 +491,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
#endif
/* first time we met this term */
RESET_VARIABLE(ptf);
if ((ADDR)TR > Yap_TrailTop-MIN_ARENA_SIZE)
if ((ADDR)TR > LOCAL_TrailTop-MIN_ARENA_SIZE)
goto trail_overflow;
Bind_and_Trail(ptd0, (CELL)ptf);
ptf++;
@ -720,16 +720,16 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
HB = oldHB;
switch (res) {
case -1:
if (arena == GlobalArena)
GlobalArenaOverflows++;
if (arena == LOCAL_GlobalArena)
LOCAL_GlobalArenaOverflows++;
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, LOCAL_ErrorMessage);
return 0L;
}
break;
default: /* temporary space overflow */
if (!Yap_ExpandPreAllocCodeSpace(0,NULL,TRUE)) {
Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, LOCAL_ErrorMessage);
return 0L;
}
}
@ -774,8 +774,8 @@ CreateTermInArena(Term arena, Atom Na, UInt Nar, UInt arity, Term *newarena, Ter
ASP = oldASP;
H = oldH;
HB = oldHB;
if (arena == GlobalArena)
GlobalArenaOverflows++;
if (arena == LOCAL_GlobalArena)
LOCAL_GlobalArenaOverflows++;
if (!GrowArena(arena, old_top, old_size, Nar*sizeof(CELL), arity+2 PASS_REGS)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while creating large global term");
return 0L;
@ -855,8 +855,8 @@ GetGlobalEntry(Atom at USES_REGS)
#if THREADS
new->owner_id = worker_id;
#endif
new->NextGE = GlobalVariables;
GlobalVariables = new;
new->NextGE = LOCAL_GlobalVariables;
LOCAL_GlobalVariables = new;
new->AtomOfGE = ae;
new->NextOfPE = ae->PropsOfAE;
ae->PropsOfAE = AbsGlobalProp(new);
@ -869,8 +869,8 @@ static UInt
garena_overflow_size(CELL *arena USES_REGS)
{
UInt dup = (((CELL *)arena-H0)*sizeof(CELL))>>3;
if (dup < 64*1024*GlobalArenaOverflows)
dup = 64*1024*GlobalArenaOverflows;
if (dup < 64*1024*LOCAL_GlobalArenaOverflows)
dup = 64*1024*LOCAL_GlobalArenaOverflows;
if (dup > 1024*1024)
return 1024*1024;
return dup;
@ -911,7 +911,7 @@ p_nb_setarg( USES_REGS1 )
return FALSE;
to = Deref(ARG3);
to = CopyTermToArena(ARG3, GlobalArena, FALSE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
to = CopyTermToArena(ARG3, LOCAL_GlobalArena, FALSE, TRUE, 2, &LOCAL_GlobalArena, garena_overflow_size(ArenaPt(LOCAL_GlobalArena) PASS_REGS) PASS_REGS);
if (to == 0L)
return FALSE;
@ -958,7 +958,7 @@ p_nb_set_shared_arg( USES_REGS1 )
}
if (pos < 1 || pos > arity)
return FALSE;
to = CopyTermToArena(ARG3, GlobalArena, TRUE, TRUE, 3, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
to = CopyTermToArena(ARG3, LOCAL_GlobalArena, TRUE, TRUE, 3, &LOCAL_GlobalArena, garena_overflow_size(ArenaPt(LOCAL_GlobalArena) PASS_REGS) PASS_REGS);
if (to == 0L)
return FALSE;
destp[pos] = to;
@ -1041,7 +1041,7 @@ p_nb_create_accumulator( USES_REGS1 )
if (!Yap_unify(ARG2, acct)) {
return FALSE;
}
to = CopyTermToArena(t, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
to = CopyTermToArena(t, LOCAL_GlobalArena, TRUE, TRUE, 2, &LOCAL_GlobalArena, garena_overflow_size(ArenaPt(LOCAL_GlobalArena) PASS_REGS) PASS_REGS);
if (to == 0L)
return FALSE;
destp = RepAppl(Deref(ARG2));
@ -1091,7 +1091,7 @@ p_nb_add_to_accumulator( USES_REGS1 )
target[1] = source[1];
} else {
/* we need to create a new long int */
new = CopyTermToArena(new, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
new = CopyTermToArena(new, LOCAL_GlobalArena, TRUE, TRUE, 2, &LOCAL_GlobalArena, garena_overflow_size(ArenaPt(LOCAL_GlobalArena) PASS_REGS) PASS_REGS);
destp = RepAppl(Deref(ARG1));
destp[1] = new;
}
@ -1118,7 +1118,7 @@ p_nb_add_to_accumulator( USES_REGS1 )
new = Yap_MkApplTerm(FunctorPlus, 2, t2);
new = Yap_Eval(new);
new = CopyTermToArena(new, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
new = CopyTermToArena(new, LOCAL_GlobalArena, TRUE, TRUE, 2, &LOCAL_GlobalArena, garena_overflow_size(ArenaPt(LOCAL_GlobalArena) PASS_REGS) PASS_REGS);
destp = RepAppl(Deref(ARG1));
destp[1] = new;
@ -1158,7 +1158,7 @@ Yap_SetGlobalVal(Atom at, Term t0)
Term to;
GlobalEntry *ge;
ge = GetGlobalEntry(at PASS_REGS);
to = CopyTermToArena(t0, GlobalArena, FALSE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
to = CopyTermToArena(t0, LOCAL_GlobalArena, FALSE, TRUE, 2, &LOCAL_GlobalArena, garena_overflow_size(ArenaPt(LOCAL_GlobalArena) PASS_REGS) PASS_REGS);
if (to == 0L)
return to;
WRITE_LOCK(ge->GRWLock);
@ -1172,7 +1172,7 @@ Yap_SaveTerm(Term t0)
{
CACHE_REGS
Term to;
to = CopyTermToArena(t0, GlobalArena, FALSE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
to = CopyTermToArena(t0, LOCAL_GlobalArena, FALSE, TRUE, 2, &LOCAL_GlobalArena, garena_overflow_size(ArenaPt(LOCAL_GlobalArena) PASS_REGS) PASS_REGS);
if (to == 0L)
return to;
return to;
@ -1205,7 +1205,7 @@ p_nb_set_shared_val( USES_REGS1 )
return (FALSE);
}
ge = GetGlobalEntry(AtomOfTerm(t) PASS_REGS);
to = CopyTermToArena(ARG2, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
to = CopyTermToArena(ARG2, LOCAL_GlobalArena, TRUE, TRUE, 2, &LOCAL_GlobalArena, garena_overflow_size(ArenaPt(LOCAL_GlobalArena) PASS_REGS) PASS_REGS);
if (to == 0L)
return FALSE;
WRITE_LOCK(ge->GRWLock);
@ -1295,10 +1295,10 @@ nbdelete(Atom at USES_REGS)
}
WRITE_LOCK(ge->GRWLock);
ae = ge->AtomOfGE;
if (GlobalVariables == ge) {
GlobalVariables = ge->NextGE;
if (LOCAL_GlobalVariables == ge) {
LOCAL_GlobalVariables = ge->NextGE;
} else {
g = GlobalVariables;
g = LOCAL_GlobalVariables;
while (g->NextGE != ge)
g = g->NextGE;
g->NextGE = ge->NextGE;
@ -1376,7 +1376,7 @@ p_nb_create( USES_REGS1 )
Yap_Error(TYPE_ERROR_ATOM,tname,"nb_create");
return FALSE;
}
to = CreateTermInArena(GlobalArena, AtomOfTerm(tname), IntegerOfTerm(tarity), 3, &GlobalArena, 0L PASS_REGS);
to = CreateTermInArena(LOCAL_GlobalArena, AtomOfTerm(tname), IntegerOfTerm(tarity), 3, &LOCAL_GlobalArena, 0L PASS_REGS);
if (!to)
return FALSE;
WRITE_LOCK(ge->GRWLock);
@ -1428,7 +1428,7 @@ p_nb_create2( USES_REGS1 )
Yap_Error(TYPE_ERROR_ATOM,tname,"nb_create");
return FALSE;
}
to = CreateTermInArena(GlobalArena, AtomOfTerm(tname), IntegerOfTerm(tarity), 4, &GlobalArena, tinit PASS_REGS);
to = CreateTermInArena(LOCAL_GlobalArena, AtomOfTerm(tname), IntegerOfTerm(tarity), 4, &LOCAL_GlobalArena, tinit PASS_REGS);
if (!to)
return FALSE;
WRITE_LOCK(ge->GRWLock);
@ -1445,7 +1445,7 @@ nb_queue(UInt arena_sz USES_REGS)
Term queue_arena, queue, ar[QUEUE_FUNCTOR_ARITY], *nar;
Term t = Deref(ARG1);
DepthArenas++;
LOCAL_DepthArenas++;
if (!IsVarTerm(t)) {
if (!IsApplTerm(t)) {
return FALSE;
@ -1475,8 +1475,8 @@ static Int
p_nb_queue( USES_REGS1 )
{
UInt arena_sz = (ASP-H)/16;
if (DepthArenas > 1)
arena_sz /= DepthArenas;
if (LOCAL_DepthArenas > 1)
arena_sz /= LOCAL_DepthArenas;
if (arena_sz < MIN_ARENA_SIZE)
arena_sz = MIN_ARENA_SIZE;
if (arena_sz > MAX_ARENA_SIZE)
@ -1556,7 +1556,7 @@ p_nb_queue_close( USES_REGS1 )
Term t = Deref(ARG1);
Int out;
DepthArenas--;
LOCAL_DepthArenas--;
if (!IsVarTerm(t)) {
CELL *qp;
@ -1625,7 +1625,7 @@ p_nb_queue_enqueue( USES_REGS1 )
ARG3 = to;
/* fprintf(stderr,"growing %ld cells\n",(unsigned long int)gsiz);*/
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, LOCAL_ErrorMessage);
return 0L;
}
to = ARG3;
@ -1677,6 +1677,31 @@ p_nb_queue_dequeue( USES_REGS1 )
return Yap_unify(out, ARG2);
}
/* purge an entry from the queue, replacing it by [] */
static Int
p_nb_queue_replace( USES_REGS1 )
{
CELL *qd = GetQueue(ARG1,"dequeue");
UInt qsz;
Term queue, t = Deref(ARG2);
if (!qd)
return FALSE;
qsz = IntegerOfTerm(qd[QUEUE_SIZE]);
if (qsz == 0)
return FALSE;
queue = qd[QUEUE_HEAD];
for (; qsz > 0; qsz--) {
if (Yap_eq(HeadOfTerm(queue), t)) {
*RepPair(Deref(queue)) = Deref(ARG3);
return TRUE;
}
queue = TailOfTerm(queue);
}
return FALSE;
}
static Int
p_nb_queue_peek( USES_REGS1 )
{
@ -1711,6 +1736,16 @@ p_nb_queue_size( USES_REGS1 )
return Yap_unify(ARG2,qd[QUEUE_SIZE]);
}
static Int
p_nb_queue_show( USES_REGS1 )
{
CELL *qd = GetQueue(ARG1,"queue_size");
if (!qd)
return FALSE;
return Yap_unify(ARG2,qd[QUEUE_HEAD]);
}
static CELL *
GetHeap(Term t, char* caller)
@ -1768,7 +1803,7 @@ p_nb_heap( USES_REGS1 )
while ((heap = MkZeroApplTerm(Yap_MkFunctor(AtomHeap,2*hsize+HEAP_START+1),2*hsize+HEAP_START+1 PASS_REGS)) == TermNil) {
if (!Yap_gcl((2*hsize+HEAP_START+1)*sizeof(CELL), 2, ENV, P)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -1942,7 +1977,7 @@ p_nb_heap_add_to_heap( USES_REGS1 )
}
ARG3 = to;
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, LOCAL_ErrorMessage);
return 0L;
}
to = ARG3;
@ -2050,7 +2085,7 @@ p_nb_beam( USES_REGS1 )
}
while ((beam = MkZeroApplTerm(Yap_MkFunctor(AtomHeap,5*hsize+HEAP_START+1),5*hsize+HEAP_START+1 PASS_REGS)) == TermNil) {
if (!Yap_gcl((4*hsize+HEAP_START+1)*sizeof(CELL), 2, ENV, P)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -2328,7 +2363,7 @@ p_nb_beam_add_to_beam( USES_REGS1 )
}
ARG3 = to;
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, LOCAL_ErrorMessage);
return 0L;
}
to = ARG3;
@ -2440,7 +2475,7 @@ p_nb_beam_keys( USES_REGS1 )
if (H > ASP-1024) {
H = ho;
if (!Yap_gcl(((ASP-H)-1024)*sizeof(CELL), 2, ENV, P)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return TermNil;
}
goto restart;
@ -2531,7 +2566,7 @@ init_current_nb( USES_REGS1 )
}
}
READ_LOCK(HashChain[0].AERWLock);
EXTRA_CBACK_ARG(1,1) = MkIntegerTerm((Int)GlobalVariables);
EXTRA_CBACK_ARG(1,1) = MkIntegerTerm((Int)LOCAL_GlobalVariables);
return cont_current_nb( PASS_REGS1 );
}
@ -2562,7 +2597,9 @@ void Yap_InitGlobals(void)
Yap_InitCPred("nb_queue_dequeue", 2, p_nb_queue_dequeue, SafePredFlag);
Yap_InitCPred("nb_queue_peek", 2, p_nb_queue_peek, SafePredFlag);
Yap_InitCPred("nb_queue_empty", 1, p_nb_queue_empty, SafePredFlag);
Yap_InitCPred("nb_queue_replace", 3, p_nb_queue_replace, SafePredFlag);
Yap_InitCPred("nb_queue_size", 2, p_nb_queue_size, SafePredFlag);
Yap_InitCPred("nb_queue_show", 2, p_nb_queue_show, SafePredFlag);
Yap_InitCPred("nb_heap", 2, p_nb_heap, 0L);
Yap_InitCPred("nb_heap_close", 1, p_nb_heap_close, SafePredFlag);
Yap_InitCPred("nb_heap_add", 3, p_nb_heap_add_to_heap, 0L);

195
C/gprof.c
View File

@ -123,13 +123,13 @@ typedef greg_t context_reg;
#include <ucontext.h>
#endif
static Int ProfCalls, ProfGCs, ProfHGrows, ProfSGrows, ProfMallocs, ProfOn, ProfOns;
#define TIMER_DEFAULT 100
#define PROFILING_FILE 1
#define PROFPREDS_FILE 2
static char *DIRNAME=NULL;
typedef struct RB_red_blk_node {
yamop *key; /* first address */
@ -142,7 +142,7 @@ typedef struct RB_red_blk_node {
struct RB_red_blk_node* parent;
} rb_red_blk_node;
static rb_red_blk_node *ProfilerRoot, *ProfilerNil;
static rb_red_blk_node *
RBMalloc(UInt size)
@ -162,14 +162,14 @@ RBTreeCreate(void) {
/* see the comment in the rb_red_blk_tree structure in red_black_tree.h */
/* for information on nil and root */
temp=ProfilerNil= RBMalloc(sizeof(rb_red_blk_node));
temp=GLOBAL_ProfilerNil= RBMalloc(sizeof(rb_red_blk_node));
temp->parent=temp->left=temp->right=temp;
temp->pcs=0;
temp->red=0;
temp->key=temp->lim=NULL;
temp->pe=NULL;
temp = RBMalloc(sizeof(rb_red_blk_node));
temp->parent=temp->left=temp->right=ProfilerNil;
temp->parent=temp->left=temp->right=GLOBAL_ProfilerNil;
temp->key=temp->lim=NULL;
temp->pe=NULL;
temp->pcs=0;
@ -199,7 +199,7 @@ RBTreeCreate(void) {
static void
LeftRotate(rb_red_blk_node* x) {
rb_red_blk_node* y;
rb_red_blk_node* nil=ProfilerNil;
rb_red_blk_node* nil=GLOBAL_ProfilerNil;
/* I originally wrote this function to use the sentinel for */
/* nil to avoid checking for nil. However this introduces a */
@ -230,7 +230,7 @@ LeftRotate(rb_red_blk_node* x) {
x->parent=y;
#ifdef DEBUG_ASSERT
Assert(!ProfilerNil->red,"nil not red in LeftRotate");
Assert(!GLOBAL_ProfilerNil->red,"nil not red in LeftRotate");
#endif
}
@ -255,7 +255,7 @@ LeftRotate(rb_red_blk_node* x) {
static void
RightRotate(rb_red_blk_node* y) {
rb_red_blk_node* x;
rb_red_blk_node* nil=ProfilerNil;
rb_red_blk_node* nil=GLOBAL_ProfilerNil;
/* I originally wrote this function to use the sentinel for */
/* nil to avoid checking for nil. However this introduces a */
@ -285,7 +285,7 @@ RightRotate(rb_red_blk_node* y) {
y->parent=x;
#ifdef DEBUG_ASSERT
Assert(!ProfilerNil->red,"nil not red in RightRotate");
Assert(!GLOBAL_ProfilerNil->red,"nil not red in RightRotate");
#endif
}
@ -309,11 +309,11 @@ TreeInsertHelp(rb_red_blk_node* z) {
/* This function should only be called by InsertRBTree (see above) */
rb_red_blk_node* x;
rb_red_blk_node* y;
rb_red_blk_node* nil=ProfilerNil;
rb_red_blk_node* nil=GLOBAL_ProfilerNil;
z->left=z->right=nil;
y=ProfilerRoot;
x=ProfilerRoot->left;
y=GLOBAL_ProfilerRoot;
x=GLOBAL_ProfilerRoot->left;
while( x != nil) {
y=x;
if (x->key > z->key) { /* x.key > z.key */
@ -323,7 +323,7 @@ TreeInsertHelp(rb_red_blk_node* z) {
}
}
z->parent=y;
if ( (y == ProfilerRoot) ||
if ( (y == GLOBAL_ProfilerRoot) ||
(y->key > z->key)) { /* y.key > z.key */
y->left=z;
} else {
@ -331,7 +331,7 @@ TreeInsertHelp(rb_red_blk_node* z) {
}
#ifdef DEBUG_ASSERT
Assert(!ProfilerNil->red,"nil not red in TreeInsertHelp");
Assert(!GLOBAL_ProfilerNil->red,"nil not red in TreeInsertHelp");
#endif
}
@ -403,12 +403,12 @@ RBTreeInsert(yamop *key, yamop *lim) {
}
}
}
ProfilerRoot->left->red=0;
GLOBAL_ProfilerRoot->left->red=0;
return newNode;
#ifdef DEBUG_ASSERT
Assert(!ProfilerNil->red,"nil not red in RBTreeInsert");
Assert(!ProfilerRoot->red,"root not red in RBTreeInsert");
Assert(!GLOBAL_ProfilerNil->red,"nil not red in RBTreeInsert");
Assert(!GLOBAL_ProfilerRoot->red,"root not red in RBTreeInsert");
#endif
}
@ -429,10 +429,10 @@ RBTreeInsert(yamop *key, yamop *lim) {
static rb_red_blk_node*
RBExactQuery(yamop* q) {
rb_red_blk_node* x;
rb_red_blk_node* nil=ProfilerNil;
rb_red_blk_node* nil=GLOBAL_ProfilerNil;
if (!ProfilerRoot) return NULL;
x=ProfilerRoot->left;
if (!GLOBAL_ProfilerRoot) return NULL;
x=GLOBAL_ProfilerRoot->left;
if (x == nil) return NULL;
while(x->key != q) {/*assignemnt*/
if (x->key > q) { /* x->key > q */
@ -450,10 +450,10 @@ static rb_red_blk_node*
RBLookup(yamop *entry) {
rb_red_blk_node *current;
if (!ProfilerRoot)
if (!GLOBAL_ProfilerRoot)
return NULL;
current = ProfilerRoot->left;
while (current != ProfilerNil) {
current = GLOBAL_ProfilerRoot->left;
while (current != GLOBAL_ProfilerNil) {
if (current->key <= entry && current->lim >= entry) {
return current;
}
@ -483,7 +483,7 @@ RBLookup(yamop *entry) {
/***********************************************************************/
static void RBDeleteFixUp(rb_red_blk_node* x) {
rb_red_blk_node* root=ProfilerRoot->left;
rb_red_blk_node* root=GLOBAL_ProfilerRoot->left;
rb_red_blk_node *w;
while( (!x->red) && (root != x)) {
@ -563,8 +563,8 @@ static void RBDeleteFixUp(rb_red_blk_node* x) {
static rb_red_blk_node*
TreeSuccessor(rb_red_blk_node* x) {
rb_red_blk_node* y;
rb_red_blk_node* nil=ProfilerNil;
rb_red_blk_node* root=ProfilerRoot;
rb_red_blk_node* nil=GLOBAL_ProfilerNil;
rb_red_blk_node* root=GLOBAL_ProfilerRoot;
if (nil != (y = x->right)) { /* assignment to y is intentional */
while(y->left != nil) { /* returns the minium of the right subtree of x */
@ -602,8 +602,8 @@ static void
RBDelete(rb_red_blk_node* z){
rb_red_blk_node* y;
rb_red_blk_node* x;
rb_red_blk_node* nil=ProfilerNil;
rb_red_blk_node* root=ProfilerRoot;
rb_red_blk_node* nil=GLOBAL_ProfilerNil;
rb_red_blk_node* root=GLOBAL_ProfilerRoot;
y= ((z->left == nil) || (z->right == nil)) ? z : TreeSuccessor(z);
x= (y->left == nil) ? y->right : y->left;
@ -656,21 +656,21 @@ int size=0;
if (name!=NULL) {
size=strlen(name)+1;
if (DIRNAME!=NULL) free(DIRNAME);
DIRNAME=malloc(size);
if (DIRNAME==NULL) { printf("Profiler Out of Mem\n"); exit(1); }
strcpy(DIRNAME,name);
if (GLOBAL_DIRNAME!=NULL) free(GLOBAL_DIRNAME);
GLOBAL_DIRNAME=malloc(size);
if (GLOBAL_DIRNAME==NULL) { printf("Profiler Out of Mem\n"); exit(1); }
strcpy(GLOBAL_DIRNAME,name);
}
if (DIRNAME==NULL) {
if (GLOBAL_DIRNAME==NULL) {
do {
if (DIRNAME!=NULL) free(DIRNAME);
if (GLOBAL_DIRNAME!=NULL) free(GLOBAL_DIRNAME);
size+=20;
DIRNAME=malloc(size);
if (DIRNAME==NULL) { printf("Profiler Out of Mem\n"); exit(1); }
} while (getcwd(DIRNAME, size-15)==NULL);
GLOBAL_DIRNAME=malloc(size);
if (GLOBAL_DIRNAME==NULL) { printf("Profiler Out of Mem\n"); exit(1); }
} while (getcwd(GLOBAL_DIRNAME, size-15)==NULL);
}
return DIRNAME;
return GLOBAL_DIRNAME;
}
char *profile_names(int);
@ -678,12 +678,12 @@ char *profile_names(int k) {
static char *FNAME=NULL;
int size=200;
if (DIRNAME==NULL) set_profile_dir(NULL);
size=strlen(DIRNAME)+40;
if (GLOBAL_DIRNAME==NULL) set_profile_dir(NULL);
size=strlen(GLOBAL_DIRNAME)+40;
if (FNAME!=NULL) free(FNAME);
FNAME=malloc(size);
if (FNAME==NULL) { printf("Profiler Out of Mem\n"); exit(1); }
strcpy(FNAME,DIRNAME);
strcpy(FNAME,GLOBAL_DIRNAME);
if (k==PROFILING_FILE) {
sprintf(FNAME,"%s/PROFILING_%d",FNAME,getpid());
@ -697,7 +697,7 @@ int size=200;
void del_profile_files(void);
void del_profile_files() {
if (DIRNAME!=NULL) {
if (GLOBAL_DIRNAME!=NULL) {
remove(profile_names(PROFPREDS_FILE));
remove(profile_names(PROFILING_FILE));
}
@ -708,7 +708,7 @@ Yap_inform_profiler_of_clause(yamop *code_start, yamop *code_end, PredEntry *pe,
static Int order=0;
ProfPreds++;
ProfOn = TRUE;
GLOBAL_ProfOn = TRUE;
if (FPreds != NULL) {
Int temp;
@ -716,7 +716,7 @@ static Int order=0;
if (index_code) temp=-order; else temp=order;
fprintf(FPreds,"+%p %p %p %ld\n",code_start,code_end, pe, (long int)temp);
}
ProfOn = FALSE;
GLOBAL_ProfOn = FALSE;
}
typedef struct clause_entry {
@ -731,7 +731,7 @@ static Int profend( USES_REGS1 );
static void
clean_tree(rb_red_blk_node* node) {
if (node == ProfilerNil)
if (node == GLOBAL_ProfilerNil)
return;
clean_tree(node->left);
clean_tree(node->right);
@ -740,18 +740,18 @@ clean_tree(rb_red_blk_node* node) {
static void
reset_tree(void) {
clean_tree(ProfilerRoot);
Yap_FreeCodeSpace((char *)ProfilerNil);
ProfilerNil = ProfilerRoot = NULL;
ProfCalls = ProfGCs = ProfHGrows = ProfSGrows = ProfMallocs = ProfOns = 0L;
clean_tree(GLOBAL_ProfilerRoot);
Yap_FreeCodeSpace((char *)GLOBAL_ProfilerNil);
GLOBAL_ProfilerNil = GLOBAL_ProfilerRoot = NULL;
GLOBAL_ProfCalls = GLOBAL_ProfGCs = GLOBAL_ProfHGrows = GLOBAL_ProfSGrows = GLOBAL_ProfMallocs = GLOBAL_ProfOns = 0L;
}
static int
InitProfTree(void)
{
if (ProfilerRoot)
if (GLOBAL_ProfilerRoot)
reset_tree();
while (!(ProfilerRoot = RBTreeCreate())) {
while (!(GLOBAL_ProfilerRoot = RBTreeCreate())) {
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "while initialisating profiler");
return FALSE;
@ -807,10 +807,10 @@ static void RemoveCode(CODEADDR clau)
PredEntry *pp;
UInt count;
if (!ProfilerRoot) return;
if (!GLOBAL_ProfilerRoot) return;
if (!(x = RBExactQuery((yamop *)clau))) {
/* send message */
ProfOn = FALSE;
GLOBAL_ProfOn = FALSE;
return;
}
pp = x->pe;
@ -823,7 +823,7 @@ static void RemoveCode(CODEADDR clau)
node->pe = pp;
node->pcs = count;
/* send message */
ProfOn = FALSE;
GLOBAL_ProfOn = FALSE;
return;
} else {
node->pcs += count;
@ -872,7 +872,7 @@ showprofres( USES_REGS1 ) {
}
}
fclose(FProf);
if (ProfCalls==0)
if (GLOBAL_ProfCalls==0)
return TRUE;
return TRUE;
}
@ -909,7 +909,7 @@ p_test( USES_REGS1 ) {
}
}
fclose(FProf);
if (ProfCalls==0)
if (GLOBAL_ProfCalls==0)
return TRUE;
return TRUE;
}
@ -920,39 +920,40 @@ p_test( USES_REGS1 ) {
static void
prof_alrm(int signo, siginfo_t *si, void *scv)
{
{
CACHE_REGS
void * oldpc=(void *) CONTEXT_PC(scv);
yamop *current_p;
ProfCalls++;
GLOBAL_ProfCalls++;
/* skip an interrupt */
if (ProfOn) {
ProfOns++;
if (GLOBAL_ProfOn) {
GLOBAL_ProfOns++;
return;
}
ProfOn = TRUE;
if (Yap_PrologMode & TestMode) {
if (Yap_PrologMode & GCMode) {
ProfGCs++;
ProfOn = FALSE;
GLOBAL_ProfOn = TRUE;
if (LOCAL_PrologMode & TestMode) {
if (LOCAL_PrologMode & GCMode) {
GLOBAL_ProfGCs++;
GLOBAL_ProfOn = FALSE;
return;
}
if (Yap_PrologMode & MallocMode) {
ProfMallocs++;
ProfOn = FALSE;
if (LOCAL_PrologMode & MallocMode) {
GLOBAL_ProfMallocs++;
GLOBAL_ProfOn = FALSE;
return;
}
if (Yap_PrologMode & GrowHeapMode) {
ProfHGrows++;
ProfOn = FALSE;
if (LOCAL_PrologMode & GrowHeapMode) {
GLOBAL_ProfHGrows++;
GLOBAL_ProfOn = FALSE;
return;
}
if (Yap_PrologMode & GrowStackMode) {
ProfSGrows++;
ProfOn = FALSE;
if (LOCAL_PrologMode & GrowStackMode) {
GLOBAL_ProfSGrows++;
GLOBAL_ProfOn = FALSE;
return;
}
@ -987,34 +988,34 @@ prof_alrm(int signo, siginfo_t *si, void *scv)
#if DEBUG
fprintf(stderr,"Oops: %p, %p\n", oldpc, current_p);
#endif
ProfOn = FALSE;
GLOBAL_ProfOn = FALSE;
return;
}
#endif
if (Yap_OffLineProfiler) {
fprintf(FProf,"%p\n", current_p);
ProfOn = FALSE;
GLOBAL_ProfOn = FALSE;
return;
}
LookupNode(current_p);
ProfOn = FALSE;
GLOBAL_ProfOn = FALSE;
}
void
Yap_InformOfRemoval(CODEADDR clau)
{
ProfOn = TRUE;
GLOBAL_ProfOn = TRUE;
if (FPreds != NULL) {
/* just store info about what is going on */
fprintf(FPreds,"-%p\n",clau);
ProfOn = FALSE;
GLOBAL_ProfOn = FALSE;
return;
}
RemoveCode(clau);
ProfOn = FALSE;
GLOBAL_ProfOn = FALSE;
}
static Int profend( USES_REGS1 );
@ -1024,25 +1025,25 @@ profnode( USES_REGS1 ) {
Term t1 = Deref(ARG1), tleft, tright;
rb_red_blk_node *node;
if (!ProfilerRoot)
if (!GLOBAL_ProfilerRoot)
return FALSE;
if (!(node = (rb_red_blk_node *)IntegerOfTerm(t1)))
node = ProfilerRoot;
node = GLOBAL_ProfilerRoot;
/*
if (node->key)
fprintf(stderr,"%p: %p,%p,%d,%p(%d),%p,%p\n",node,node->key,node->lim,node->pcs,node->pe,node->pe->ArityOfPE,node->right,node->left);
*/
if (node->left == ProfilerNil) {
if (node->left == GLOBAL_ProfilerNil) {
tleft = TermNil;
} else {
tleft = MkIntegerTerm((Int)node->left);
}
if (node->left == ProfilerNil) {
if (node->left == GLOBAL_ProfilerNil) {
tleft = TermNil;
} else {
tleft = MkIntegerTerm((Int)node->left);
}
if (node->right == ProfilerNil) {
if (node->right == GLOBAL_ProfilerNil) {
tright = TermNil;
} else {
tright = MkIntegerTerm((Int)node->right);
@ -1058,12 +1059,12 @@ profnode( USES_REGS1 ) {
static Int
profglobs( USES_REGS1 ) {
return
Yap_unify(ARG1,MkIntegerTerm(ProfCalls)) &&
Yap_unify(ARG2,MkIntegerTerm(ProfGCs)) &&
Yap_unify(ARG3,MkIntegerTerm(ProfHGrows)) &&
Yap_unify(ARG4,MkIntegerTerm(ProfSGrows)) &&
Yap_unify(ARG5,MkIntegerTerm(ProfMallocs)) &&
Yap_unify(ARG6,MkIntegerTerm(ProfOns)) ;
Yap_unify(ARG1,MkIntegerTerm(GLOBAL_ProfCalls)) &&
Yap_unify(ARG2,MkIntegerTerm(GLOBAL_ProfGCs)) &&
Yap_unify(ARG3,MkIntegerTerm(GLOBAL_ProfHGrows)) &&
Yap_unify(ARG4,MkIntegerTerm(GLOBAL_ProfSGrows)) &&
Yap_unify(ARG5,MkIntegerTerm(GLOBAL_ProfMallocs)) &&
Yap_unify(ARG6,MkIntegerTerm(GLOBAL_ProfOns)) ;
}
static Int
@ -1169,14 +1170,14 @@ static Int profoff( USES_REGS1 ) {
return FALSE;
}
static Int profon( USES_REGS1 ) {
static Int ProfOn( USES_REGS1 ) {
Term p;
profoff( PASS_REGS1 );
p=Deref(ARG1);
return(start_profilers(IntOfTerm(p)));
}
static Int profon0( USES_REGS1 ) {
static Int ProfOn0( USES_REGS1 ) {
profoff( PASS_REGS1 );
return(start_profilers(TIMER_DEFAULT));
}
@ -1187,7 +1188,7 @@ static Int profison( USES_REGS1 ) {
static Int profalt( USES_REGS1 ) {
if (ProfilerOn==0) return(FALSE);
if (ProfilerOn==-1) return profon( PASS_REGS1 );
if (ProfilerOn==-1) return ProfOn( PASS_REGS1 );
return profoff( PASS_REGS1 );
}
@ -1248,15 +1249,15 @@ void
Yap_InitLowProf(void)
{
#if LOW_PROF
ProfCalls = 0;
GLOBAL_ProfCalls = 0;
ProfilerOn = FALSE;
Yap_OffLineProfiler = FALSE;
Yap_InitCPred("profinit",0, profinit, SafePredFlag);
Yap_InitCPred("profinit",1, profinit1, SafePredFlag);
Yap_InitCPred("$proftype",1, proftype, SafePredFlag);
Yap_InitCPred("profend" ,0, profend, SafePredFlag);
Yap_InitCPred("profon" , 0, profon0, SafePredFlag);
Yap_InitCPred("profon" , 1, profon, SafePredFlag);
Yap_InitCPred("ProfOn" , 0, ProfOn0, SafePredFlag);
Yap_InitCPred("ProfOn" , 1, ProfOn, SafePredFlag);
Yap_InitCPred("profoff", 0, profoff, SafePredFlag);
Yap_InitCPred("profalt", 0, profalt, SafePredFlag);
Yap_InitCPred("$offline_showprofres", 0, profres0, SafePredFlag);

491
C/grow.c
View File

@ -42,20 +42,7 @@ typedef enum {
STACK_INCREMENTAL_COPYING = 2
} what_stack_copying;
static int heap_overflows = 0;
static Int total_heap_overflow_time = 0;
int stack_overflows = 0;
static Int total_stack_overflow_time = 0;
int delay_overflows = 0;
static Int total_delay_overflow_time = 0;
static int trail_overflows = 0;
static Int total_trail_overflow_time = 0;
static int atom_table_overflows = 0;
static Int total_atom_table_overflow_time = 0;
STATIC_PROTO(Int p_growheap, ( USES_REGS1 ));
STATIC_PROTO(Int p_growstack, ( USES_REGS1 ));
@ -85,10 +72,11 @@ STATIC_PROTO(Term AdjustGlobTerm, (Term CACHE_TYPE));
static void
LeaveGrowMode(prolog_exec_mode grow_mode)
{
Yap_PrologMode &= ~grow_mode;
if (Yap_PrologMode & AbortMode) {
CACHE_REGS
LOCAL_PrologMode &= ~grow_mode;
if (LOCAL_PrologMode & AbortMode) {
CACHE_REGS
Yap_PrologMode &= ~AbortMode;
LOCAL_PrologMode &= ~AbortMode;
Yap_Error(PURE_ABORT, TermNil, "");
/* in case someone mangles the P register */
save_machine_regs();
@ -98,7 +86,7 @@ LeaveGrowMode(prolog_exec_mode grow_mode)
#if PUSH_REGS
restore_absmi_regs(&Yap_standard_regs);
#endif
siglongjmp (Yap_RestartEnv, 1);
siglongjmp (LOCAL_RestartEnv, 1);
#endif
}
}
@ -121,27 +109,27 @@ static void
SetHeapRegs(int copying_threads USES_REGS)
{
#ifdef undf7
fprintf(Yap_stderr,"HeapBase = %x\tHeapTop=%x\nGlobalBase=%x\tGlobalTop=%x\nLocalBase=%x\tLocatTop=%x\n", Yap_HeapBase, HeapTop, Yap_GlobalBase, H, LCL0, ASP);
fprintf(GLOBAL_stderr,"HeapBase = %x\tHeapTop=%x\nGlobalBase=%x\tGlobalTop=%x\nLocalBase=%x\tLocatTop=%x\n", Yap_HeapBase, HeapTop, LOCAL_GlobalBase, H, LCL0, ASP);
#endif
/* The old stack pointers */
OldLCL0 = LCL0;
OldASP = ASP;
OldGlobalBase = (CELL *)Yap_GlobalBase;
OldH = H;
OldH0 = H0;
OldTrailBase = Yap_TrailBase;
OldTrailTop = Yap_TrailTop;
OldTR = TR;
OldHeapBase = Yap_HeapBase;
OldHeapTop = HeapTop;
LOCAL_OldLCL0 = LCL0;
LOCAL_OldASP = ASP;
LOCAL_OldGlobalBase = (CELL *)LOCAL_GlobalBase;
LOCAL_OldH = H;
LOCAL_OldH0 = H0;
LOCAL_OldTrailBase = LOCAL_TrailBase;
LOCAL_OldTrailTop = LOCAL_TrailTop;
LOCAL_OldTR = TR;
LOCAL_OldHeapBase = Yap_HeapBase;
LOCAL_OldHeapTop = HeapTop;
/* Adjust stack addresses */
Yap_TrailBase = TrailAddrAdjust(Yap_TrailBase);
Yap_TrailTop = TrailAddrAdjust(Yap_TrailTop);
if (GDiff) {
LOCAL_TrailBase = TrailAddrAdjust(LOCAL_TrailBase);
LOCAL_TrailTop = TrailAddrAdjust(LOCAL_TrailTop);
if (LOCAL_GDiff) {
/* make sure we are not just expanding the delay stack */
Yap_GlobalBase = BaseAddrAdjust(Yap_GlobalBase);
LOCAL_GlobalBase = BaseAddrAdjust(LOCAL_GlobalBase);
}
Yap_LocalBase = LocalAddrAdjust(Yap_LocalBase);
LOCAL_LocalBase = LocalAddrAdjust(LOCAL_LocalBase);
#if !USE_SYSTEM_MALLOC && !USE_DL_MALLOC
AuxSp = PtoBaseAdjust(AuxSp);
AuxTop = (ADDR)PtoBaseAdjust((CELL *)AuxTop);
@ -157,10 +145,10 @@ SetHeapRegs(int copying_threads USES_REGS)
ASP = PtoLocAdjust(ASP);
if (H0)
H0 = PtoGloAdjust(H0);
LOCK(SignalLock);
LOCK(LOCAL_SignalLock);
if (LCL0)
LCL0 = PtoLocAdjust(LCL0);
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
if (H)
H = PtoGloAdjust(H);
#ifdef CUT_C
@ -190,17 +178,17 @@ SetHeapRegs(int copying_threads USES_REGS)
else if (IsOldLocalPtr(S))
S = PtoLocAdjust(S);
if (!copying_threads) {
if (GlobalArena)
GlobalArena = AbsAppl(PtoGloAdjust(RepAppl(GlobalArena)));
if (LOCAL_GlobalArena)
LOCAL_GlobalArena = AbsAppl(PtoGloAdjust(RepAppl(LOCAL_GlobalArena)));
}
#ifdef COROUTINING
if (AttsMutableList)
AttsMutableList = AbsAppl(PtoGloAdjust(RepAppl(AttsMutableList)));
if (WokenGoals)
WokenGoals = AbsAppl(PtoGloAdjust(RepAppl(WokenGoals)));
if (LOCAL_AttsMutableList)
LOCAL_AttsMutableList = AbsAppl(PtoGloAdjust(RepAppl(LOCAL_AttsMutableList)));
if (LOCAL_WokenGoals)
LOCAL_WokenGoals = AbsAppl(PtoGloAdjust(RepAppl(LOCAL_WokenGoals)));
#endif
GcGeneration = AbsAppl(PtoGloAdjust(RepAppl(GcGeneration)));
GcPhase = AbsAppl(PtoGloAdjust(RepAppl(GcPhase)));
LOCAL_GcGeneration = AbsAppl(PtoGloAdjust(RepAppl(LOCAL_GcGeneration)));
LOCAL_GcPhase = AbsAppl(PtoGloAdjust(RepAppl(LOCAL_GcPhase)));
}
static void
@ -208,9 +196,9 @@ MoveLocalAndTrail( USES_REGS1 )
{
/* cpcellsd(To,From,NOfCells) - copy the cells downwards */
#if USE_SYSTEM_MALLOC
cpcellsd(ASP, (CELL *)((char *)OldASP+BaseDiff), (CELL *)OldTR - OldASP);
cpcellsd(ASP, (CELL *)((char *)LOCAL_OldASP+LOCAL_BaseDiff), (CELL *)LOCAL_OldTR - LOCAL_OldASP);
#else
cpcellsd(ASP, OldASP, (CELL *)OldTR - OldASP);
cpcellsd(ASP, LOCAL_OldASP, (CELL *)LOCAL_OldTR - LOCAL_OldASP);
#endif
}
@ -221,7 +209,7 @@ CopyLocalAndTrail( USES_REGS1 )
{
/* cpcellsd(To,From,NOfCells) - copy the cells downwards */
#if USE_SYSTEM_MALLOC
cpcellsd((void *)ASP, (void *)OldASP, (CELL *)OldTR - OldASP);
cpcellsd((void *)ASP, (void *)LOCAL_OldASP, (CELL *)LOCAL_OldTR - LOCAL_OldASP);
#endif
}
@ -245,11 +233,11 @@ worker_p_binding(int worker_p, CELL *aux_ptr)
{
CACHE_REGS
if (aux_ptr > H) {
CELL reg = FOREIGN_ThreadHandle(worker_p).current_yaam_regs->LCL0_[aux_ptr-LCL0];
CELL reg = REMOTE_ThreadHandle(worker_p).current_yaam_regs->LCL0_[aux_ptr-LCL0];
reg = AdjustGlobTerm(reg PASS_REGS);
return reg;
} else {
CELL reg = FOREIGN_ThreadHandle(worker_p).current_yaam_regs-> H0_[aux_ptr-H0];
CELL reg = REMOTE_ThreadHandle(worker_p).current_yaam_regs-> H0_[aux_ptr-H0];
reg = AdjustGlobTerm(reg PASS_REGS);
return reg;
}
@ -275,7 +263,7 @@ RestoreTrail(int worker_p USES_REGS)
if (IsVarTerm(aux_cell)) {
if (aux_cell < LOCAL_start_global_copy || EQUAL_OR_YOUNGER_CP((choiceptr)LOCAL_end_local_copy, (choiceptr)aux_cell)) {
YAPOR_ERROR_CHECKING((CELL *)aux_cell < H0, "RestoreTrail: aux_cell < H0");
YAPOR_ERROR_CHECKING((ADDR)aux_cell > Yap_LocalBase, "RestoreTrail: aux_cell > LocalBase");
YAPOR_ERROR_CHECKING((ADDR)aux_cell > LOCAL_LocalBase, "RestoreTrail: aux_cell > LocalBase");
#ifdef TABLING
*((CELL *) aux_cell) = TrailVal(aux_tr);
#else
@ -286,7 +274,7 @@ RestoreTrail(int worker_p USES_REGS)
} else if (IsPairTerm(aux_cell)) {
/* avoid frozen segments */
aux_cell = (CELL) RepPair(aux_cell);
if (IN_BETWEEN(Yap_TrailBase, aux_cell, Yap_TrailTop)) {
if (IN_BETWEEN(LOCAL_TrailBase, aux_cell, LOCAL_TrailTop)) {
aux_tr = (tr_fr_ptr) aux_cell;
}
#endif /* TABLING */
@ -319,7 +307,7 @@ MoveGlobal( USES_REGS1 )
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
* absmi.asm
*/
cpcellsd((CELL *)Yap_GlobalBase, (CELL *)OldGlobalBase, OldH - (CELL *)OldGlobalBase);
cpcellsd((CELL *)LOCAL_GlobalBase, (CELL *)LOCAL_OldGlobalBase, LOCAL_OldH - (CELL *)LOCAL_OldGlobalBase);
}
static void
@ -329,7 +317,7 @@ MoveExpandedGlobal( USES_REGS1 )
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
* absmi.asm
*/
cpcellsd((CELL *)(Yap_GlobalBase+(GDiff-BaseDiff)), (CELL *)Yap_GlobalBase, OldH - (CELL *)OldGlobalBase);
cpcellsd((CELL *)(LOCAL_GlobalBase+(LOCAL_GDiff-LOCAL_BaseDiff)), (CELL *)LOCAL_GlobalBase, LOCAL_OldH - (CELL *)LOCAL_OldGlobalBase);
}
static void
@ -340,9 +328,9 @@ MoveGlobalWithHole( USES_REGS1 )
* absmi.asm
*/
#if USE_SYSTEM_MALLOC
cpcellsd((CELL *)((char *)Yap_GlobalBase+(GDiff0-BaseDiff)), (CELL *)Yap_GlobalBase, OldH - (CELL *)OldGlobalBase);
cpcellsd((CELL *)((char *)LOCAL_GlobalBase+(LOCAL_GDiff0-LOCAL_BaseDiff)), (CELL *)LOCAL_GlobalBase, LOCAL_OldH - (CELL *)LOCAL_OldGlobalBase);
#else
cpcellsd((CELL *)((char *)OldGlobalBase+GDiff0), (CELL *)OldGlobalBase, OldH - (CELL *)OldGlobalBase);
cpcellsd((CELL *)((char *)LOCAL_OldGlobalBase+LOCAL_GDiff0), (CELL *)LOCAL_OldGlobalBase, LOCAL_OldH - (CELL *)LOCAL_OldGlobalBase);
#endif
}
@ -353,9 +341,9 @@ MoveHalfGlobal(CELL *OldPt USES_REGS)
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
* absmi.asm
*/
UInt diff = OldH-OldPt;
CELL *NewPt = (CELL *)((char*)OldPt+GDiff);
CELL *IntPt = (CELL *)((char*)OldPt+GDiff0);
UInt diff = LOCAL_OldH-OldPt;
CELL *NewPt = (CELL *)((char*)OldPt+LOCAL_GDiff);
CELL *IntPt = (CELL *)((char*)OldPt+LOCAL_GDiff0);
cpcellsd(NewPt, IntPt, diff);
}
@ -373,7 +361,7 @@ AdjustAppl(register CELL t0 USES_REGS)
#ifdef DEBUG
else {
/* strange cell */
/* fprintf(Yap_stderr,"% garbage appl %lx found in stacks by stack shifter\n", t0);*/
/* fprintf(GLOBAL_stderr,"% garbage appl %lx found in stacks by stack shifter\n", t0);*/
}
#endif
return(t0);
@ -391,7 +379,7 @@ AdjustPair(register CELL t0 USES_REGS)
else if (IsHeapP(t))
return (AbsPair(CellPtoHeapAdjust(t)));
#ifdef DEBUG
/* fprintf(Yap_stderr,"% garbage pair %lx found in stacks by stack shifter\n", t0);*/
/* fprintf(GLOBAL_stderr,"% garbage pair %lx found in stacks by stack shifter\n", t0);*/
#endif
return(t0);
}
@ -399,7 +387,7 @@ AdjustPair(register CELL t0 USES_REGS)
static void
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)LOCAL_TrailBase;
#if defined(YAPOR_THREADS)
if (thread_copying == STACK_INCREMENTAL_COPYING) {
@ -518,9 +506,9 @@ static void
AdjustGlobal(long sz, int thread_copying USES_REGS)
{
CELL *pt, *pt_max;
ArrayEntry *al = DynamicArrays;
StaticArrayEntry *sal = StaticArrays;
GlobalEntry *gl = GlobalVariables;
ArrayEntry *al = LOCAL_DynamicArrays;
StaticArrayEntry *sal = LOCAL_StaticArrays;
GlobalEntry *gl = LOCAL_GlobalVariables;
while (al) {
al->ValueOfVE = AdjustGlobTerm(al->ValueOfVE PASS_REGS);
@ -736,10 +724,10 @@ AdjustScannerStacks(TokEntry **tksp, VarEntry **vep USES_REGS)
ves = *vep = (VarEntry *)TrailAddrAdjust((ADDR)ves);
AdjustVarTable(ves PASS_REGS);
}
ves = Yap_AnonVarTable;
ves = LOCAL_AnonVarTable;
if (ves != NULL) {
if (IsOldVarTableTrailPtr(ves))
ves = Yap_AnonVarTable = VarEntryAdjust(ves);
ves = LOCAL_AnonVarTable = VarEntryAdjust(ves);
}
while (ves != NULL) {
VarEntry *vetmp = ves->VarLeft;
@ -773,47 +761,47 @@ static_growheap(long size, int fix_code, struct intermediates *cip, tr_fr_ptr *o
if (size < YAP_ALLOC_SIZE)
size = YAP_ALLOC_SIZE;
size = AdjustPageSize(size);
Yap_ErrorMessage = NULL;
LOCAL_ErrorMessage = NULL;
if (!Yap_ExtendWorkSpace(size)) {
Int min_size = AdjustPageSize(((CELL)Yap_TrailTop-(CELL)Yap_GlobalBase)+MinHeapGap);
Int min_size = AdjustPageSize(((CELL)LOCAL_TrailTop-(CELL)LOCAL_GlobalBase)+MinHeapGap);
Yap_ErrorMessage = NULL;
LOCAL_ErrorMessage = NULL;
if (size < min_size) size = min_size;
minimal_request = size;
size = Yap_ExtendWorkSpaceThroughHole(size);
if (size < 0) {
Yap_ErrorMessage = "Database crashed against Stacks";
LOCAL_ErrorMessage = "Database crashed against Stacks";
return FALSE;
}
}
start_growth_time = Yap_cputime();
gc_verbose = Yap_is_gc_verbose();
heap_overflows++;
LOCAL_heap_overflows++;
if (gc_verbose) {
#if defined(YAPOR_THREADS)
fprintf(Yap_stderr, "%% Worker Id %d:\n", worker_id);
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
#endif
fprintf(Yap_stderr, "%% Database Overflow %d\n", heap_overflows);
fprintf(Yap_stderr, "%% growing the heap %ld bytes\n", size);
fprintf(GLOBAL_stderr, "%% Database Overflow %d\n", LOCAL_heap_overflows);
fprintf(GLOBAL_stderr, "%% growing the heap %ld bytes\n", size);
}
/* CreepFlag is set to force heap expansion */
if (ActiveSignals == YAP_CDOVF_SIGNAL) {
LOCK(SignalLock);
if (LOCAL_ActiveSignals == YAP_CDOVF_SIGNAL) {
LOCK(LOCAL_SignalLock);
CreepFlag = CalculateStackGap();
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
}
ASP -= 256;
YAPEnterCriticalSection();
TrDiff = LDiff = GDiff = GDiff0 = DelayDiff = BaseDiff = size;
XDiff = HDiff = 0;
GSplit = NULL;
LOCAL_TrDiff = LOCAL_LDiff = LOCAL_GDiff = LOCAL_GDiff0 = LOCAL_DelayDiff = LOCAL_BaseDiff = size;
LOCAL_XDiff = LOCAL_HDiff = 0;
LOCAL_GSplit = NULL;
SetHeapRegs(FALSE PASS_REGS);
MoveLocalAndTrail( PASS_REGS1 );
if (fix_code) {
CELL *SaveOldH = OldH;
OldH = (CELL *)cip->freep;
CELL *SaveOldH = LOCAL_OldH;
LOCAL_OldH = (CELL *)cip->freep;
MoveGlobal( PASS_REGS1 );
OldH = SaveOldH;
LOCAL_OldH = SaveOldH;
} else {
MoveGlobal( PASS_REGS1 );
}
@ -835,10 +823,10 @@ static_growheap(long size, int fix_code, struct intermediates *cip, tr_fr_ptr *o
if (minimal_request)
Yap_AllocHole(minimal_request, size);
growth_time = Yap_cputime()-start_growth_time;
total_heap_overflow_time += growth_time;
LOCAL_total_heap_overflow_time += growth_time;
if (gc_verbose) {
fprintf(Yap_stderr, "%% took %g sec\n", (double)growth_time/1000);
fprintf(Yap_stderr, "%% Total of %g sec expanding Database\n", (double)total_heap_overflow_time/1000);
fprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
fprintf(GLOBAL_stderr, "%% Total of %g sec expanding Database\n", (double)LOCAL_total_heap_overflow_time/1000);
}
return(TRUE);
}
@ -851,7 +839,7 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit USES_REGS)
UInt start_growth_time, growth_time;
int gc_verbose;
char *omax = (char *)H0;
ADDR old_GlobalBase = Yap_GlobalBase;
ADDR old_GlobalBase = LOCAL_GlobalBase;
UInt minimal_request = 0L;
long size = request;
char vb_msg1 = '\0', *vb_msg2;
@ -867,10 +855,10 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit USES_REGS)
if (hsplit) {
/* just a little bit of sanity checking */
if (hsplit < H0 && hsplit > (CELL *)Yap_GlobalBase) {
if (hsplit < H0 && hsplit > (CELL *)LOCAL_GlobalBase) {
insert_in_delays = TRUE;
/* expanding attributed variables */
if (omax - size > Yap_GlobalBase+4096*sizeof(CELL)) {
if (omax - size > LOCAL_GlobalBase+4096*sizeof(CELL)) {
/* we can just ask for more room */
size = 0;
do_grow = FALSE;
@ -899,30 +887,30 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit USES_REGS)
size = AdjustPageSize(size);
}
/* adjust to a multiple of 256) */
Yap_ErrorMessage = NULL;
Yap_PrologMode |= GrowStackMode;
LOCAL_ErrorMessage = NULL;
LOCAL_PrologMode |= GrowStackMode;
start_growth_time = Yap_cputime();
if (do_grow) {
if (!Yap_AllowGlobalExpansion) {
Yap_ErrorMessage = "Global Stack crashed against Local Stack";
if (!GLOBAL_AllowGlobalExpansion) {
LOCAL_ErrorMessage = "Global Stack crashed against Local Stack";
LeaveGrowMode(GrowStackMode);
return 0;
}
if (!Yap_AllowGlobalExpansion || !Yap_ExtendWorkSpace(size)) {
if (!GLOBAL_AllowGlobalExpansion || !Yap_ExtendWorkSpace(size)) {
/* always fails when using malloc */
Yap_ErrorMessage = NULL;
size += AdjustPageSize(((CELL)Yap_TrailTop-(CELL)Yap_GlobalBase)+MinHeapGap);
LOCAL_ErrorMessage = NULL;
size += AdjustPageSize(((CELL)LOCAL_TrailTop-(CELL)LOCAL_GlobalBase)+MinHeapGap);
minimal_request = size;
size = Yap_ExtendWorkSpaceThroughHole(size);
if (size < 0) {
Yap_ErrorMessage = "Global Stack crashed against Local Stack";
LOCAL_ErrorMessage = "Global Stack crashed against Local Stack";
LeaveGrowMode(GrowStackMode);
return 0;
}
}
}
gc_verbose = Yap_is_gc_verbose();
delay_overflows++;
LOCAL_delay_overflows++;
if (gc_verbose) {
if (hsplit) {
if (hsplit > H0) {
@ -937,10 +925,10 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit USES_REGS)
vb_msg2 = "Delay";
}
#if defined(YAPOR_THREADS)
fprintf(Yap_stderr, "%% Worker Id %d:\n", worker_id);
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
#endif
fprintf(Yap_stderr, "%% %cO %s Overflow %d\n", vb_msg1, vb_msg2, delay_overflows);
fprintf(Yap_stderr, "%% %cO growing the stacks %ld bytes\n", vb_msg1, size);
fprintf(GLOBAL_stderr, "%% %cO %s Overflow %d\n", vb_msg1, vb_msg2, LOCAL_delay_overflows);
fprintf(GLOBAL_stderr, "%% %cO growing the stacks %ld bytes\n", vb_msg1, size);
}
ASP -= 256;
YAPEnterCriticalSection();
@ -949,41 +937,41 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit USES_REGS)
/* we got over a hole */
if (minimal_request) {
/* we went over a hole */
BaseDiff = size+((CELL)Yap_TrailTop-(CELL)Yap_GlobalBase)-minimal_request;
LDiff = TrDiff = size;
LOCAL_BaseDiff = size+((CELL)LOCAL_TrailTop-(CELL)LOCAL_GlobalBase)-minimal_request;
LOCAL_LDiff = LOCAL_TrDiff = size;
} else {
/* we may still have an overflow */
BaseDiff = Yap_GlobalBase - old_GlobalBase;
LOCAL_BaseDiff = LOCAL_GlobalBase - old_GlobalBase;
/* if we grow, we need to move the stacks */
LDiff = TrDiff = BaseDiff+size;
LOCAL_LDiff = LOCAL_TrDiff = LOCAL_BaseDiff+size;
}
} else {
/* stay still */
LDiff = TrDiff = 0;
BaseDiff = 0;
LOCAL_LDiff = LOCAL_TrDiff = 0;
LOCAL_BaseDiff = 0;
}
/* now, remember we have delay -- global with a hole in delay or a
hole in global */
if (!hsplit) {
if (!do_grow) {
DelayDiff = GDiff = GDiff0 = size;
LOCAL_DelayDiff = LOCAL_GDiff = LOCAL_GDiff0 = size;
request = 0L;
} else {
/* expand delay stack */
DelayDiff = GDiff = GDiff0 = LDiff;
LOCAL_DelayDiff = LOCAL_GDiff = LOCAL_GDiff0 = LOCAL_LDiff;
}
} else if (insert_in_delays) {
/* we want to expand a hole for the delay stack */
DelayDiff = size-request;
GDiff = GDiff0 = size;
LOCAL_DelayDiff = size-request;
LOCAL_GDiff = LOCAL_GDiff0 = size;
} else {
/* we want to expand a hole for the delay stack */
GDiff0 = DelayDiff = BaseDiff;
GDiff = BaseDiff+request;
LOCAL_GDiff0 = LOCAL_DelayDiff = LOCAL_BaseDiff;
LOCAL_GDiff = LOCAL_BaseDiff+request;
}
GSplit = hsplit;
XDiff = HDiff = 0;
Yap_GlobalBase = old_GlobalBase;
LOCAL_GSplit = hsplit;
LOCAL_XDiff = LOCAL_HDiff = 0;
LOCAL_GlobalBase = old_GlobalBase;
SetHeapRegs(FALSE PASS_REGS);
if (do_grow) {
MoveLocalAndTrail( PASS_REGS1 );
@ -996,7 +984,7 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit USES_REGS)
MoveExpandedGlobal( PASS_REGS1 );
}
/* don't run through garbage */
if (hsplit && (OldH != hsplit)) {
if (hsplit && (LOCAL_OldH != hsplit)) {
AdjustStacksAndTrail(request, FALSE PASS_REGS);
} else {
AdjustStacksAndTrail(0, FALSE PASS_REGS);
@ -1008,7 +996,7 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit USES_REGS)
if (hsplit) {
if (insert_in_delays) {
/* we have things not quite where we want to have them */
cpcellsd((CELL *)(omax+DelayDiff), (CELL *)(omax+GDiff0), (ADDR)hsplit-omax);
cpcellsd((CELL *)(omax+LOCAL_DelayDiff), (CELL *)(omax+LOCAL_GDiff0), (ADDR)hsplit-omax);
} else {
MoveHalfGlobal(hsplit PASS_REGS);
}
@ -1019,16 +1007,16 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit USES_REGS)
Yap_AllocHole(minimal_request, size);
}
growth_time = Yap_cputime()-start_growth_time;
total_delay_overflow_time += growth_time;
LOCAL_total_delay_overflow_time += growth_time;
if (gc_verbose) {
fprintf(Yap_stderr, "%% %cO took %g sec\n", vb_msg1, (double)growth_time/1000);
fprintf(Yap_stderr, "%% %cO Total of %g sec expanding stacks \n", vb_msg1, (double)total_delay_overflow_time/1000);
fprintf(GLOBAL_stderr, "%% %cO took %g sec\n", vb_msg1, (double)growth_time/1000);
fprintf(GLOBAL_stderr, "%% %cO Total of %g sec expanding stacks \n", vb_msg1, (double)LOCAL_total_delay_overflow_time/1000);
}
LeaveGrowMode(GrowStackMode);
if (hsplit) {
return request;
} else
return GDiff-BaseDiff;
return LOCAL_GDiff-LOCAL_BaseDiff;
}
static void
@ -1246,7 +1234,7 @@ static int
do_growheap(int fix_code, UInt in_size, struct intermediates *cip, tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep USES_REGS)
{
unsigned long size = sizeof(CELL) * K16;
int shift_factor = (heap_overflows > 8 ? 8 : heap_overflows);
int shift_factor = (LOCAL_heap_overflows > 8 ? 8 : LOCAL_heap_overflows);
unsigned long sz = size << shift_factor;
if (sz < in_size) {
@ -1256,10 +1244,10 @@ do_growheap(int fix_code, UInt in_size, struct intermediates *cip, tr_fr_ptr *ol
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"cannot grow Heap: more than a worker/thread running");
return FALSE;
#endif
if (Yap_SizeOfOverflow > sz) {
if (GLOBAL_SizeOfOverflow > sz) {
if (size < YAP_ALLOC_SIZE)
size = YAP_ALLOC_SIZE;
sz = AdjustPageSize(Yap_SizeOfOverflow);
sz = AdjustPageSize(GLOBAL_SizeOfOverflow);
}
while(sz >= sizeof(CELL) * K16 && !static_growheap(sz, fix_code, cip, old_trp, tksp, vep PASS_REGS)) {
size = size/2;
@ -1287,11 +1275,11 @@ do_growheap(int fix_code, UInt in_size, struct intermediates *cip, tr_fr_ptr *ol
fix_tabling_info( PASS_REGS1 );
#endif /* TABLING */
if (sz >= sizeof(CELL) * K16) {
LOCK(SignalLock);
ActiveSignals &= ~YAP_CDOVF_SIGNAL;
if (!ActiveSignals)
LOCK(LOCAL_SignalLock);
LOCAL_ActiveSignals &= ~YAP_CDOVF_SIGNAL;
if (!LOCAL_ActiveSignals)
CreepFlag = CalculateStackGap();
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return TRUE;
}
/* failed */
@ -1342,12 +1330,12 @@ growatomtable( USES_REGS1 )
UInt start_growth_time = Yap_cputime(), growth_time;
int gc_verbose = Yap_is_gc_verbose();
LOCK(SignalLock);
if (ActiveSignals == YAP_CDOVF_SIGNAL) {
LOCK(LOCAL_SignalLock);
if (LOCAL_ActiveSignals == YAP_CDOVF_SIGNAL) {
CreepFlag = CalculateStackGap();
}
ActiveSignals &= ~YAP_CDOVF_SIGNAL;
UNLOCK(SignalLock);
LOCAL_ActiveSignals &= ~YAP_CDOVF_SIGNAL;
UNLOCK(LOCAL_SignalLock);
while ((ntb = (AtomHashEntry *)Yap_AllocCodeSpace(nsize*sizeof(AtomHashEntry))) == NULL) {
/* leave for next time */
#if !USE_SYSTEM_MALLOC
@ -1355,13 +1343,13 @@ growatomtable( USES_REGS1 )
#endif
return FALSE;
}
atom_table_overflows++;
LOCAL_atom_table_overflows ++;
if (gc_verbose) {
#if defined(YAPOR_THREADS)
fprintf(Yap_stderr, "%% Worker Id %d:\n", worker_id);
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
#endif
fprintf(Yap_stderr, "%% Atom Table Overflow %d\n", atom_table_overflows);
fprintf(Yap_stderr, "%% growing the atom table to %ld entries\n", (long int)(nsize));
fprintf(GLOBAL_stderr, "%% Atom Table Overflow %d\n", LOCAL_atom_table_overflows );
fprintf(GLOBAL_stderr, "%% growing the atom table to %ld entries\n", (long int)(nsize));
}
YAPEnterCriticalSection();
init_new_table(ntb, nsize);
@ -1371,10 +1359,10 @@ growatomtable( USES_REGS1 )
AtomHashTableSize = nsize;
YAPLeaveCriticalSection();
growth_time = Yap_cputime()-start_growth_time;
total_atom_table_overflow_time += growth_time;
LOCAL_total_atom_table_overflow_time += growth_time;
if (gc_verbose) {
fprintf(Yap_stderr, "%% took %g sec\n", (double)growth_time/1000);
fprintf(Yap_stderr, "%% Total of %g sec expanding atom table \n", (double)total_atom_table_overflow_time/1000);
fprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
fprintf(GLOBAL_stderr, "%% Total of %g sec expanding atom table \n", (double)LOCAL_total_atom_table_overflow_time/1000);
}
#if USE_SYSTEM_MALLOC
return TRUE;
@ -1401,19 +1389,19 @@ Yap_growheap(int fix_code, UInt in_size, void *cip)
if (NOfAtoms > 2*AtomHashTableSize) {
UInt n = NOfAtoms;
if (Yap_AGcThreshold)
if (GLOBAL_AGcThreshold)
Yap_atom_gc( PASS_REGS1 );
/* check if we have a significant improvement from agc */
if (n > NOfAtoms+ NOfAtoms/10 ||
NOfAtoms > 2*AtomHashTableSize) {
res = growatomtable( PASS_REGS1 );
} else {
LOCK(SignalLock);
if (ActiveSignals == YAP_CDOVF_SIGNAL) {
LOCK(LOCAL_SignalLock);
if (LOCAL_ActiveSignals == YAP_CDOVF_SIGNAL) {
CreepFlag = CalculateStackGap();
}
ActiveSignals &= ~YAP_CDOVF_SIGNAL;
UNLOCK(SignalLock);
LOCAL_ActiveSignals &= ~YAP_CDOVF_SIGNAL;
UNLOCK(LOCAL_SignalLock);
return TRUE;
}
LeaveGrowMode(GrowHeapMode);
@ -1442,12 +1430,12 @@ Yap_growglobal(CELL **ptr)
unsigned long sz = sizeof(CELL) * K16;
#if defined(YAPOR_THREADS)
if (Yap_number_workers != 1) {
if (GLOBAL_number_workers != 1) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,"cannot grow Global: more than a worker/thread running");
return(FALSE);
}
#elif defined(THREADS)
if (Yap_NOfThreads != 1) {
if (GLOBAL_NOfThreads != 1) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,"cannot grow Global: more than a worker/thread running");
return(FALSE);
}
@ -1480,7 +1468,7 @@ Yap_growstack(long size)
CACHE_REGS
int res;
Yap_PrologMode |= GrowStackMode;
LOCAL_PrologMode |= GrowStackMode;
res=growstack(size PASS_REGS);
LeaveGrowMode(GrowStackMode);
return res;
@ -1491,58 +1479,58 @@ execute_growstack(long size0, int from_trail, int in_parser, tr_fr_ptr *old_trp,
{
UInt minimal_request = 0L;
long size = size0;
ADDR old_Yap_GlobalBase = Yap_GlobalBase;
ADDR old_LOCAL_GlobalBase = LOCAL_GlobalBase;
if (!Yap_AllowGlobalExpansion) {
Yap_ErrorMessage = "Database crashed against stacks";
if (!GLOBAL_AllowGlobalExpansion) {
LOCAL_ErrorMessage = "Database crashed against stacks";
return FALSE;
}
if (!Yap_ExtendWorkSpace(size)) {
/* make sure stacks and trail are contiguous */
Yap_ErrorMessage = NULL;
minimal_request = AdjustPageSize(((CELL)Yap_TrailTop-(CELL)Yap_GlobalBase)+4*MinHeapGap+size0);
LOCAL_ErrorMessage = NULL;
minimal_request = AdjustPageSize(((CELL)LOCAL_TrailTop-(CELL)LOCAL_GlobalBase)+4*MinHeapGap+size0);
size = Yap_ExtendWorkSpaceThroughHole(minimal_request);
if (size < 0) {
Yap_ErrorMessage = "Database crashed against stacks";
LOCAL_ErrorMessage = "Database crashed against stacks";
return FALSE;
}
YAPEnterCriticalSection();
GDiff = DelayDiff = BaseDiff = size-size0;
LOCAL_GDiff = LOCAL_DelayDiff = LOCAL_BaseDiff = size-size0;
} else {
YAPEnterCriticalSection();
if (Yap_GlobalBase != old_Yap_GlobalBase) {
GDiff = BaseDiff = DelayDiff = Yap_GlobalBase-old_Yap_GlobalBase;
Yap_GlobalBase=old_Yap_GlobalBase;
if (LOCAL_GlobalBase != old_LOCAL_GlobalBase) {
LOCAL_GDiff = LOCAL_BaseDiff = LOCAL_DelayDiff = LOCAL_GlobalBase-old_LOCAL_GlobalBase;
LOCAL_GlobalBase=old_LOCAL_GlobalBase;
} else {
GDiff = BaseDiff = DelayDiff = 0;
LOCAL_GDiff = LOCAL_BaseDiff = LOCAL_DelayDiff = 0;
}
}
XDiff = HDiff = 0;
GDiff0=GDiff;
LOCAL_XDiff = LOCAL_HDiff = 0;
LOCAL_GDiff0=LOCAL_GDiff;
#if USE_SYSTEM_MALLOC
if (from_trail) {
TrDiff = LDiff = GDiff;
LOCAL_TrDiff = LOCAL_LDiff = LOCAL_GDiff;
} else {
TrDiff = LDiff = size+GDiff;
LOCAL_TrDiff = LOCAL_LDiff = size+LOCAL_GDiff;
}
#else
if (from_trail) {
TrDiff = LDiff = size-size0;
LOCAL_TrDiff = LOCAL_LDiff = size-size0;
} else {
TrDiff = LDiff = size;
LOCAL_TrDiff = LOCAL_LDiff = size;
}
#endif
ASP -= 256;
SetHeapRegs(FALSE PASS_REGS);
if (from_trail) {
Yap_TrailTop += size0;
LOCAL_TrailTop += size0;
}
if (LDiff) {
if (LOCAL_LDiff) {
MoveLocalAndTrail( PASS_REGS1 );
}
if (GDiff) {
if (LOCAL_GDiff) {
#if !USE_SYSTEM_MALLOC
/* That is done by realloc */
MoveGlobal( PASS_REGS1 );
@ -1563,7 +1551,7 @@ execute_growstack(long size0, int from_trail, int in_parser, tr_fr_ptr *old_trp,
#ifdef TABLING
fix_tabling_info( PASS_REGS1 );
#endif /* TABLING */
} else if (LDiff) {
} else if (LOCAL_LDiff) {
if (in_parser) {
tr_fr_ptr nTR;
@ -1599,28 +1587,28 @@ growstack(long size USES_REGS)
if (size < YAP_ALLOC_SIZE)
size = YAP_ALLOC_SIZE;
size = AdjustPageSize(size);
Yap_ErrorMessage = NULL;
LOCAL_ErrorMessage = NULL;
start_growth_time = Yap_cputime();
gc_verbose = Yap_is_gc_verbose();
stack_overflows++;
LOCAL_stack_overflows++;
if (gc_verbose) {
#if defined(YAPOR) || defined(THREADS)
fprintf(Yap_stderr, "%% Worker Id %d:\n", worker_id);
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
#endif
fprintf(Yap_stderr, "%% Stack Overflow %d\n", stack_overflows);
fprintf(Yap_stderr, "%% Global: %8ld cells (%p-%p)\n", (unsigned long int)(H-(CELL *)Yap_GlobalBase),Yap_GlobalBase,H);
fprintf(Yap_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
fprintf(Yap_stderr, "%% Trail:%8ld cells (%p-%p)\n",
(unsigned long int)(TR-(tr_fr_ptr)Yap_TrailBase),Yap_TrailBase,TR);
fprintf(Yap_stderr, "%% Growing the stacks %ld bytes\n", size);
fprintf(GLOBAL_stderr, "%% Stack Overflow %d\n", LOCAL_stack_overflows);
fprintf(GLOBAL_stderr, "%% Global: %8ld cells (%p-%p)\n", (unsigned long int)(H-(CELL *)LOCAL_GlobalBase),LOCAL_GlobalBase,H);
fprintf(GLOBAL_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
fprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
(unsigned long int)(TR-(tr_fr_ptr)LOCAL_TrailBase),LOCAL_TrailBase,TR);
fprintf(GLOBAL_stderr, "%% Growing the stacks %ld bytes\n", size);
}
if (!execute_growstack(size, FALSE, FALSE, NULL, NULL, NULL PASS_REGS))
return FALSE;
growth_time = Yap_cputime()-start_growth_time;
total_stack_overflow_time += growth_time;
LOCAL_total_stack_overflow_time += growth_time;
if (gc_verbose) {
fprintf(Yap_stderr, "%% took %g sec\n", (double)growth_time/1000);
fprintf(Yap_stderr, "%% Total of %g sec expanding stacks \n", (double)total_stack_overflow_time/1000);
fprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
fprintf(GLOBAL_stderr, "%% Total of %g sec expanding stacks \n", (double)LOCAL_total_stack_overflow_time/1000);
}
return TRUE;
}
@ -1634,33 +1622,33 @@ Yap_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
UInt start_growth_time, growth_time;
int gc_verbose;
Yap_PrologMode |= GrowStackMode;
LOCAL_PrologMode |= GrowStackMode;
/* adjust to a multiple of 256) */
size = AdjustPageSize((ADDR)LCL0-Yap_GlobalBase);
Yap_ErrorMessage = NULL;
size = AdjustPageSize((ADDR)LCL0-LOCAL_GlobalBase);
LOCAL_ErrorMessage = NULL;
start_growth_time = Yap_cputime();
gc_verbose = Yap_is_gc_verbose();
stack_overflows++;
LOCAL_stack_overflows++;
if (gc_verbose) {
#if defined(YAPOR) || defined(THREADS)
fprintf(Yap_stderr, "%% Worker Id %d:\n", worker_id);
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
#endif
fprintf(Yap_stderr, "%% Stack Overflow %d\n", stack_overflows);
fprintf(Yap_stderr, "%% Global: %8ld cells (%p-%p)\n", (unsigned long int)(H-(CELL *)Yap_GlobalBase),Yap_GlobalBase,H);
fprintf(Yap_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
fprintf(Yap_stderr, "%% Trail:%8ld cells (%p-%p)\n",
(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(GLOBAL_stderr, "%% Stack Overflow %d\n", LOCAL_stack_overflows);
fprintf(GLOBAL_stderr, "%% Global: %8ld cells (%p-%p)\n", (unsigned long int)(H-(CELL *)LOCAL_GlobalBase),LOCAL_GlobalBase,H);
fprintf(GLOBAL_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
fprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
(unsigned long int)(TR-(tr_fr_ptr)LOCAL_TrailBase),LOCAL_TrailBase,TR);
fprintf(GLOBAL_stderr, "%% Growing the stacks %ld bytes\n", (unsigned long int)size);
}
if (!execute_growstack(size, FALSE, TRUE, old_trp, tksp, vep PASS_REGS)) {
LeaveGrowMode(GrowStackMode);
return FALSE;
}
growth_time = Yap_cputime()-start_growth_time;
total_stack_overflow_time += growth_time;
LOCAL_total_stack_overflow_time += growth_time;
if (gc_verbose) {
fprintf(Yap_stderr, "%% took %g sec\n", (double)growth_time/1000);
fprintf(Yap_stderr, "%% Total of %g sec expanding stacks \n", (double)total_stack_overflow_time/1000);
fprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
fprintf(GLOBAL_stderr, "%% Total of %g sec expanding stacks \n", (double)LOCAL_total_stack_overflow_time/1000);
}
LeaveGrowMode(GrowStackMode);
return TRUE;
@ -1678,7 +1666,7 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr
#endif
/* at least 64K for trail */
if (!size)
size = ((ADDR)TR-Yap_TrailBase);
size = ((ADDR)TR-LOCAL_TrailBase);
size *= 2;
if (size < YAP_ALLOC_SIZE)
size = YAP_ALLOC_SIZE;
@ -1688,58 +1676,58 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr
size=size0;
/* adjust to a multiple of 256) */
size = AdjustPageSize(size);
trail_overflows++;
LOCAL_trail_overflows++;
if (gc_verbose) {
#if defined(YAPOR) || defined(THREADS)
fprintf(Yap_stderr, "%% Worker Id %d:\n", worker_id);
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
#endif
fprintf(Yap_stderr, "%% Trail Overflow %d\n", trail_overflows);
fprintf(GLOBAL_stderr, "%% Trail Overflow %d\n", LOCAL_trail_overflows);
#if USE_SYSTEM_MALLOC
fprintf(Yap_stderr, "%% Heap: %8ld cells (%p-%p)\n", (unsigned long int)(H-(CELL *)Yap_GlobalBase),(CELL *)Yap_GlobalBase,H);
fprintf(Yap_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
fprintf(Yap_stderr, "%% Trail:%8ld cells (%p-%p)\n",
(unsigned long int)(TR-(tr_fr_ptr)Yap_TrailBase),Yap_TrailBase,TR);
fprintf(GLOBAL_stderr, "%% Heap: %8ld cells (%p-%p)\n", (unsigned long int)(H-(CELL *)LOCAL_GlobalBase),(CELL *)LOCAL_GlobalBase,H);
fprintf(GLOBAL_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
fprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
(unsigned long int)(TR-(tr_fr_ptr)LOCAL_TrailBase),LOCAL_TrailBase,TR);
#endif
fprintf(Yap_stderr, "%% growing the trail %ld bytes\n", size);
fprintf(GLOBAL_stderr, "%% growing the trail %ld bytes\n", size);
}
Yap_ErrorMessage = NULL;
if (!Yap_AllowTrailExpansion) {
Yap_ErrorMessage = "Trail Overflow";
LOCAL_ErrorMessage = NULL;
if (!GLOBAL_AllowTrailExpansion) {
LOCAL_ErrorMessage = "Trail Overflow";
return FALSE;
}
#if USE_SYSTEM_MALLOC
execute_growstack(size, TRUE, in_parser, old_trp, tksp, vep PASS_REGS);
#else
if (!Yap_ExtendWorkSpace(size)) {
Yap_ErrorMessage = NULL;
LOCAL_ErrorMessage = NULL;
if (contiguous_only) {
/* I can't expand in this case */
trail_overflows--;
LOCAL_trail_overflows--;
return FALSE;
}
execute_growstack(size, TRUE, in_parser, old_trp, tksp, vep PASS_REGS);
} else {
YAPEnterCriticalSection();
if (in_parser) {
TrDiff = LDiff = GDiff = BaseDiff = DelayDiff = XDiff = HDiff = GDiff0 = 0;
LOCAL_TrDiff = LOCAL_LDiff = LOCAL_GDiff = LOCAL_BaseDiff = LOCAL_DelayDiff = LOCAL_XDiff = LOCAL_HDiff = LOCAL_GDiff0 = 0;
AdjustScannerStacks(tksp, vep PASS_REGS);
}
Yap_TrailTop += size;
LOCAL_TrailTop += size;
YAPLeaveCriticalSection();
}
#endif
growth_time = Yap_cputime()-start_growth_time;
total_trail_overflow_time += growth_time;
LOCAL_total_trail_overflow_time += growth_time;
if (gc_verbose) {
fprintf(Yap_stderr, "%% took %g sec\n", (double)growth_time/1000);
fprintf(Yap_stderr, "%% Total of %g sec expanding trail \n", (double)total_trail_overflow_time/1000);
fprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
fprintf(GLOBAL_stderr, "%% Total of %g sec expanding trail \n", (double)LOCAL_total_trail_overflow_time/1000);
}
LOCK(SignalLock);
if (ActiveSignals == YAP_TROVF_SIGNAL) {
LOCK(LOCAL_SignalLock);
if (LOCAL_ActiveSignals == YAP_TROVF_SIGNAL) {
CreepFlag = CalculateStackGap();
}
ActiveSignals &= ~YAP_TROVF_SIGNAL;
UNLOCK(SignalLock);
LOCAL_ActiveSignals &= ~YAP_TROVF_SIGNAL;
UNLOCK(LOCAL_SignalLock);
return TRUE;
}
@ -1801,8 +1789,8 @@ Yap_shift_visit(CELL **to_visit, CELL ***to_visit_maxp)
static Int
p_inform_trail_overflows( USES_REGS1 )
{
Term tn = MkIntTerm(trail_overflows);
Term tt = MkIntegerTerm(total_trail_overflow_time);
Term tn = MkIntTerm(LOCAL_trail_overflows);
Term tt = MkIntegerTerm(LOCAL_total_trail_overflow_time);
return(Yap_unify(tn, ARG1) && Yap_unify(tt, ARG2));
}
@ -1831,8 +1819,8 @@ p_growheap( USES_REGS1 )
static Int
p_inform_heap_overflows( USES_REGS1 )
{
Term tn = MkIntTerm(heap_overflows);
Term tt = MkIntegerTerm(total_heap_overflow_time);
Term tn = MkIntTerm(LOCAL_heap_overflows);
Term tt = MkIntegerTerm(LOCAL_total_heap_overflow_time);
return(Yap_unify(tn, ARG1) && Yap_unify(tt, ARG2));
}
@ -1845,40 +1833,40 @@ Yap_CopyThreadStacks(int worker_q, int worker_p, int incremental)
Int size;
/* make sure both stacks have same size */
Int p_size = FOREIGN_ThreadHandle(worker_p).ssize+FOREIGN_ThreadHandle(worker_p).tsize;
Int q_size = FOREIGN_ThreadHandle(worker_q).ssize+FOREIGN_ThreadHandle(worker_q).tsize;
Int p_size = REMOTE_ThreadHandle(worker_p).ssize+REMOTE_ThreadHandle(worker_p).tsize;
Int q_size = REMOTE_ThreadHandle(worker_q).ssize+REMOTE_ThreadHandle(worker_q).tsize;
if (p_size != q_size) {
if (!(FOREIGN_ThreadHandle(worker_q).stack_address = realloc(FOREIGN_ThreadHandle(worker_q).stack_address,p_size*K1))) {
if (!(REMOTE_ThreadHandle(worker_q).stack_address = realloc(REMOTE_ThreadHandle(worker_q).stack_address,p_size*K1))) {
exit(1);
}
}
FOREIGN_ThreadHandle(worker_q).ssize = FOREIGN_ThreadHandle(worker_p).ssize;
FOREIGN_ThreadHandle(worker_q).tsize = FOREIGN_ThreadHandle(worker_p).tsize;
REMOTE_ThreadHandle(worker_q).ssize = REMOTE_ThreadHandle(worker_p).ssize;
REMOTE_ThreadHandle(worker_q).tsize = REMOTE_ThreadHandle(worker_p).tsize;
/* compute offset indicators */
Yap_GlobalBase = Yap_thread_gl[worker_p].global_base;
Yap_LocalBase = Yap_thread_gl[worker_p].local_base;
Yap_TrailBase = Yap_thread_gl[worker_p].trail_base;
Yap_TrailTop = Yap_thread_gl[worker_p].trail_top;
size = FOREIGN_ThreadHandle(worker_q).stack_address-FOREIGN_ThreadHandle(worker_p).stack_address;
TrDiff = LDiff = GDiff = GDiff0 = DelayDiff = BaseDiff = size;
XDiff = HDiff = 0;
GSplit = NULL;
H = FOREIGN_ThreadHandle(worker_p).current_yaam_regs->H_;
H0 = FOREIGN_ThreadHandle(worker_p).current_yaam_regs->H0_;
B = FOREIGN_ThreadHandle(worker_p).current_yaam_regs->B_;
ENV = FOREIGN_ThreadHandle(worker_p).current_yaam_regs->ENV_;
YENV = FOREIGN_ThreadHandle(worker_p).current_yaam_regs->YENV_;
ASP = FOREIGN_ThreadHandle(worker_p).current_yaam_regs->ASP_;
TR = FOREIGN_ThreadHandle(worker_p).current_yaam_regs->TR_;
LOCAL_GlobalBase = REMOTE_GlobalBase(worker_p);
LOCAL_LocalBase = REMOTE_LocalBase(worker_p);
LOCAL_TrailBase = REMOTE_TrailBase(worker_p);
LOCAL_TrailTop = REMOTE_TrailTop(worker_p);
size = REMOTE_ThreadHandle(worker_q).stack_address-REMOTE_ThreadHandle(worker_p).stack_address;
LOCAL_TrDiff = LOCAL_LDiff = LOCAL_GDiff = LOCAL_GDiff0 = LOCAL_DelayDiff = LOCAL_BaseDiff = size;
LOCAL_XDiff = LOCAL_HDiff = 0;
LOCAL_GSplit = NULL;
H = REMOTE_ThreadHandle(worker_p).current_yaam_regs->H_;
H0 = REMOTE_ThreadHandle(worker_p).current_yaam_regs->H0_;
B = REMOTE_ThreadHandle(worker_p).current_yaam_regs->B_;
ENV = REMOTE_ThreadHandle(worker_p).current_yaam_regs->ENV_;
YENV = REMOTE_ThreadHandle(worker_p).current_yaam_regs->YENV_;
ASP = REMOTE_ThreadHandle(worker_p).current_yaam_regs->ASP_;
TR = REMOTE_ThreadHandle(worker_p).current_yaam_regs->TR_;
if (ASP > CellPtr(B))
ASP = CellPtr(B);
LCL0 = FOREIGN_ThreadHandle(worker_p).current_yaam_regs->LCL0_;
LCL0 = REMOTE_ThreadHandle(worker_p).current_yaam_regs->LCL0_;
#ifdef CUT_C
Yap_REGS.CUT_C_TOP = FOREIGN_ThreadHandle(worker_p).current_yaam_regs->CUT_C_TOP;
Yap_REGS.CUT_C_TOP = REMOTE_ThreadHandle(worker_p).current_yaam_regs->CUT_C_TOP;
#endif
DynamicArrays = NULL;
StaticArrays = NULL;
GlobalVariables = NULL;
LOCAL_DynamicArrays = NULL;
LOCAL_StaticArrays = NULL;
LOCAL_GlobalVariables = NULL;
SetHeapRegs(TRUE PASS_REGS);
if (incremental) {
IncrementalCopyStacksFromWorker( PASS_REGS1 );
@ -1929,8 +1917,8 @@ p_growstack( USES_REGS1 )
static Int
p_inform_stack_overflows( USES_REGS1 )
{ /* */
Term tn = MkIntTerm(stack_overflows);
Term tt = MkIntegerTerm(total_stack_overflow_time);
Term tn = MkIntTerm(LOCAL_stack_overflows);
Term tt = MkIntegerTerm(LOCAL_total_stack_overflow_time);
return(Yap_unify(tn, ARG1) && Yap_unify(tt, ARG2));
@ -1939,9 +1927,10 @@ p_inform_stack_overflows( USES_REGS1 )
Int
Yap_total_stack_shift_time(void)
{
return(total_heap_overflow_time+
total_stack_overflow_time+
total_trail_overflow_time);
CACHE_REGS
return(LOCAL_total_heap_overflow_time+
LOCAL_total_stack_overflow_time+
LOCAL_total_trail_overflow_time);
}
void

File diff suppressed because it is too large Load Diff

198
C/index.c
View File

@ -832,14 +832,14 @@ sort_group(GroupDef *grp, CELL *top, struct intermediates *cint)
if (!(base = (CELL *)Yap_AllocCodeSpace(2*max*sizeof(CELL)))) {
CACHE_REGS
save_machine_regs();
Yap_Error_Size = 2*max*sizeof(CELL);
LOCAL_Error_Size = 2*max*sizeof(CELL);
siglongjmp(cint->CompilerBotch,2);
}
#else
base = top;
while (top+2*max > (CELL *)Yap_TrailTop) {
while (top+2*max > (CELL *)LOCAL_TrailTop) {
if (!Yap_growtrail(2*max*CellSize, TRUE)) {
Yap_Error_Size = 2*max*CellSize;
LOCAL_Error_Size = 2*max*CellSize;
save_machine_regs();
siglongjmp(cint->CompilerBotch,4);
return;
@ -2058,16 +2058,16 @@ groups_in(ClauseDef *min, ClauseDef *max, GroupDef *grp, struct intermediates *c
}
groups++;
grp++;
while (grp+16 > (GroupDef *)Yap_TrailTop) {
while (grp+16 > (GroupDef *)LOCAL_TrailTop) {
UInt sz = (groups+16)*sizeof(GroupDef);
#if USE_SYSTEM_MALLOC
Yap_Error_Size = sz;
LOCAL_Error_Size = sz;
/* grow stack */
save_machine_regs();
siglongjmp(cint->CompilerBotch,4);
#else
if (!Yap_growtrail(sz, TRUE)) {
Yap_Error_Size = sz;
LOCAL_Error_Size = sz;
save_machine_regs();
siglongjmp(cint->CompilerBotch,4);
return 0;
@ -2197,7 +2197,7 @@ emit_switch_space(UInt n, UInt item_size, struct intermediates *cint, CELL func_
UInt sz = sizeof(LogUpdIndex)+n*item_size;
LogUpdIndex *cl = (LogUpdIndex *)Yap_AllocCodeSpace(sz);
if (cl == NULL) {
Yap_Error_Size = sz;
LOCAL_Error_Size = sz;
/* grow stack */
save_machine_regs();
siglongjmp(cint->CompilerBotch,2);
@ -2218,7 +2218,7 @@ emit_switch_space(UInt n, UInt item_size, struct intermediates *cint, CELL func_
UInt sz = sizeof(StaticIndex)+n*item_size;
StaticIndex *cl = (StaticIndex *)Yap_AllocCodeSpace(sz);
if (cl == NULL) {
Yap_Error_Size = sz;
LOCAL_Error_Size = sz;
/* grow stack */
save_machine_regs();
siglongjmp(cint->CompilerBotch,2);
@ -3147,8 +3147,8 @@ copy_clauses(ClauseDef *max0, ClauseDef *min0, CELL *top, struct intermediates *
{
CACHE_REGS
UInt sz = ((max0+1)-min0)*sizeof(ClauseDef);
if ((char *)top + sz >= Yap_TrailTop-4096) {
Yap_Error_Size = sz;
if ((char *)top + sz >= LOCAL_TrailTop-4096) {
LOCAL_Error_Size = sz;
/* grow stack */
save_machine_regs();
siglongjmp(cint->CompilerBotch,4);
@ -3337,13 +3337,13 @@ compile_index(struct intermediates *cint)
/* only global variable I use directly */
cint->i_labelno = 1;
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
#if USE_SYSTEM_MALLOC
if (!cint->cls) {
cint->cls = (ClauseDef *)Yap_AllocCodeSpace(NClauses*sizeof(ClauseDef));
if (!cint->cls) {
/* tell how much space we need */
Yap_Error_Size += NClauses*sizeof(ClauseDef);
LOCAL_Error_Size += NClauses*sizeof(ClauseDef);
/* grow stack */
save_machine_regs();
siglongjmp(cint->CompilerBotch,2);
@ -3355,7 +3355,7 @@ compile_index(struct intermediates *cint)
cint->cls = (ClauseDef *)H;
if (cint->cls+2*NClauses > (ClauseDef *)(ASP-4096)) {
/* tell how much space we need */
Yap_Error_Size += NClauses*sizeof(ClauseDef);
LOCAL_Error_Size += NClauses*sizeof(ClauseDef);
/* grow stack */
save_machine_regs();
siglongjmp(cint->CompilerBotch,3);
@ -3402,37 +3402,37 @@ Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc)
cint.code_addr = NULL;
cint.blks = NULL;
cint.cls = NULL;
Yap_Error_Size = 0;
LOCAL_Error_Size = 0;
if ((setjres = sigsetjmp(cint.CompilerBotch, 0)) == 3) {
restore_machine_regs();
recover_from_failed_susp_on_cls(&cint, 0);
if (!Yap_gcl(Yap_Error_Size, ap->ArityOfPE+NSlots, ENV, next_pc)) {
if (!Yap_gcl(LOCAL_Error_Size, ap->ArityOfPE+NSlots, ENV, next_pc)) {
CleanCls(&cint);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FAILCODE;
}
} else if (setjres == 2) {
restore_machine_regs();
Yap_Error_Size = recover_from_failed_susp_on_cls(&cint, Yap_Error_Size);
if (!Yap_growheap(FALSE, Yap_Error_Size, NULL)) {
LOCAL_Error_Size = recover_from_failed_susp_on_cls(&cint, LOCAL_Error_Size);
if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) {
CleanCls(&cint);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return FAILCODE;
}
} else if (setjres == 4) {
restore_machine_regs();
recover_from_failed_susp_on_cls(&cint, 0);
if (!Yap_growtrail(Yap_Error_Size, FALSE)) {
if (!Yap_growtrail(LOCAL_Error_Size, FALSE)) {
CleanCls(&cint);
Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, LOCAL_ErrorMessage);
return FAILCODE;
}
} else if (setjres != 0) {
restore_machine_regs();
recover_from_failed_susp_on_cls(&cint, 0);
if (!Yap_growheap(FALSE, Yap_Error_Size, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
CleanCls(&cint);
return FAILCODE;
}
@ -3442,25 +3442,25 @@ Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc)
cint.CodeStart = cint.BlobsStart = cint.cpc = cint.icpc = NULL;
cint.expand_block = NULL;
cint.label_offset = NULL;
Yap_ErrorMessage = NULL;
LOCAL_ErrorMessage = NULL;
if (compile_index(&cint) == (UInt)FAILCODE) {
Yap_ReleaseCMem(&cint);
CleanCls(&cint);
return FAILCODE;
}
#ifdef DEBUG
if (Yap_Option['i' - 'a' + 1]) {
if (GLOBAL_Option['i' - 'a' + 1]) {
Yap_ShowCode(&cint);
}
#endif
/* globals for assembler */
IPredArity = ap->ArityOfPE;
LOCAL_IPredArity = ap->ArityOfPE;
if (cint.CodeStart) {
if ((indx_out = Yap_assemble(ASSEMBLING_INDEX, TermNil, ap, FALSE, &cint, cint.i_labelno+1)) == NULL) {
if (!Yap_growheap(FALSE, Yap_Error_Size, NULL)) {
if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) {
Yap_ReleaseCMem(&cint);
CleanCls(&cint);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return NULL;
}
goto restart_index;
@ -3483,7 +3483,7 @@ static istack_entry *
push_stack(istack_entry *sp, Int arg, Term Tag, Term extra, struct intermediates *cint)
{
CACHE_REGS
if (sp+1 > (istack_entry *)Yap_TrailTop) {
if (sp+1 > (istack_entry *)LOCAL_TrailTop) {
save_machine_regs();
siglongjmp(cint->CompilerBotch,4);
}
@ -4369,7 +4369,7 @@ expand_index(struct intermediates *cint) {
cint->cls = (ClauseDef *)Yap_AllocCodeSpace(nclauses*sizeof(ClauseDef));
if (!cint->cls) {
/* tell how much space we need */
Yap_Error_Size += NClauses*sizeof(ClauseDef);
LOCAL_Error_Size += NClauses*sizeof(ClauseDef);
/* grow stack */
save_machine_regs();
siglongjmp(cint->CompilerBotch,2);
@ -4379,7 +4379,7 @@ expand_index(struct intermediates *cint) {
cint->cls = (ClauseDef *)H;
if (cint->cls+2*nclauses > (ClauseDef *)(ASP-4096)) {
/* tell how much space we need (worst case) */
Yap_Error_Size += 2*NClauses*sizeof(ClauseDef);
LOCAL_Error_Size += 2*NClauses*sizeof(ClauseDef);
/* grow stack */
save_machine_regs();
siglongjmp(cint->CompilerBotch,3);
@ -4397,7 +4397,7 @@ expand_index(struct intermediates *cint) {
cint->cls = (ClauseDef *)Yap_AllocCodeSpace(NClauses*sizeof(ClauseDef));
if (!cint->cls) {
/* tell how much space we need */
Yap_Error_Size += NClauses*sizeof(ClauseDef);
LOCAL_Error_Size += NClauses*sizeof(ClauseDef);
/* grow stack */
save_machine_regs();
siglongjmp(cint->CompilerBotch,2);
@ -4407,7 +4407,7 @@ expand_index(struct intermediates *cint) {
cint->cls = (ClauseDef *)H;
if (cint->cls+2*NClauses > (ClauseDef *)(ASP-4096)) {
/* tell how much space we need (worst case) */
Yap_Error_Size += 2*NClauses*sizeof(ClauseDef);
LOCAL_Error_Size += 2*NClauses*sizeof(ClauseDef);
save_machine_regs();
siglongjmp(cint->CompilerBotch,3);
}
@ -4513,11 +4513,11 @@ ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop USES_REGS) {
restore_machine_regs();
/* grow stack */
recover_from_failed_susp_on_cls(&cint, 0);
Yap_gcl(Yap_Error_Size, ap->ArityOfPE+ExtraArgs, ENV, nextop);
Yap_gcl(LOCAL_Error_Size, ap->ArityOfPE+ExtraArgs, ENV, nextop);
} else if (cb == 2) {
restore_machine_regs();
Yap_Error_Size = recover_from_failed_susp_on_cls(&cint, Yap_Error_Size);
if (!Yap_growheap(FALSE, Yap_Error_Size, NULL)) {
LOCAL_Error_Size = recover_from_failed_susp_on_cls(&cint, LOCAL_Error_Size);
if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) {
save_machine_regs();
if (ap->PredFlags & LogUpdatePredFlag) {
Yap_kill_iblock((ClauseUnion *)ClauseCodeToLogUpdIndex(ap->cs.p_code.TrueCodeOfPred),NULL, ap);
@ -4540,14 +4540,14 @@ ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop USES_REGS) {
#if defined(YAPOR) || defined(THREADS)
}
#endif
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
CleanCls(&cint);
return FAILCODE;
}
} else if (cb == 4) {
restore_machine_regs();
Yap_ReleaseCMem(&cint);
if (!Yap_growtrail(Yap_Error_Size, FALSE)) {
if (!Yap_growtrail(LOCAL_Error_Size, FALSE)) {
save_machine_regs();
if (ap->PredFlags & LogUpdatePredFlag) {
Yap_kill_iblock((ClauseUnion *)ClauseCodeToLogUpdIndex(ap->cs.p_code.TrueCodeOfPred),NULL, ap);
@ -4564,25 +4564,25 @@ ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop USES_REGS) {
restart_index:
cint.CodeStart = cint.cpc = cint.BlobsStart = cint.icpc = NIL;
cint.CurrentPred = ap;
Yap_ErrorMessage = NULL;
Yap_Error_Size = 0;
LOCAL_ErrorMessage = NULL;
LOCAL_Error_Size = 0;
if (P->opc == Yap_opcode(_expand_clauses)) {
expand_clauses = P;
} else {
expand_clauses = NULL;
}
#ifdef DEBUG
if (Yap_Option['i' - 'a' + 1]) {
if (GLOBAL_Option['i' - 'a' + 1]) {
Term tmod = ap->ModuleOfPred;
if (!tmod) tmod = TermProlog;
#if THREADS
Yap_DebugPlWrite(MkIntegerTerm(worker_id));
Yap_DebugPutc(Yap_c_error_stream,' ');
Yap_DebugPutc(LOCAL_c_error_stream,' ');
#endif
Yap_DebugPutc(Yap_c_error_stream,'>');
Yap_DebugPutc(Yap_c_error_stream,'\t');
Yap_DebugPutc(LOCAL_c_error_stream,'>');
Yap_DebugPutc(LOCAL_c_error_stream,'\t');
Yap_DebugPlWrite(tmod);
Yap_DebugPutc(Yap_c_error_stream,':');
Yap_DebugPutc(LOCAL_c_error_stream,':');
if (ap->ModuleOfPred == IDB_MODULE) {
Term t = Deref(ARG1);
if (IsAtomTerm(t)) {
@ -4593,7 +4593,7 @@ ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop USES_REGS) {
Functor f = FunctorOfTerm(t);
Atom At = NameOfFunctor(f);
Yap_DebugPlWrite(MkAtomTerm(At));
Yap_DebugPutc(Yap_c_error_stream,'/');
Yap_DebugPutc(LOCAL_c_error_stream,'/');
Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f)));
}
} else {
@ -4604,14 +4604,14 @@ ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop USES_REGS) {
Functor f = ap->FunctorOfPred;
Atom At = NameOfFunctor(f);
Yap_DebugPlWrite(MkAtomTerm(At));
Yap_DebugPutc(Yap_c_error_stream,'/');
Yap_DebugPutc(LOCAL_c_error_stream,'/');
Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f)));
}
}
Yap_DebugPutc(Yap_c_error_stream,'\n');
Yap_DebugPutc(LOCAL_c_error_stream,'\n');
#if THREADS
Yap_DebugPlWrite(MkIntegerTerm(worker_id));
Yap_DebugPutc(Yap_c_error_stream,' ');
Yap_DebugPutc(LOCAL_c_error_stream,' ');
#endif
}
#endif
@ -4634,16 +4634,16 @@ ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop USES_REGS) {
return FAILCODE;
}
#ifdef DEBUG
if (Yap_Option['i' - 'a' + 1]) {
if (GLOBAL_Option['i' - 'a' + 1]) {
Yap_ShowCode(&cint);
}
#endif
/* globals for assembler */
IPredArity = ap->ArityOfPE;
LOCAL_IPredArity = ap->ArityOfPE;
if (cint.CodeStart) {
if ((indx_out = Yap_assemble(ASSEMBLING_EINDEX, TermNil, ap, FALSE, &cint, cint.i_labelno+1)) == NULL) {
if (!Yap_growheap(FALSE, Yap_Error_Size, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
Yap_ReleaseCMem(&cint);
CleanCls(&cint);
return FAILCODE;
@ -4715,7 +4715,7 @@ static path_stack_entry *
push_path(path_stack_entry *sp, yamop **pipc, ClauseDef *clp, struct intermediates *cint)
{
CACHE_REGS
if (sp+1 > (path_stack_entry *)Yap_TrailTop) {
if (sp+1 > (path_stack_entry *)LOCAL_TrailTop) {
save_machine_regs();
siglongjmp(cint->CompilerBotch,4);
}
@ -4732,7 +4732,7 @@ static path_stack_entry *
fetch_new_block(path_stack_entry *sp, yamop **pipc, PredEntry *ap, struct intermediates *cint)
{
CACHE_REGS
if (sp+1 > (path_stack_entry *)Yap_TrailTop) {
if (sp+1 > (path_stack_entry *)LOCAL_TrailTop) {
save_machine_regs();
siglongjmp(cint->CompilerBotch,4);
}
@ -6028,31 +6028,31 @@ Yap_AddClauseToIndex(PredEntry *ap, yamop *beg, int first) {
cint.CodeStart = cint.BlobsStart = cint.cpc = cint.icpc = NIL;
if ((cb = sigsetjmp(cint.CompilerBotch, 0)) == 3) {
restore_machine_regs();
Yap_gcl(Yap_Error_Size, ap->ArityOfPE, ENV, CP);
Yap_gcl(LOCAL_Error_Size, ap->ArityOfPE, ENV, CP);
save_machine_regs();
} else if (cb == 2) {
restore_machine_regs();
Yap_growheap(FALSE, Yap_Error_Size, NULL);
Yap_growheap(FALSE, LOCAL_Error_Size, NULL);
save_machine_regs();
} else if (cb == 4) {
restore_machine_regs();
Yap_growtrail(Yap_Error_Size, FALSE);
Yap_growtrail(LOCAL_Error_Size, FALSE);
save_machine_regs();
}
if (cb) {
Yap_RemoveIndexation(ap);
return;
}
Yap_Error_Size = 0;
Yap_ErrorMessage = NULL;
LOCAL_Error_Size = 0;
LOCAL_ErrorMessage = NULL;
#ifdef DEBUG
if (Yap_Option['i' - 'a' + 1]) {
if (GLOBAL_Option['i' - 'a' + 1]) {
Term tmod = ap->ModuleOfPred;
if (!tmod) tmod = TermProlog;
Yap_DebugPutc(Yap_c_error_stream,'+');
Yap_DebugPutc(Yap_c_error_stream,'\t');
Yap_DebugPutc(LOCAL_c_error_stream,'+');
Yap_DebugPutc(LOCAL_c_error_stream,'\t');
Yap_DebugPlWrite(tmod);
Yap_DebugPutc(Yap_c_error_stream,':');
Yap_DebugPutc(LOCAL_c_error_stream,':');
if (ap->ModuleOfPred == IDB_MODULE) {
Term t = Deref(ARG1);
if (IsAtomTerm(t)) {
@ -6063,7 +6063,7 @@ Yap_AddClauseToIndex(PredEntry *ap, yamop *beg, int first) {
Functor f = FunctorOfTerm(t);
Atom At = NameOfFunctor(f);
Yap_DebugPlWrite(MkAtomTerm(At));
Yap_DebugPutc(Yap_c_error_stream,'/');
Yap_DebugPutc(LOCAL_c_error_stream,'/');
Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f)));
}
} else {
@ -6074,11 +6074,11 @@ Yap_AddClauseToIndex(PredEntry *ap, yamop *beg, int first) {
Functor f = ap->FunctorOfPred;
Atom At = NameOfFunctor(f);
Yap_DebugPlWrite(MkAtomTerm(At));
Yap_DebugPutc(Yap_c_error_stream,'/');
Yap_DebugPutc(LOCAL_c_error_stream,'/');
Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f)));
}
}
Yap_DebugPutc(Yap_c_error_stream,'\n');
Yap_DebugPutc(LOCAL_c_error_stream,'\n');
}
#endif
stack = (path_stack_entry *)TR;
@ -6504,19 +6504,19 @@ Yap_RemoveClauseFromIndex(PredEntry *ap, yamop *beg) {
cint.CodeStart = cint.BlobsStart = cint.cpc = cint.icpc = NULL;
if ((cb = sigsetjmp(cint.CompilerBotch, 0)) == 3) {
restore_machine_regs();
Yap_gcl(Yap_Error_Size, ap->ArityOfPE, ENV, CP);
Yap_gcl(LOCAL_Error_Size, ap->ArityOfPE, ENV, CP);
save_machine_regs();
} else if (cb == 2) {
restore_machine_regs();
Yap_growheap(FALSE, Yap_Error_Size, NULL);
Yap_growheap(FALSE, LOCAL_Error_Size, NULL);
save_machine_regs();
} else if (cb == 4) {
restore_machine_regs();
Yap_growtrail(Yap_Error_Size, FALSE);
Yap_growtrail(LOCAL_Error_Size, FALSE);
save_machine_regs();
}
Yap_Error_Size = 0;
Yap_ErrorMessage = NULL;
LOCAL_Error_Size = 0;
LOCAL_ErrorMessage = NULL;
if (cb) {
/* cannot rely on the code */
if (ap->PredFlags & LogUpdatePredFlag) {
@ -6530,14 +6530,14 @@ Yap_RemoveClauseFromIndex(PredEntry *ap, yamop *beg) {
return;
}
#ifdef DEBUG
if (Yap_Option['i' - 'a' + 1]) {
if (GLOBAL_Option['i' - 'a' + 1]) {
Term tmod = ap->ModuleOfPred;
if (!tmod) tmod = TermProlog;
Yap_DebugPutc(Yap_c_error_stream,'-');
Yap_DebugPutc(Yap_c_error_stream,'\t');
Yap_DebugPutc(LOCAL_c_error_stream,'-');
Yap_DebugPutc(LOCAL_c_error_stream,'\t');
Yap_DebugPlWrite(tmod);
Yap_DebugPutc(Yap_c_error_stream,':');
Yap_DebugPutc(LOCAL_c_error_stream,':');
if (ap->ModuleOfPred != IDB_MODULE) {
if (ap->ArityOfPE == 0) {
Atom At = (Atom)ap->FunctorOfPred;
@ -6546,7 +6546,7 @@ Yap_RemoveClauseFromIndex(PredEntry *ap, yamop *beg) {
Functor f = ap->FunctorOfPred;
Atom At = NameOfFunctor(f);
Yap_DebugPlWrite(MkAtomTerm(At));
Yap_DebugPutc(Yap_c_error_stream,'/');
Yap_DebugPutc(LOCAL_c_error_stream,'/');
Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f)));
}
} else {
@ -6560,11 +6560,11 @@ Yap_RemoveClauseFromIndex(PredEntry *ap, yamop *beg) {
Functor f = ap->FunctorOfPred;
Atom At = NameOfFunctor(f);
Yap_DebugPlWrite(MkAtomTerm(At));
Yap_DebugPutc(Yap_c_error_stream,'/');
Yap_DebugPutc(LOCAL_c_error_stream,'/');
Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f)));
}
}
Yap_DebugPutc(Yap_c_error_stream,'\n');
Yap_DebugPutc(LOCAL_c_error_stream,'\n');
}
#endif
stack = (path_stack_entry *)TR;
@ -6656,6 +6656,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
CACHE_REGS
CELL *s_reg = NULL;
Term t = TermNil;
int blob_term = FALSE;
yamop *start_pc = ipc;
choiceptr b0 = NULL;
yamop **jlbl = NULL;
@ -6974,6 +6975,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
/* instructions type e */
case _switch_on_type:
t = Deref(ARG1);
blob_term = FALSE;
if (IsVarTerm(t)) {
jlbl = &(ipc->u.llll.l4);
ipc = ipc->u.llll.l4;
@ -6993,6 +6995,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
break;
case _switch_list_nl:
t = Deref(ARG1);
blob_term = FALSE;
if (IsVarTerm(t)) {
jlbl = &(ipc->u.ollll.l4);
ipc = ipc->u.ollll.l4;
@ -7013,6 +7016,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
break;
case _switch_on_arg_type:
t = Deref(XREGS[arg_from_x(ipc->u.xllll.x)]);
blob_term = FALSE;
if (IsVarTerm(t)) {
jlbl = &(ipc->u.xllll.l4);
ipc = ipc->u.xllll.l4;
@ -7032,6 +7036,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
break;
case _switch_on_sub_arg_type:
t = Deref(s_reg[ipc->u.sllll.s]);
blob_term = FALSE;
if (IsVarTerm(t)) {
jlbl = &(ipc->u.sllll.l4);
ipc = ipc->u.sllll.l4;
@ -7051,6 +7056,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
break;
case _if_not_then:
t = Deref(ARG1);
blob_term = FALSE;
if (IsVarTerm(t)) {
jlbl = &(ipc->u.clll.l3);
ipc = ipc->u.clll.l3;
@ -7086,14 +7092,17 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
break;
case _index_dbref:
t = AbsAppl(s_reg-1);
blob_term = FALSE;
ipc = NEXTOP(ipc,e);
break;
case _index_blob:
t = Yap_DoubleP_key(s_reg);
blob_term = TRUE;
ipc = NEXTOP(ipc,e);
break;
case _index_long:
t = Yap_IntP_key(s_reg);
blob_term = TRUE;
ipc = NEXTOP(ipc,e);
break;
case _switch_on_cons:
@ -7114,8 +7123,13 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
break;
case _expand_index:
case _expand_clauses:
XREGS[ap->ArityOfPE+1] = (CELL)s_reg;
XREGS[ap->ArityOfPE+2] = (CELL)t;
if (blob_term) { /* protect garbage collector */
XREGS[ap->ArityOfPE+1] = (CELL)&XREGS[ap->ArityOfPE+1];
XREGS[ap->ArityOfPE+2] = TermNil;
} else {
XREGS[ap->ArityOfPE+1] = (CELL)s_reg;
XREGS[ap->ArityOfPE+2] = t;
}
XREGS[ap->ArityOfPE+3] = Terms[0];
XREGS[ap->ArityOfPE+4] = Terms[1];
XREGS[ap->ArityOfPE+5] = Terms[2];
@ -7126,8 +7140,11 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
}
#endif
ipc = ExpandIndex(ap, 5, cp_pc PASS_REGS);
s_reg = (CELL *)XREGS[ap->ArityOfPE+1];
t = XREGS[ap->ArityOfPE+2];
if (!blob_term) { /* protect garbage collector */
s_reg = (CELL *)XREGS[ap->ArityOfPE+1];
t = XREGS[ap->ArityOfPE+2];
}
blob_term = FALSE;
Terms[0] = XREGS[ap->ArityOfPE+3];
Terms[1] = XREGS[ap->ArityOfPE+4];
Terms[2] = XREGS[ap->ArityOfPE+5];
@ -7151,15 +7168,22 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
break;
}
case _index_pred:
XREGS[ap->ArityOfPE+1] = (CELL)s_reg;
XREGS[ap->ArityOfPE+2] = (CELL)t;
if (blob_term) { /* protect garbage collector */
XREGS[ap->ArityOfPE+1] = (CELL)&XREGS[ap->ArityOfPE+1];
XREGS[ap->ArityOfPE+2] = TermNil;
} else {
XREGS[ap->ArityOfPE+1] = (CELL)s_reg;
XREGS[ap->ArityOfPE+2] = t;
}
XREGS[ap->ArityOfPE+3] = Terms[0];
XREGS[ap->ArityOfPE+4] = Terms[1];
XREGS[ap->ArityOfPE+5] = Terms[2];
Yap_IPred(ap, 5, cp_pc);
start_pc = ipc = ap->cs.p_code.TrueCodeOfPred;
s_reg = (CELL *)XREGS[ap->ArityOfPE+1];
t = XREGS[ap->ArityOfPE+2];
if (!blob_term) { /* protect garbage collector */
s_reg = (CELL *)XREGS[ap->ArityOfPE+1];
t = XREGS[ap->ArityOfPE+2];
}
Terms[0] = XREGS[ap->ArityOfPE+3];
Terms[1] = XREGS[ap->ArityOfPE+4];
Terms[2] = XREGS[ap->ArityOfPE+5];

271
C/init.c
View File

@ -34,8 +34,11 @@ static char SccsId[] = "%W% %G%";
#include "tracer.h"
#endif
#ifdef YAPOR
#ifdef YAPOR_COW
#include <signal.h>
#endif /* YAPOR_COW */
#include "or.macros.h"
#endif /* YAPOR */
#endif /* YAPOR */
#if defined(YAPOR) || defined(TABLING)
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
@ -55,7 +58,6 @@ static char SccsId[] = "%W% %G%";
#define LOGFILE "logfile"
int Yap_output_msg = FALSE;
#ifdef MACC
STATIC_PROTO(void InTTYLine, (char *));
@ -73,118 +75,15 @@ STATIC_PROTO(void InitStdPreds,(void));
STATIC_PROTO(void InitFlags, (void));
STATIC_PROTO(void InitCodes, (void));
STATIC_PROTO(void InitVersion, (void));
STD_PROTO(void exit, (int));
static void InitWorker(int wid);
STD_PROTO(void exit, (int));
/************** YAP PROLOG GLOBAL VARIABLES *************************/
/************* variables related to memory allocation ***************/
#if defined(THREADS)
ADDR Yap_HeapBase;
struct restore_info rinfo[MAX_THREADS];
struct thread_globs Yap_thread_gl[MAX_THREADS];
pthread_t Yap_master_thread;
#else
struct restore_info rinfo;
ADDR Yap_HeapBase,
Yap_LocalBase,
Yap_GlobalBase,
Yap_TrailBase,
Yap_TrailTop;
/************ variables concerned with Error Handling *************/
char *Yap_ErrorMessage; /* used to pass error messages */
Term Yap_Error_Term; /* used to pass error terms */
yap_error_number Yap_Error_TYPE; /* used to pass the error */
UInt Yap_Error_Size; /* used to pass a size associated with an error */
/******************* storing error messages ****************************/
char Yap_ErrorSay[MAX_ERROR_MSG_SIZE];
/* if we botched in a LongIO operation */
jmp_buf Yap_IOBotch;
/* if we botched in the compiler */
jmp_buf Yap_CompilerBotch;
/************ variables concerned with Error Handling *************/
sigjmp_buf Yap_RestartEnv; /* used to restart after an abort execution */
/********* IO support *****/
/********* parsing ********************************************/
TokEntry *Yap_tokptr, *Yap_toktide;
VarEntry *Yap_VarTable, *Yap_AnonVarTable;
int Yap_eot_before_eof = FALSE;
/******************* intermediate buffers **********************/
char Yap_FileNameBuf[YAP_FILENAME_MAX],
Yap_FileNameBuf2[YAP_FILENAME_MAX];
#endif /* THREADS */
/******** whether Yap is responsible for signal handling******************/
int Yap_PrologShouldHandleInterrupts;
/********* readline support *****/
#if HAVE_LIBREADLINE
char *_line = (char *) NULL;
#endif
#ifdef MPWSHELL
/********** informing if we are in the MPW shell ********************/
int mpwshell = FALSE;
#endif
#ifdef EMACS
int emacs_mode = FALSE;
char emacs_tmp[256], emacs_tmp2[256];
#endif
/********* Prolog State ********************************************/
Int Yap_PrologMode = BootMode;
int Yap_CritLocks = 0;
/********* streams ********************************************/
YP_FILE *Yap_stdin;
YP_FILE *Yap_stdout;
YP_FILE *Yap_stderr;
/************** Access to yap initial arguments ***************************/
char **Yap_argv;
int Yap_argc;
/************** Extensions to Terms ***************************************/
#ifdef COROUTINING
/* array with the ops for your favourite extensions */
ext_op attas[attvars_ext+1];
#endif
/************** declarations local to init.c ************************/
static char *optypes[] =
{"", "xfx", "xfy", "yfx", "xf", "yf", "fx", "fy"};
@ -197,10 +96,6 @@ int Yap_page_size;
void **Yap_ABSMI_OPCODES;
#endif
#if USE_SOCKET
int Yap_sockets_io=0;
#endif
#if DEBUG
#if COROUTINING
int Yap_Portray_delays = FALSE;
@ -306,7 +201,7 @@ static void
SetOp(int p, int type, char *at, Term m)
{
#ifdef DEBUG
if (Yap_Option[5])
if (GLOBAL_Option[5])
fprintf(stderr,"[setop %d %s %s]\n", p, optypes[type], at);
#endif
OpDec(p, optypes[type], Yap_LookupAtom(at), m);
@ -448,8 +343,8 @@ InitDebug(void)
int i;
for (i = 1; i < 20; ++i)
Yap_Option[i] = 0;
if (Yap_output_msg) {
GLOBAL_Option[i] = 0;
if (GLOBAL_output_msg) {
char ch;
#if HAVE_ISATTY
@ -464,10 +359,10 @@ InitDebug(void)
fprintf(stderr,"m Machine\t p parser\n");
while ((ch = YP_putchar(YP_getchar())) != '\n')
if (ch >= 'a' && ch <= 'z')
Yap_Option[ch - 'a' + 1] = 1;
if (Yap_Option['l' - 96]) {
Yap_logfile = fopen(LOGFILE, "w");
if (Yap_logfile == NULL) {
GLOBAL_Option[ch - 'a' + 1] = 1;
if (GLOBAL_Option['l' - 96]) {
GLOBAL_logfile = fopen(LOGFILE, "w");
if (GLOBAL_logfile == NULL) {
fprintf(stderr,"can not open %s\n", LOGFILE);
getchar();
exit(0);
@ -1166,20 +1061,68 @@ InitInvisibleAtoms(void)
INIT_RWLOCK(Yap_heap_regs->invisiblechain.AERWLock);
}
#ifdef YAPOR
void Yap_init_yapor_workers(void) {
CACHE_REGS
int proc;
#ifdef YAPOR_THREADS
return;
#endif /* YAPOR_THREADS */
#ifdef YAPOR_COW
GLOBAL_master_worker = getpid();
if (GLOBAL_number_workers > 1) {
int son;
son = fork();
if (son == -1)
Yap_Error(FATAL_ERROR, TermNil, "fork error (Yap_init_yapor_workers)");
if (son > 0) {
/* I am the father, I must stay here and wait for my children to all die */
struct sigaction sigact;
sigact.sa_handler = SIG_DFL;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = SA_RESTART;
sigaction(SIGINT, &sigact, NULL);
pause();
exit(0);
} else
GLOBAL_worker_pid(0) = getpid();
}
#endif /* YAPOR_COW */
for (proc = 1; proc < GLOBAL_number_workers; proc++) {
int son;
son = fork();
if (son == -1)
Yap_Error(FATAL_ERROR, TermNil, "fork error (Yap_init_yapor_workers)");
if (son == 0) {
/* new worker */
worker_id = proc;
Yap_remap_yapor_memory();
LOCAL = REMOTE(worker_id);
memcpy(REMOTE(worker_id), REMOTE(0), sizeof(struct worker_local));
InitWorker(worker_id);
break;
} else
GLOBAL_worker_pid(proc) = son;
}
}
#endif /* YAPOR */
#ifdef THREADS
static void
InitThreadHandle(int wid)
{
FOREIGN_ThreadHandle(wid).in_use = FALSE;
FOREIGN_ThreadHandle(wid).zombie = FALSE;
FOREIGN_ThreadHandle(wid).local_preds = NULL;
REMOTE_ThreadHandle(wid).in_use = FALSE;
REMOTE_ThreadHandle(wid).zombie = FALSE;
REMOTE_ThreadHandle(wid).local_preds = NULL;
#ifdef LOW_LEVEL_TRACER
FOREIGN_ThreadHandle(wid).thread_inst_count = 0LL;
REMOTE_ThreadHandle(wid).thread_inst_count = 0LL;
#endif
pthread_mutex_init(&(FOREIGN_ThreadHandle(wid).tlock), NULL);
pthread_mutex_init(&(FOREIGN_ThreadHandle(wid).tlock_status), NULL);
FOREIGN_ThreadHandle(wid).tdetach = (CELL)0;
FOREIGN_ThreadHandle(wid).cmod = (CELL)0;
pthread_mutex_init(&(REMOTE_ThreadHandle(wid).tlock), NULL);
pthread_mutex_init(&(REMOTE_ThreadHandle(wid).tlock_status), NULL);
REMOTE_ThreadHandle(wid).tdetach = (CELL)0;
REMOTE_ThreadHandle(wid).cmod = (CELL)0;
}
int
@ -1189,7 +1132,7 @@ Yap_InitThread(int new_id)
if (new_id) {
if (!(new_s = (struct worker_local *)calloc(sizeof(struct worker_local), 1)))
return FALSE;
Yap_WLocal[new_id] = new_s;
Yap_local[new_id] = new_s;
}
InitWorker(new_id);
return TRUE;
@ -1201,32 +1144,32 @@ InitFirstWorkerThreadHandle(void)
{
#ifdef THREADS
CACHE_REGS
ThreadHandle.id = 0;
ThreadHandle.in_use = TRUE;
ThreadHandle.default_yaam_regs =
LOCAL_ThreadHandle.id = 0;
LOCAL_ThreadHandle.in_use = TRUE;
LOCAL_ThreadHandle.default_yaam_regs =
&Yap_standard_regs;
ThreadHandle.pthread_handle = pthread_self();
pthread_mutex_init(&FOREIGN_ThreadHandle(0).tlock, NULL);
pthread_mutex_init(&FOREIGN_ThreadHandle(0).tlock_status, NULL);
ThreadHandle.tdetach = MkAtomTerm(AtomFalse);
LOCAL_ThreadHandle.pthread_handle = pthread_self();
pthread_mutex_init(&REMOTE_ThreadHandle(0).tlock, NULL);
pthread_mutex_init(&REMOTE_ThreadHandle(0).tlock_status, NULL);
LOCAL_ThreadHandle.tdetach = MkAtomTerm(AtomFalse);
#endif
}
static void
InitScratchPad(int wid)
{
FOREIGN(wid)->scratchpad.ptr = NULL;
FOREIGN(wid)->scratchpad.sz = SCRATCH_START_SIZE;
FOREIGN(wid)->scratchpad.msz = SCRATCH_START_SIZE;
REMOTE_ScratchPad(wid).ptr = NULL;
REMOTE_ScratchPad(wid).sz = SCRATCH_START_SIZE;
REMOTE_ScratchPad(wid).msz = SCRATCH_START_SIZE;
}
void
Yap_CloseScratchPad(void)
{
CACHE_REGS
Yap_FreeCodeSpace(ScratchPad.ptr);
ScratchPad.sz = SCRATCH_START_SIZE;
ScratchPad.msz = SCRATCH_START_SIZE;
Yap_FreeCodeSpace(LOCAL_ScratchPad.ptr);
LOCAL_ScratchPad.sz = SCRATCH_START_SIZE;
LOCAL_ScratchPad.msz = SCRATCH_START_SIZE;
}
#include "iglobals.h"
@ -1241,11 +1184,11 @@ struct global_data Yap_Global;
#endif
#if defined(THREADS)
struct worker_local *Yap_WLocal[MAX_THREADS];
struct worker_local *Yap_local[MAX_THREADS];
#elif defined(YAPOR)
struct worker_local *Yap_WLocal;
struct worker_local *Yap_local;
#else /* !THREADS && !YAPOR */
struct worker_local Yap_WLocal;
struct worker_local Yap_local;
#endif
static void
@ -1255,7 +1198,7 @@ InitCodes(void)
#if THREADS
int wid;
for (wid = 1; wid < MAX_THREADS; wid++) {
Yap_WLocal[wid] = NULL;
Yap_local[wid] = NULL;
}
#endif
#include "ihstruct.h"
@ -1304,11 +1247,11 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
/* initialise system stuff */
#if PUSH_REGS
#ifdef THREADS
if (!(Yap_WLocal[0] = (struct worker_local *)calloc(sizeof(struct worker_local), 1)))
if (!(Yap_local[0] = (struct worker_local *)calloc(sizeof(struct worker_local), 1)))
return;
pthread_key_create(&Yap_yaamregs_key, NULL);
pthread_setspecific(Yap_yaamregs_key, (const void *)&Yap_standard_regs);
Yap_master_thread = pthread_self();
GLOBAL_master_thread = pthread_self();
#else
/* In this case we need to initialise the abstract registers */
Yap_regp = &Yap_standard_regs;
@ -1319,11 +1262,8 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
#ifdef THREADS
Yap_regp = ((REGSTORE *)pthread_getspecific(Yap_yaamregs_key));
Yap_regp->worker_id_ = 0;
#endif
/* Init signal handling and time */
/* also init memory page size, required by later functions */
Yap_InitSysbits ();
LOCAL = REMOTE(0);
#endif /* THREADS */
if (Heap < MinHeapSpace)
Heap = MinHeapSpace;
Heap = AdjustPageSize(Heap * K);
@ -1338,8 +1278,10 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
Atts = 2048*sizeof(CELL);
else
Atts = AdjustPageSize(Atts * K);
#ifdef YAPOR
#if defined(YAPOR) || defined(THREADS)
worker_id = 0;
#endif /* YAPOR || THREADS */
#ifdef YAPOR
if (n_workers > MAX_WORKERS)
Yap_Error(INTERNAL_ERROR, TermNil, "excessive number of workers");
#ifdef YAPOR_COPY
@ -1353,16 +1295,16 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
#endif /* YAPOR_COPY - YAPOR_COW - YAPOR_SBA - YAPOR_THREADS */
#endif /* YAPOR */
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
Yap_init_optyap_memory(Trail, Heap, Stack+Atts, n_workers);
Yap_init_yapor_stacks_memory(Trail, Heap, Stack+Atts, n_workers);
#else
Yap_InitMemory (Trail, Heap, Stack+Atts);
Yap_InitMemory(Trail, Heap, Stack+Atts);
#endif
#if defined(YAPOR) || defined(TABLING)
Yap_init_optyap_data(max_table_size, n_workers, sch_loop, delay_load);
Yap_init_global_optyap_data(max_table_size, n_workers, sch_loop, delay_load);
#endif /* YAPOR || TABLING */
Yap_AttsSize = Atts;
Yap_InitTime ();
Yap_AttsSize = Atts;
Yap_InitTime();
/* InitAbsmi must be done before InitCodes */
/* This must be done before initialising predicates */
for (i = 0; i <= LAST_FLAG; i++) {
@ -1394,17 +1336,17 @@ Yap_HaltRegisterHook (HaltHookFunc f, void * env)
return FALSE;
h->environment = env;
h->hook = f;
LOCK(Yap_BGL);
h->next = Yap_HaltHooks;
Yap_HaltHooks = h;
UNLOCK(Yap_BGL);
LOCK(GLOBAL_BGL);
h->next = GLOBAL_HaltHooks;
GLOBAL_HaltHooks = h;
UNLOCK(GLOBAL_BGL);
return TRUE;
}
static void
run_halt_hooks(int code)
{
struct halt_hook *hooke = Yap_HaltHooks;
struct halt_hook *hooke = GLOBAL_HaltHooks;
while (hooke) {
hooke->hook(code, hooke->environment);
@ -1415,11 +1357,12 @@ run_halt_hooks(int code)
void
Yap_exit (int value)
{
CACHE_REGS
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
Yap_unmap_optyap_memory();
#endif
Yap_unmap_yapor_memory();
#endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA */
if (! (Yap_PrologMode & BootMode) ) {
if (! (LOCAL_PrologMode & BootMode) ) {
#ifdef LOW_PROF
remove("PROFPREDS");
remove("PROFILING");

View File

@ -405,9 +405,9 @@ p_dif( USES_REGS1 )
* We may wake up goals during our attempt to unify the
* two terms. If we are adding to the tail of a list of
* woken goals that should be ok, but otherwise we need
* to restore WokenGoals to its previous value.
* to restore LOCAL_WokenGoals to its previous value.
*/
CELL OldWokenGoals = Yap_ReadTimedVar(WokenGoals);
CELL OldWokenGoals = Yap_ReadTimedVar(LOCAL_WokenGoals);
#endif
register tr_fr_ptr pt0;
/* store the old value of TR for clearing bindings */
@ -425,7 +425,7 @@ p_dif( USES_REGS1 )
d0 = Yap_IUnify(d0, d1);
#ifdef COROUTINING
/* now restore Woken Goals to its old value */
Yap_UpdateTimedVar(WokenGoals, OldWokenGoals);
Yap_UpdateTimedVar(LOCAL_WokenGoals, OldWokenGoals);
if (OldWokenGoals == TermNil) {
Yap_undo_signal(YAP_WAKEUP_SIGNAL);
}
@ -719,7 +719,7 @@ p_functor( USES_REGS1 ) /* functor(?,?,?) */
d0 = AbsAppl(H);
if (pt1+d1 > ENV - CreepFlag) {
if (!Yap_gcl((1+d1)*sizeof(CELL), 3, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
goto restart;

View File

@ -183,17 +183,17 @@ Yap_DebugGetc()
}
if ((ch = *lp++) == 0)
ch = '\n', eolflg = 1;
if (Yap_Option['l' - 96])
putc(ch, Yap_logfile);
if (GLOBAL_Option['l' - 96])
putc(ch, GLOBAL_logfile);
return (ch);
}
int
Yap_DebugPutc(int sno, wchar_t ch)
{
if (Yap_Option['l' - 96])
(void) putc(ch, Yap_logfile);
return (putc(ch, Yap_stderr));
if (GLOBAL_Option['l' - 96])
(void) putc(ch, GLOBAL_logfile);
return (putc(ch, GLOBAL_stderr));
}
void
@ -206,7 +206,7 @@ void
Yap_DebugErrorPutc(int c)
{
CACHE_REGS
Yap_DebugPutc (Yap_c_error_stream, c);
Yap_DebugPutc (LOCAL_c_error_stream, c);
}
#endif
@ -238,7 +238,7 @@ typedef struct stream_ref
int beam_write (void)
{
Yap_StartSlots();
Yap_plwrite (ARG1, Stream[Yap_c_output_stream].stream_wputc, 0, 1200);
Yap_plwrite (ARG1, Stream[LOCAL_c_output_stream].stream_wputc, 0, 1200);
Yap_CloseSlots();
if (EX != 0L) {
Term ball = Yap_PopTermFromDB(EX);
@ -273,8 +273,8 @@ syntax_error (TokEntry * tokptr, IOSTREAM *st, Term *outp)
/* make sure to globalise variable */
Yap_unify(*outp, MkVarTerm());
start = tokptr->TokPos;
clean_vars(Yap_VarTable);
clean_vars(Yap_AnonVarTable);
clean_vars(LOCAL_VarTable);
clean_vars(LOCAL_AnonVarTable);
while (1) {
Term ts[2];
@ -286,7 +286,7 @@ syntax_error (TokEntry * tokptr, IOSTREAM *st, Term *outp)
H = Hi;
break;
}
if (tokptr == Yap_toktide) {
if (tokptr == LOCAL_toktide) {
err = tokptr->TokPos;
out = count;
}
@ -402,31 +402,31 @@ Yap_StringToTerm(char *s,Term *tp)
if (sno == NULL)
return FALSE;
TR_before_parse = TR;
tokstart = Yap_tokptr = Yap_toktide = Yap_tokenizer(sno, &tpos);
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(sno, &tpos);
if (tokstart == NIL || tokstart->Tok == Ord (eot_tok)) {
if (tp) {
*tp = MkAtomTerm(AtomEOFBeforeEOT);
}
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Sclose(sno);
return FALSE;
} else if (Yap_ErrorMessage) {
} else if (LOCAL_ErrorMessage) {
if (tp) {
*tp = MkAtomTerm(Yap_LookupAtom(Yap_ErrorMessage));
*tp = MkAtomTerm(Yap_LookupAtom(LOCAL_ErrorMessage));
}
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Sclose(sno);
return FALSE;
}
t = Yap_Parse();
TR = TR_before_parse;
if (!t || Yap_ErrorMessage) {
if (!t || LOCAL_ErrorMessage) {
GenerateSyntaxError(tp, tokstart, sno PASS_REGS);
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Sclose(sno);
return FALSE;
}
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Sclose(sno);
return t;
}
@ -436,13 +436,13 @@ Int
Yap_FirstLineInParse (void)
{
CACHE_REGS
return StartLine;
return LOCAL_StartLine;
}
static Int
p_startline ( USES_REGS1 )
{
return (Yap_unify_constant (ARG1, MkIntegerTerm (StartLine)));
return (Yap_unify_constant (ARG1, MkIntegerTerm (LOCAL_StartLine)));
}
/* control the parser error handler */
@ -512,25 +512,25 @@ Yap_readTerm(void *st0, Term *tp, Term *varnames, Term *terror, Term *tpos)
if (st == NULL) {
return FALSE;
}
tokstart = Yap_tokptr = Yap_toktide = Yap_tokenizer(st, tpos);
if (Yap_ErrorMessage)
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(st, tpos);
if (LOCAL_ErrorMessage)
{
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
if (terror)
*terror = MkAtomTerm(Yap_LookupAtom(Yap_ErrorMessage));
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
*terror = MkAtomTerm(Yap_LookupAtom(LOCAL_ErrorMessage));
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
return FALSE;
}
pt = Yap_Parse();
if (Yap_ErrorMessage || pt == (CELL)0) {
if (LOCAL_ErrorMessage || pt == (CELL)0) {
GenerateSyntaxError(terror, tokstart, st PASS_REGS);
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
return FALSE;
}
if (varnames) {
*varnames = Yap_VarNames(Yap_VarTable, TermNil);
*varnames = Yap_VarNames(LOCAL_VarTable, TermNil);
if (!*varnames) {
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
return FALSE;
}
}
@ -554,9 +554,6 @@ static Int
{
Term t, v;
TokEntry *tokstart;
#if EMACS
int emacs_cares = FALSE;
#endif
Term tmod = Deref(ARG3), OCurrentModule = CurrentModule, tpos;
extern void Yap_setCurrentSourceLocation(IOSTREAM **s);
@ -567,7 +564,7 @@ static Int
Yap_Error(TYPE_ERROR_ATOM, tmod, "read_term/2");
return FALSE;
}
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
tpos = Yap_StreamPosition(inp_stream);
if (!Yap_unify(tpos,ARG5)) {
/* do this early so that we do not have to protect it in case of stack expansion */
@ -585,33 +582,32 @@ static Int
/* Scans the term using stack space */
while (TRUE) {
old_H = H;
Yap_eot_before_eof = FALSE;
tpos = Yap_StreamPosition(inp_stream);
tokstart = Yap_tokptr = Yap_toktide = Yap_tokenizer(inp_stream, &tpos);
if (Yap_Error_TYPE != YAP_NO_ERROR && seekable) {
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(inp_stream, &tpos);
if (LOCAL_Error_TYPE != YAP_NO_ERROR && seekable) {
H = old_H;
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
if (seekable) {
Sseek64(inp_stream, cpos, SIO_SEEK_SET);
}
if (Yap_Error_TYPE == OUT_OF_TRAIL_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_TRAIL_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growtrail (sizeof(CELL) * K16, FALSE)) {
return FALSE;
}
} else if (Yap_Error_TYPE == OUT_OF_AUXSPACE_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
} else if (LOCAL_Error_TYPE == OUT_OF_AUXSPACE_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) {
return FALSE;
}
} else if (Yap_Error_TYPE == OUT_OF_HEAP_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
} else if (LOCAL_Error_TYPE == OUT_OF_HEAP_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growheap(FALSE, 0, NULL)) {
return FALSE;
}
} else if (Yap_Error_TYPE == OUT_OF_STACK_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(Yap_Error_Size, nargs, ENV, CP)) {
} else if (LOCAL_Error_TYPE == OUT_OF_STACK_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, nargs, ENV, CP)) {
return FALSE;
}
}
@ -620,18 +616,18 @@ static Int
break;
}
}
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
/* preserve value of H after scanning: otherwise we may lose strings
and floats */
old_H = H;
if (tokstart != NULL && tokstart->Tok == Ord (eot_tok)) {
/* did we get the end of file from an abort? */
if (Yap_ErrorMessage &&
!strcmp(Yap_ErrorMessage,"Abort")) {
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
if (LOCAL_ErrorMessage &&
!strcmp(LOCAL_ErrorMessage,"Abort")) {
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
return FALSE;
} else {
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
return Yap_unify_constant(ARG2, MkAtomTerm (AtomEof))
&& Yap_unify_constant(ARG4, TermNil);
@ -639,61 +635,61 @@ static Int
}
repeat_cycle:
CurrentModule = tmod;
if (Yap_ErrorMessage || (t = Yap_Parse()) == 0) {
if (LOCAL_ErrorMessage || (t = Yap_Parse()) == 0) {
CurrentModule = OCurrentModule;
if (Yap_ErrorMessage) {
if (LOCAL_ErrorMessage) {
int res;
if (!strcmp(Yap_ErrorMessage,"Stack Overflow") ||
!strcmp(Yap_ErrorMessage,"Trail Overflow") ||
!strcmp(Yap_ErrorMessage,"Heap Overflow")) {
if (!strcmp(LOCAL_ErrorMessage,"Stack Overflow") ||
!strcmp(LOCAL_ErrorMessage,"Trail Overflow") ||
!strcmp(LOCAL_ErrorMessage,"Heap Overflow")) {
/* ignore term we just built */
tr_fr_ptr old_TR = TR;
H = old_H;
TR = (tr_fr_ptr)ScannerStack;
TR = (tr_fr_ptr)LOCAL_ScannerStack;
if (!strcmp(Yap_ErrorMessage,"Stack Overflow"))
res = Yap_growstack_in_parser(&old_TR, &tokstart, &Yap_VarTable);
else if (!strcmp(Yap_ErrorMessage,"Heap Overflow"))
res = Yap_growheap_in_parser(&old_TR, &tokstart, &Yap_VarTable);
if (!strcmp(LOCAL_ErrorMessage,"Stack Overflow"))
res = Yap_growstack_in_parser(&old_TR, &tokstart, &LOCAL_VarTable);
else if (!strcmp(LOCAL_ErrorMessage,"Heap Overflow"))
res = Yap_growheap_in_parser(&old_TR, &tokstart, &LOCAL_VarTable);
else
res = Yap_growtrail_in_parser(&old_TR, &tokstart, &Yap_VarTable);
res = Yap_growtrail_in_parser(&old_TR, &tokstart, &LOCAL_VarTable);
if (res) {
ScannerStack = (char *)TR;
LOCAL_ScannerStack = (char *)TR;
TR = old_TR;
old_H = H;
Yap_tokptr = Yap_toktide = tokstart;
Yap_ErrorMessage = NULL;
LOCAL_tokptr = LOCAL_toktide = tokstart;
LOCAL_ErrorMessage = NULL;
goto repeat_cycle;
}
ScannerStack = (char *)TR;
LOCAL_ScannerStack = (char *)TR;
TR = old_TR;
}
}
if (ParserErrorStyle == QUIET_ON_PARSER_ERROR) {
/* just fail */
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
return FALSE;
} else if (ParserErrorStyle == CONTINUE_ON_PARSER_ERROR) {
Yap_ErrorMessage = NULL;
LOCAL_ErrorMessage = NULL;
/* try again */
goto repeat_cycle;
} else {
Term terr = syntax_error(tokstart, inp_stream, &ARG2);
if (Yap_ErrorMessage == NULL)
Yap_ErrorMessage = "SYNTAX ERROR";
if (LOCAL_ErrorMessage == NULL)
LOCAL_ErrorMessage = "SYNTAX ERROR";
if (ParserErrorStyle == EXCEPTION_ON_PARSER_ERROR) {
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
Yap_Error(SYNTAX_ERROR,terr,Yap_ErrorMessage);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_Error(SYNTAX_ERROR,terr,LOCAL_ErrorMessage);
return FALSE;
} else /* FAIL ON PARSER ERROR */ {
Term t[2];
t[0] = terr;
t[1] = MkAtomTerm(Yap_LookupAtom(Yap_ErrorMessage));
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
t[1] = MkAtomTerm(Yap_LookupAtom(LOCAL_ErrorMessage));
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
return Yap_unify(ARG6,Yap_MkApplTerm(Yap_MkFunctor(AtomError,2),2,t));
}
}
@ -703,17 +699,14 @@ static Int
break;
}
}
#if EMACS
first_char = tokstart->TokPos;
#endif /* EMACS */
if (!Yap_unify(t, ARG2))
return FALSE;
if (AtomOfTerm (Deref (ARG1)) == AtomTrue) {
while (TRUE) {
CELL *old_H = H;
if (setjmp(Yap_IOBotch) == 0) {
v = Yap_VarNames(Yap_VarTable, TermNil);
if (setjmp(LOCAL_IOBotch) == 0) {
v = Yap_VarNames(LOCAL_VarTable, TermNil);
break;
} else {
tr_fr_ptr old_TR;
@ -722,16 +715,16 @@ static Int
old_TR = TR;
/* restart global */
H = old_H;
TR = (tr_fr_ptr)ScannerStack;
Yap_growstack_in_parser(&old_TR, &tokstart, &Yap_VarTable);
ScannerStack = (char *)TR;
TR = (tr_fr_ptr)LOCAL_ScannerStack;
Yap_growstack_in_parser(&old_TR, &tokstart, &LOCAL_VarTable);
LOCAL_ScannerStack = (char *)TR;
TR = old_TR;
}
}
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
return Yap_unify (v, ARG4);
} else {
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
return TRUE;
}
}
@ -976,7 +969,7 @@ p_char_conversion( USES_REGS1 )
CharConversionTable2 = Yap_AllocCodeSpace(NUMBER_OF_CHARS*sizeof(char));
while (CharConversionTable2 == NULL) {
if (!Yap_growheap(FALSE, NUMBER_OF_CHARS*sizeof(char), NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return(FALSE);
}
}
@ -1110,9 +1103,6 @@ Yap_InitBackIO (void)
void
Yap_InitIOPreds(void)
{
Yap_stdin = stdin;
Yap_stdout = stdout;
Yap_stderr = stderr;
if (!Stream)
Stream = (StreamDesc *)Yap_AllocCodeSpace(sizeof(StreamDesc)*MaxStreams);
/* here the Input/Output predicates */

View File

@ -65,16 +65,16 @@ LoadForeign(StringList ofiles, StringList libs,
/* load wants to follow the LIBRARY_PATH */
if (ofiles->next != NULL || libs != NULL) {
strcpy(Yap_ErrorSay," Load Failed: in AIX you must load a single object file");
strcpy(LOCAL_ErrorSay," Load Failed: in AIX you must load a single object file");
return LOAD_FAILLED;
}
if (!Yap_TrueFileName(AtomName(ofiles->name), Yap_FileNameBuf, TRUE)) {
strcpy(Yap_ErrorSay, " Trying to open unexisting file in LoadForeign ");
if (!Yap_TrueFileName(AtomName(ofiles->name), LOCAL_FileNameBuf, TRUE)) {
strcpy(LOCAL_ErrorSay, " Trying to open unexisting file in LoadForeign ");
return LOAD_FAILLED;
}
/* In AIX, just call load and everything will go in */
if ((*init_proc=((YapInitProc *)load(Yap_FileNameBuf,0,NULL))) == NULL) {
strcpy(Yap_ErrorSay,sys_errlist[errno]);
if ((*init_proc=((YapInitProc *)load(LOCAL_FileNameBuf,0,NULL))) == NULL) {
strcpy(LOCAL_ErrorSay,sys_errlist[errno]);
return LOAD_FAILLED;
}
return LOAD_SUCCEEDED;

View File

@ -18,7 +18,7 @@
#include "Foreign.h"
#ifdef A_OUT
this code is no being maintained anymore
#include <stdio.h>
#if STDC_HEADERS
#include <stdlib.h>
@ -43,7 +43,7 @@
#endif
#include <a.out.h>
static char YapExecutable[YAP_FILE_MAX];
#define oktox(n) \
(0==stat(n,&stbuf)&&(stbuf.st_mode&S_IFMT)==S_IFREG&&0==access(n,X_OK))
@ -64,10 +64,10 @@ Yap_FindExecutable(char *name)
cp = (char *)getenv("PATH");
if (cp == NULL)
cp = ".:/usr/ucb:/bin:/usr/bin:/usr/local/bin";
if (*Yap_argv[0] == '/') {
if (oktox(Yap_argv[0])) {
strcpy(Yap_FileNameBuf, Yap_argv[0]);
Yap_TrueFileName(Yap_FileNameBuf, YapExecutable, TRUE);
if (*GLOBAL_argv[0] == '/') {
if (oktox(GLOBAL_argv[0])) {
strcpy(LOCAL_FileNameBuf, GLOBAL_argv[0]);
Yap_TrueFileName(LOCAL_FileNameBuf, GLOBAL_Executable, TRUE);
return;
}
}
@ -79,24 +79,24 @@ Yap_FindExecutable(char *name)
* argv[0]
*/
for (cp2 = Yap_FileNameBuf; (*cp) != 0 && (*cp) != ':';)
for (cp2 = LOCAL_FileNameBuf; (*cp) != 0 && (*cp) != ':';)
*cp2++ = *cp++;
*cp2++ = '/';
strcpy(cp2, Yap_argv[0]);
strcpy(cp2, GLOBAL_argv[0]);
if (*cp)
cp++;
if (!oktox(Yap_FileNameBuf))
if (!oktox(LOCAL_FileNameBuf))
continue;
Yap_TrueFileName(Yap_FileNameBuf, YapExecutable, TRUE);
Yap_TrueFileName(LOCAL_FileNameBuf, GLOBAL_Executable, TRUE);
return;
}
/* one last try for dual systems */
strcpy(Yap_FileNameBuf, Yap_argv[0]);
Yap_TrueFileName(Yap_FileNameBuf, YapExecutable, TRUE);
if (oktox(YapExecutable))
strcpy(LOCAL_FileNameBuf, GLOBAL_argv[0]);
Yap_TrueFileName(LOCAL_FileNameBuf, GLOBAL_Executable, TRUE);
if (oktox(GLOBAL_Executable))
return;
else
Yap_Error(SYSTEM_ERROR,MkAtomTerm(Yap_LookupAtom(YapExecutable)),
Yap_Error(SYSTEM_ERROR,MkAtomTerm(Yap_LookupAtom(GLOBAL_Executable)),
"cannot find file being executed");
}
@ -174,22 +174,22 @@ LoadForeign(StringList ofiles,
/* prepare the magic */
if (strlen(o_files) + strlen(l_files) + strlen(proc_name) +
strlen(YapExecutable) > 2*MAXPATHLEN) {
strcpy(Yap_ErrorSay, " too many parameters in load_foreign/3 ");
strlen(GLOBAL_Executable) > 2*MAXPATHLEN) {
strcpy(LOCAL_ErrorSay, " too many parameters in load_foreign/3 ");
return LOAD_FAILLED;
}
sprintf(command, "/usr/bin/ld -N -A %s -o %s -u _%s %s %s -lc",
YapExecutable,
GLOBAL_Executable,
tfile, proc_name, o_files, l_files);
/* now, do the magic */
if (system(command) != 0) {
unlink(tfile);
strcpy(Yap_ErrorSay," ld returned error status in load_foreign_files ");
strcpy(LOCAL_ErrorSay," ld returned error status in load_foreign_files ");
return LOAD_FAILLED;
}
/* now check the music has played */
if ((fildes = open(tfile, O_RDONLY)) < 0) {
strcpy(Yap_ErrorSay," unable to open temp file in load_foreign_files ");
strcpy(LOCAL_ErrorSay," unable to open temp file in load_foreign_files ");
return LOAD_FAILLED;
}
/* it did, get the mice */
@ -204,28 +204,28 @@ LoadForeign(StringList ofiles,
firstloadImSz = loadImageSize;
/* now fetch the space we need */
if (!(FCodeBase = Yap_AllocCodeSpace((int) loadImageSize))) {
strcpy(Yap_ErrorSay," unable to allocate space for external code ");
strcpy(LOCAL_ErrorSay," unable to allocate space for external code ");
return LOAD_FAILLED;
}
/* now, a new incantation to load the new foreign code */
sprintf(command, "/usr/bin/ld -N -A %s -T %lx -o %s -u _%s %s %s -lc",
YapExecutable,
GLOBAL_Executable,
(unsigned long) FCodeBase,
tfile, proc_name, o_files, l_files);
/* and do it */
if (system(command) != 0) {
unlink(tfile);
strcpy(Yap_ErrorSay," ld returned error status in load_foreign_files ");
strcpy(LOCAL_ErrorSay," ld returned error status in load_foreign_files ");
return LOAD_FAILLED;
}
if ((fildes = open(tfile, O_RDONLY)) < 0) {
strcpy(Yap_ErrorSay," unable to open temp file in load_foreign_files ");
strcpy(LOCAL_ErrorSay," unable to open temp file in load_foreign_files ");
return LOAD_FAILLED;
}
read(fildes, (char *) &header, sizeof(header));
loadImageSize = header.a_text + header.a_data + header.a_bss;
if (firstloadImSz < loadImageSize) {
strcpy(Yap_ErrorSay," miscalculation in load_foreign/3 ");
strcpy(LOCAL_ErrorSay," miscalculation in load_foreign/3 ");
return LOAD_FAILLED;
}
/* now search for our init function */
@ -236,11 +236,11 @@ LoadForeign(StringList ofiles,
func_info[0].n_un.n_name = entry_fun;
func_info[1].n_un.n_name = NULL;
if (nlist(tfile, func_info) == -1) {
strcpy(Yap_ErrorSay," in nlist(3) ");
strcpy(LOCAL_ErrorSay," in nlist(3) ");
return LOAD_FAILLED;
}
if (func_info[0].n_type == 0) {
strcpy(Yap_ErrorSay," in nlist(3) ");
strcpy(LOCAL_ErrorSay," in nlist(3) ");
return LOAD_FAILLED;
}
*init_proc = (YapInitProc)(func_info[0].n_value);

View File

@ -19,7 +19,7 @@
#include "Foreign.h"
#ifdef COFF
this code is no being maintained anymore
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
@ -45,8 +45,6 @@
#define N_TXTOFF(x) (sizeof(struct filehdr)+(x).f_opthdr+(x).f_nscns*sizeof(struct scnhdr))
static char YapExecutable[YAP_FILE_MAX];
/*
* YAP_FindExecutable(argv[0]) should be called on yap initialization to
@ -62,10 +60,10 @@ Yap_FindExecutable(char *name)
cp = (char *)getenv("PATH");
if (cp == NULL)
cp = ".:/usr/ucb:/bin:/usr/bin:/usr/local/bin";
if (*Yap_argv[0] == '/') {
if (oktox(Yap_argv[0])) {
strcpy(Yap_FileNameBuf, Yap_argv[0]);
Yap_TrueFileName(Yap_FileNameBuf, YapExecutable, TRUE);
if (*GLOBAL_argv[0] == '/') {
if (oktox(GLOBAL_argv[0])) {
strcpy(LOCAL_FileNameBuf, GLOBAL_argv[0]);
Yap_TrueFileName(LOCAL_FileNameBuf, GLOBAL_Executable, TRUE);
return;
}
}
@ -77,24 +75,24 @@ Yap_FindExecutable(char *name)
* argv[0]
*/
for (cp2 = Yap_FileNameBuf; (*cp) != 0 && (*cp) != ':';)
for (cp2 = LOCAL_FileNameBuf; (*cp) != 0 && (*cp) != ':';)
*cp2++ = *cp++;
*cp2++ = '/';
strcpy(cp2, Yap_argv[0]);
strcpy(cp2, GLOBAL_argv[0]);
if (*cp)
cp++;
if (!oktox(Yap_FileNameBuf))
if (!oktox(LOCAL_FileNameBuf))
continue;
Yap_TrueFileName(Yap_FileNameBuf, YapExecutable, TRUE);
Yap_TrueFileName(LOCAL_FileNameBuf, GLOBAL_Executable, TRUE);
return;
}
/* one last try for dual systems */
strcpy(Yap_FileNameBuf, Yap_argv[0]);
Yap_TrueFileName(Yap_FileNameBuf, YapExecutable, TRUE);
if (oktox(YapExecutable))
strcpy(LOCAL_FileNameBuf, GLOBAL_argv[0]);
Yap_TrueFileName(LOCAL_FileNameBuf, GLOBAL_Executable, TRUE);
if (oktox(GLOBAL_Executable))
return;
else
Yap_Error(SYSTEM_ERROR,MkAtomTerm(Yap_LookupAtom(YapExecutable)),
Yap_Error(SYSTEM_ERROR,MkAtomTerm(Yap_LookupAtom(GLOBAL_Executable)),
"cannot find file being executed");
}
@ -175,22 +173,22 @@ LoadForeign(StringList ofiles,
/* prepare the magic */
if (strlen(o_files) + strlen(l_files) + strlen(proc_name) +
strlen(YapExecutable) > 2*MAXPATHLEN) {
strcpy(Yap_ErrorSay, " too many parameters in load_foreign/3 ");
strlen(GLOBAL_Executable) > 2*MAXPATHLEN) {
strcpy(LOCAL_ErrorSay, " too many parameters in load_foreign/3 ");
return LOAD_FAILLED;
}
sprintf(command, "/usr/bin/ld -N -A %s -o %s %s %s -lc",
YapExecutable,
GLOBAL_Executable,
tfile, o_files, l_files);
/* now, do the magic */
if (system(command) != 0) {
unlink(tfile);
strcpy(Yap_ErrorSay," ld returned error status in load_foreign_files ");
strcpy(LOCAL_ErrorSay," ld returned error status in load_foreign_files ");
return LOAD_FAILLED;
}
/* now check the music has played */
if ((fildes = open(tfile, O_RDONLY)) < 0) {
strcpy(Yap_ErrorSay," unable to open temp file in load_foreign_files ");
strcpy(LOCAL_ErrorSay," unable to open temp file in load_foreign_files ");
return LOAD_FAILLED;
}
/* it did, get the mice */
@ -220,7 +218,7 @@ LoadForeign(StringList ofiles,
|| activate_code(ForeignCodeBase, u1)
#endif /* pyr */
) {
strcpy(Yap_ErrorSay," unable to allocate space for external code ");
strcpy(LOCAL_ErrorSay," unable to allocate space for external code ");
return LOAD_FAILLED;
}
#ifdef mips
@ -253,11 +251,11 @@ LoadForeign(StringList ofiles,
/* and do it */
if (system(command) != 0) {
unlink(tfile);
strcpy(Yap_ErrorSay," ld returned error status in load_foreign_files ");
strcpy(LOCAL_ErrorSay," ld returned error status in load_foreign_files ");
return LOAD_FAILLED;
}
if ((fildes = open(tfile, O_RDONLY)) < 0) {
strcpy(Yap_ErrorSay," unable to open temp file in load_foreign_files ");
strcpy(LOCAL_ErrorSay," unable to open temp file in load_foreign_files ");
return LOAD_FAILLED;
}
read(fildes, (char *) &fileHeader, sizeof(fileHeader));
@ -269,7 +267,7 @@ LoadForeign(StringList ofiles,
}
loadImageSize = sysHeader.tsize + sysHeader.dsize + sysHeader.bsize;
if (firstloadImSz < loadImageSize) {
strcpy(Yap_ErrorSay," miscalculation in load_foreign/3 ");
strcpy(LOCAL_ErrorSay," miscalculation in load_foreign/3 ");
return LOAD_FAILLED;
}
/* now search for our init function */
@ -285,11 +283,11 @@ LoadForeign(StringList ofiles,
func_info[0].n_name = entry_fun;
func_info[1].n_name = NULL;
if (nlist(tfile, func_info) == -1) {
strcpy(Yap_ErrorSay," in nlist(3) ");
strcpy(LOCAL_ErrorSay," in nlist(3) ");
return LOAD_FAILLED;
}
if (func_info[0].n_type == 0) {
strcpy(Yap_ErrorSay," in nlist(3) ");
strcpy(LOCAL_ErrorSay," in nlist(3) ");
return LOAD_FAILLED;
}
*init_proc = (YapInitProc)(func_info[0].n_value);

View File

@ -94,18 +94,18 @@ LoadForeign(StringList ofiles, StringList libs,
CACHE_REGS
while (libs) {
if (!Yap_TrueFileName(AtomName(libs->name), Yap_FileNameBuf, TRUE)) {
if (!Yap_TrueFileName(AtomName(libs->name), LOCAL_FileNameBuf, TRUE)) {
/* use LD_LIBRARY_PATH */
strncpy(Yap_FileNameBuf, AtomName(libs->name), YAP_FILENAME_MAX);
strncpy(LOCAL_FileNameBuf, AtomName(libs->name), YAP_FILENAME_MAX);
}
#ifdef __osf__
if((libs->handle=dlopen(Yap_FileNameBuf,RTLD_LAZY)) == NULL)
if((libs->handle=dlopen(LOCAL_FileNameBuf,RTLD_LAZY)) == NULL)
#else
if((libs->handle=dlopen(Yap_FileNameBuf,RTLD_LAZY|RTLD_GLOBAL)) == NULL)
if((libs->handle=dlopen(LOCAL_FileNameBuf,RTLD_LAZY|RTLD_GLOBAL)) == NULL)
#endif
{
strcpy(Yap_ErrorSay,dlerror());
strcpy(LOCAL_ErrorSay,dlerror());
return LOAD_FAILLED;
}
libs = libs->next;
@ -118,18 +118,18 @@ LoadForeign(StringList ofiles, StringList libs,
other routines */
/* dlopen wants to follow the LD_CONFIG_PATH */
if (!Yap_TrueFileName(AtomName(ofiles->name), Yap_FileNameBuf, TRUE)) {
strcpy(Yap_ErrorSay, "%% Trying to open unexisting file in LoadForeign");
if (!Yap_TrueFileName(AtomName(ofiles->name), LOCAL_FileNameBuf, TRUE)) {
strcpy(LOCAL_ErrorSay, "%% Trying to open unexisting file in LoadForeign");
return LOAD_FAILLED;
}
#ifdef __osf__
if((handle=dlopen(Yap_FileNameBuf,RTLD_LAZY)) == 0)
if((handle=dlopen(LOCAL_FileNameBuf,RTLD_LAZY)) == 0)
#else
if((handle=dlopen(Yap_FileNameBuf,RTLD_LAZY|RTLD_GLOBAL)) == 0)
if((handle=dlopen(LOCAL_FileNameBuf,RTLD_LAZY|RTLD_GLOBAL)) == 0)
#endif
{
fprintf(stderr,"dlopen of %s failed with error %s\n", Yap_FileNameBuf, dlerror());
/* strcpy(Yap_ErrorSay,dlerror());*/
fprintf(stderr,"dlopen of %s failed with error %s\n", LOCAL_FileNameBuf, dlerror());
/* strcpy(LOCAL_ErrorSay,dlerror());*/
return LOAD_FAILLED;
}
@ -142,7 +142,7 @@ LoadForeign(StringList ofiles, StringList libs,
}
if(! *init_proc) {
strcpy(Yap_ErrorSay,"Could not locate initialization routine");
strcpy(LOCAL_ErrorSay,"Could not locate initialization routine");
return LOAD_FAILLED;
}

View File

@ -20,8 +20,7 @@
#include <malloc.h>
#include <stdio.h>
static char YapExecutable[YAP_FILE_MAX];
this code is no being maintained anymore
/*
* YAP_FindExecutable(argv[0]) should be called on yap initialization to
@ -33,9 +32,9 @@ Yap_FindExecutable(char *name)
/* use dld_find_executable */
char *res;
if(name != NULL && (res=dld_find_executable(name))) {
strcpy(YapExecutable,res);
strcpy(GLOBAL_Executable,res);
} else {
strcpy(YapExecutable,"./yap");
strcpy(GLOBAL_Executable,"./yap");
}
}
@ -71,9 +70,9 @@ LoadForeign(StringList ofiles, StringList libs,
int error;
if(firstTime) {
error = dld_init(YapExecutable);
error = dld_init(GLOBAL_Executable);
if(error) {
strcpy(Yap_ErrorSay,dld_strerror(error));
strcpy(LOCAL_ErrorSay,dld_strerror(error));
return LOAD_FAILLED;
}
firstTime=0;
@ -81,7 +80,7 @@ LoadForeign(StringList ofiles, StringList libs,
while (ofiles) {
if((error=dld_link(AtomName(ofiles->name))) !=0) {
strcpy(Yap_ErrorSay,dld_strerror(error));
strcpy(LOCAL_ErrorSay,dld_strerror(error));
return LOAD_FAILLED;
}
ofiles = ofiles->next;
@ -91,14 +90,14 @@ LoadForeign(StringList ofiles, StringList libs,
/* TODO: handle libs */
*init_proc = (YapInitProc) dld_get_func(proc_name);
if(! *init_proc) {
strcpy(Yap_ErrorSay,"Could not locate initialization routine");
strcpy(LOCAL_ErrorSay,"Could not locate initialization routine");
return LOAD_FAILLED;
}
if(!dld_function_executable_p(proc_name)) {
char **undefs = dld_list_undefined_sym();
char **p = undefs;
int k = dld_undefined_sym_count;
strcpy(Yap_ErrorSay,"Could not resolve all symbols");
strcpy(LOCAL_ErrorSay,"Could not resolve all symbols");
while(k) {
YP_printf("[undefined symbol %s]\n",*p++);
--k;

View File

@ -66,16 +66,16 @@ LoadForeign(StringList ofiles, StringList libs,
while (ofiles) {
HINSTANCE handle;
if (Yap_TrueFileName(AtomName(ofiles->name), Yap_FileNameBuf, TRUE) &&
(handle=LoadLibrary(Yap_FileNameBuf)) != 0)
if (Yap_TrueFileName(AtomName(ofiles->name), LOCAL_FileNameBuf, TRUE) &&
(handle=LoadLibrary(LOCAL_FileNameBuf)) != 0)
{
Yap_ErrorSay[0]=~'\0';
LOCAL_ErrorSay[0]=~'\0';
if (*init_proc == NULL)
*init_proc = (YapInitProc)GetProcAddress((HMODULE)handle, proc_name);
} else {
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), Yap_ErrorSay, 256,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), LOCAL_ErrorSay, 256,
NULL);
}
ofiles = ofiles->next;
@ -87,15 +87,15 @@ LoadForeign(StringList ofiles, StringList libs,
char * s = AtomName(libs->name);
if (s[0] == '-') {
strcat(Yap_FileNameBuf,s+2);
strcat(Yap_FileNameBuf,".dll");
strcat(LOCAL_FileNameBuf,s+2);
strcat(LOCAL_FileNameBuf,".dll");
} else {
strcpy(Yap_FileNameBuf,s);
strcpy(LOCAL_FileNameBuf,s);
}
if((handle=LoadLibrary(Yap_FileNameBuf)) == 0)
if((handle=LoadLibrary(LOCAL_FileNameBuf)) == 0)
{
/* strcpy(Yap_ErrorSay,dlerror());*/
/* strcpy(LOCAL_ErrorSay,dlerror());*/
return LOAD_FAILLED;
}
@ -106,7 +106,7 @@ LoadForeign(StringList ofiles, StringList libs,
}
if(*init_proc == NULL) {
strcpy(Yap_ErrorSay,"Could not locate initialization routine");
strcpy(LOCAL_ErrorSay,"Could not locate initialization routine");
return LOAD_FAILLED;
}

View File

@ -28,13 +28,13 @@
*/
#import <mach-o/dyld.h>
static int dl_errno;
static char *
mydlerror(void)
{
char *errString;
switch(dl_errno) {
switch(LOCAL_dl_errno) {
default:
case NSObjectFileImageFailure:
case NSObjectFileImageFormat:
@ -76,7 +76,7 @@ mydlopen(char *path)
NSModule handle = NULL;
dyld_result = NSCreateObjectFileImageFromFile(path, &ofile);
if (dyld_result != NSObjectFileImageSuccess) {
dl_errno = dyld_result;
LOCAL_dl_errno = dyld_result;
} else {
/* NSLinkModule will cause the run to abort on any link error's */
/* not very friendly but the error recovery functionality is limited */
@ -145,14 +145,14 @@ LoadForeign(StringList ofiles, StringList libs,
void *handle;
/* mydlopen wants to follow the LD_CONFIG_PATH */
if (!Yap_TrueFileName(AtomName(ofiles->name), Yap_FileNameBuf, TRUE)) {
strcpy(Yap_ErrorSay, "%% Trying to open unexisting file in LoadForeign");
if (!Yap_TrueFileName(AtomName(ofiles->name), LOCAL_FileNameBuf, TRUE)) {
strcpy(LOCAL_ErrorSay, "%% Trying to open unexisting file in LoadForeign");
return LOAD_FAILLED;
}
if((handle=mydlopen(Yap_FileNameBuf)) == 0)
if((handle=mydlopen(LOCAL_FileNameBuf)) == 0)
{
fprintf(stderr,"calling dlopen with error %s\n", mydlerror());
/* strcpy(Yap_ErrorSay,dlerror());*/
/* strcpy(LOCAL_ErrorSay,dlerror());*/
return LOAD_FAILLED;
}
@ -166,16 +166,16 @@ LoadForeign(StringList ofiles, StringList libs,
char *s = AtomName(lib->name);
if (ls[0] == '-') {
strcpy(Yap_FileNameBuf,"lib");
strcat(Yap_FileNameBuf,s+2);
strcat(Yap_FileNameBuf,".so");
strcpy(LOCAL_FileNameBuf,"lib");
strcat(LOCAL_FileNameBuf,s+2);
strcat(LOCAL_FileNameBuf,".so");
} else {
strcpy(Yap_FileNameBuf,s);
strcpy(LOCAL_FileNameBuf,s);
}
if((libs->handle=mydlopen(Yap_FileNameBuf)) == NULL)
if((libs->handle=mydlopen(LOCAL_FileNameBuf)) == NULL)
{
strcpy(Yap_ErrorSay,mydlerror());
strcpy(LOCAL_ErrorSay,mydlerror());
return LOAD_FAILLED;
}
libs = libs->next;
@ -184,7 +184,7 @@ LoadForeign(StringList ofiles, StringList libs,
*init_proc = (YapInitProc) mydlsym(proc_name);
if(! *init_proc) {
strcpy(Yap_ErrorSay,"Could not locate initialization routine");
strcpy(LOCAL_ErrorSay,"Could not locate initialization routine");
return LOAD_FAILLED;
}

View File

@ -47,7 +47,7 @@ p_load_foreign( USES_REGS1 )
StringList new;
Int returncode = FALSE;
strcpy(Yap_ErrorSay,"Invalid arguments");
strcpy(LOCAL_ErrorSay,"Invalid arguments");
/* collect the list of object files */
t = Deref(ARG1);
@ -225,10 +225,10 @@ p_open_shared_objects( USES_REGS1 ) {
void
Yap_InitLoadForeign( void )
{
if (Yap_argv == NULL)
if (GLOBAL_argv == NULL)
Yap_FindExecutable("yap");
else
Yap_FindExecutable(Yap_argv[0]);
Yap_FindExecutable(GLOBAL_argv[0]);
Yap_InitCPred("$load_foreign_files", 3, p_load_foreign, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$open_shared_objects", 0, p_open_shared_objects, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$open_shared_object", 3, p_open_shared_object, SyncPredFlag|HiddenPredFlag);

View File

@ -40,7 +40,7 @@ static Int
LoadForeign(StringList ofiles, StringList libs,
char *proc_name, YapInitProc *init_proc)
{
strcpy(Yap_ErrorSay,"load_foreign not supported in this version of Yap");
strcpy(LOCAL_ErrorSay,"load_foreign not supported in this version of Yap");
return LOAD_FAILLED;
}

View File

@ -61,17 +61,17 @@ LoadForeign( StringList ofiles, StringList libs,
int valid_fname;
/* shl_load wants to follow the LD_CONFIG_PATH */
valid_fname = Yap_TrueFileName( AtomName(ofiles->name), Yap_FileNameBuf, TRUE );
valid_fname = Yap_TrueFileName( AtomName(ofiles->name), LOCAL_FileNameBuf, TRUE );
if( !valid_fname ) {
strcpy( Yap_ErrorSay, "%% Trying to open non-existing file in LoadForeign" );
strcpy( LOCAL_ErrorSay, "%% Trying to open non-existing file in LoadForeign" );
return LOAD_FAILLED;
}
ofiles->handle = Yap_AllocCodeSpace( sizeof(shl_t) );
*(shl_t *)ofiles->handle = shl_load( Yap_FileNameBuf, BIND_DEFERRED, 0 );
*(shl_t *)ofiles->handle = shl_load( LOCAL_FileNameBuf, BIND_DEFERRED, 0 );
if( *(shl_t *)ofiles->handle == NULL ) {
strncpy( Yap_ErrorSay, strerror(errno), MAX_ERROR_MSG_SIZE );
strncpy( LOCAL_ErrorSay, strerror(errno), MAX_ERROR_MSG_SIZE );
return LOAD_FAILLED;
}
@ -84,7 +84,7 @@ LoadForeign( StringList ofiles, StringList libs,
}
if( init_missing ) {
strcpy( Yap_ErrorSay, "Could not locate initialization routine" );
strcpy( LOCAL_ErrorSay, "Could not locate initialization routine" );
return LOAD_FAILLED;
}
@ -92,17 +92,17 @@ LoadForeign( StringList ofiles, StringList libs,
char *s = AtomName(lib->s);
if( s[0] == '-' ) {
strcpy( Yap_FileNameBuf, "lib" );
strcat( Yap_FileNameBuf, s+2 );
strcat( Yap_FileNameBuf, ".sl" );
strcpy( LOCAL_FileNameBuf, "lib" );
strcat( LOCAL_FileNameBuf, s+2 );
strcat( LOCAL_FileNameBuf, ".sl" );
}
else {
strcpy( Yap_FileNameBuf, s );
strcpy( LOCAL_FileNameBuf, s );
}
*(shl_t *)libs->handle = shl_load( Yap_FileNameBuf, BIND_DEFERRED, 0 );
*(shl_t *)libs->handle = shl_load( LOCAL_FileNameBuf, BIND_DEFERRED, 0 );
if( *(shl_t *)libs->handle == NULL ) {
strncpy( Yap_ErrorSay, strerror(errno), MAX_ERROR_MSG_SIZE );
strncpy( LOCAL_ErrorSay, strerror(errno), MAX_ERROR_MSG_SIZE );
return LOAD_FAILLED;
}

View File

@ -77,7 +77,7 @@ STATIC_PROTO(Term ParseTerm, (int, JMPBUFF * CACHE_TYPE));
#define TRY(S,P) \
{ Volatile JMPBUFF *saveenv, newenv; \
Volatile TokEntry *saveT=Yap_tokptr; \
Volatile TokEntry *saveT=LOCAL_tokptr; \
Volatile CELL *saveH=H; \
Volatile int savecurprio=curprio; \
saveenv=FailBuff; \
@ -90,13 +90,13 @@ STATIC_PROTO(Term ParseTerm, (int, JMPBUFF * CACHE_TYPE));
else { FailBuff=saveenv; \
H=saveH; \
curprio = savecurprio; \
Yap_tokptr=saveT; \
LOCAL_tokptr=saveT; \
} \
}
#define TRY3(S,P,F) \
{ Volatile JMPBUFF *saveenv, newenv; \
Volatile TokEntry *saveT=Yap_tokptr; \
Volatile TokEntry *saveT=LOCAL_tokptr; \
Volatile CELL *saveH=H; \
saveenv=FailBuff; \
if(!sigsetjmp(newenv.JmpBuff, 0)) { \
@ -108,7 +108,7 @@ STATIC_PROTO(Term ParseTerm, (int, JMPBUFF * CACHE_TYPE));
else { \
FailBuff=saveenv; \
H=saveH; \
Yap_tokptr=saveT; \
LOCAL_tokptr=saveT; \
F } \
}
@ -122,15 +122,15 @@ Yap_LookupVar(char *var) /* lookup variable in variables table */
VarEntry *p;
#ifdef DEBUG
if (Yap_Option[4])
fprintf(Yap_stderr,"[LookupVar %s]", var);
if (GLOBAL_Option[4])
fprintf(GLOBAL_stderr,"[LookupVar %s]", var);
#endif
if (var[0] != '_' || var[1] != '\0') {
VarEntry **op = &Yap_VarTable;
VarEntry **op = &LOCAL_VarTable;
unsigned char *vp = (unsigned char *)var;
UInt hv;
p = Yap_VarTable;
p = LOCAL_VarTable;
hv = HashFunction(vp) % AtomHashTableSize;
while (p != NULL) {
CELL hpv = p->hv;
@ -161,8 +161,8 @@ Yap_LookupVar(char *var) /* lookup variable in variables table */
} else {
/* anon var */
p = (VarEntry *) Yap_AllocScannerMemory(sizeof(VarEntry) + 2);
p->VarLeft = Yap_AnonVarTable;
Yap_AnonVarTable = p;
p->VarLeft = LOCAL_AnonVarTable;
LOCAL_AnonVarTable = p;
p->VarRight = NULL;
p->hv = 0L;
p->VarRep[0] = '_';
@ -182,7 +182,7 @@ VarNames(VarEntry *p,Term l USES_REGS)
VarNames(p->VarLeft,l PASS_REGS) PASS_REGS));
if (H > ASP-4096) {
save_machine_regs();
siglongjmp(Yap_IOBotch,1);
siglongjmp(LOCAL_IOBotch,1);
}
return(o);
} else {
@ -295,24 +295,19 @@ Yap_IsPosfixOp(Atom op, int *pptr, int *lpptr)
inline static void
GNextToken( USES_REGS1 )
{
if (Yap_tokptr->Tok == Ord(eot_tok))
if (LOCAL_tokptr->Tok == Ord(eot_tok))
return;
#ifdef EMACS
if ((Yap_tokptr = Yap_tokptr->TokNext)->TokPos > Yap_toktide->TokPos)
Yap_toktide = Yap_tokptr;
#else
if (Yap_tokptr == Yap_toktide)
Yap_toktide = Yap_tokptr = Yap_tokptr->TokNext;
if (LOCAL_tokptr == LOCAL_toktide)
LOCAL_toktide = LOCAL_tokptr = LOCAL_tokptr->TokNext;
else
Yap_tokptr = Yap_tokptr->TokNext;
#endif
LOCAL_tokptr = LOCAL_tokptr->TokNext;
}
inline static void
checkfor(Term c, JMPBUFF *FailBuff USES_REGS)
{
if (Yap_tokptr->Tok != Ord(Ponctuation_tok)
|| Yap_tokptr->TokInfo != c)
if (LOCAL_tokptr->Tok != Ord(Ponctuation_tok)
|| LOCAL_tokptr->TokInfo != c)
FAIL;
NextToken;
}
@ -331,16 +326,16 @@ ParseArgs(Atom a, JMPBUFF *FailBuff USES_REGS)
p = (Term *) ParserAuxSp;
while (1) {
Term *tp = (Term *)ParserAuxSp;
if (ParserAuxSp+1 > Yap_TrailTop) {
Yap_ErrorMessage = "Trail Overflow";
if (ParserAuxSp+1 > LOCAL_TrailTop) {
LOCAL_ErrorMessage = "Trail Overflow";
FAIL;
}
*tp++ = Unsigned(ParseTerm(999, FailBuff PASS_REGS));
ParserAuxSp = (char *)tp;
++nargs;
if (Yap_tokptr->Tok != Ord(Ponctuation_tok))
if (LOCAL_tokptr->Tok != Ord(Ponctuation_tok))
break;
if (((int) Yap_tokptr->TokInfo) != ',')
if (((int) LOCAL_tokptr->TokInfo) != ',')
break;
NextToken;
}
@ -350,12 +345,12 @@ ParseArgs(Atom a, JMPBUFF *FailBuff USES_REGS)
* order
*/
if (H > ASP-(nargs+1)) {
Yap_ErrorMessage = "Stack Overflow";
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}
func = Yap_MkFunctor(a, nargs);
if (func == NULL) {
Yap_ErrorMessage = "Heap Overflow";
LOCAL_ErrorMessage = "Heap Overflow";
FAIL;
}
#ifdef SFUNC
@ -370,7 +365,7 @@ ParseArgs(Atom a, JMPBUFF *FailBuff USES_REGS)
t = Yap_MkApplTerm(func, nargs, p);
#endif
if (H > ASP-4096) {
Yap_ErrorMessage = "Stack Overflow";
LOCAL_ErrorMessage = "Stack Overflow";
return TermNil;
}
/* check for possible overflow against local stack */
@ -389,25 +384,25 @@ ParseList(JMPBUFF *FailBuff USES_REGS)
to_store = H;
H+=2;
to_store[0] = ParseTerm(999, FailBuff PASS_REGS);
if (Yap_tokptr->Tok == Ord(Ponctuation_tok)) {
if (((int) Yap_tokptr->TokInfo) == ',') {
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)) {
if (((int) LOCAL_tokptr->TokInfo) == ',') {
NextToken;
if (Yap_tokptr->Tok == Ord(Name_tok)
&& strcmp(RepAtom((Atom)(Yap_tokptr->TokInfo))->StrOfAE, "..") == 0) {
if (LOCAL_tokptr->Tok == Ord(Name_tok)
&& strcmp(RepAtom((Atom)(LOCAL_tokptr->TokInfo))->StrOfAE, "..") == 0) {
NextToken;
to_store[1] = ParseTerm(999, FailBuff PASS_REGS);
} else {
/* check for possible overflow against local stack */
if (H > ASP-4096) {
to_store[1] = TermNil;
Yap_ErrorMessage = "Stack Overflow";
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
} else {
to_store[1] = AbsPair(H);
goto loop;
}
}
} else if (((int) Yap_tokptr->TokInfo) == '|') {
} else if (((int) LOCAL_tokptr->TokInfo) == '|') {
NextToken;
to_store[1] = ParseTerm(999, FailBuff PASS_REGS);
} else {
@ -436,14 +431,14 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
Volatile int curprio = 0, opprio, oplprio, oprprio;
Volatile Atom opinfo;
switch (Yap_tokptr->Tok) {
switch (LOCAL_tokptr->Tok) {
case Name_tok:
t = Yap_tokptr->TokInfo;
t = LOCAL_tokptr->TokInfo;
NextToken;
/* special rules apply for +1, -2.3, etc... */
if (Yap_tokptr->Tok == Number_tok) {
if (LOCAL_tokptr->Tok == Number_tok) {
if ((Atom)t == AtomMinus) {
t = Yap_tokptr->TokInfo;
t = LOCAL_tokptr->TokInfo;
if (IsIntTerm(t))
t = MkIntTerm(-IntOfTerm(t));
else if (IsFloatTerm(t))
@ -459,12 +454,12 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
break;
}
}
if ((Yap_tokptr->Tok != Ord(Ponctuation_tok)
|| Unsigned(Yap_tokptr->TokInfo) != 'l')
if ((LOCAL_tokptr->Tok != Ord(Ponctuation_tok)
|| Unsigned(LOCAL_tokptr->TokInfo) != 'l')
&& IsPrefixOp((Atom)t, &opprio, &oprprio PASS_REGS)
) {
if (Yap_tokptr->Tok == Name_tok) {
Atom at = (Atom)Yap_tokptr->TokInfo;
if (LOCAL_tokptr->Tok == Name_tok) {
Atom at = (Atom)LOCAL_tokptr->TokInfo;
#ifndef _MSC_VER
if ((Atom)t == AtomPlus) {
if (at == AtomInf) {
@ -495,14 +490,14 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
/* build appl on the heap */
func = Yap_MkFunctor((Atom) t, 1);
if (func == NULL) {
Yap_ErrorMessage = "Heap Overflow";
LOCAL_ErrorMessage = "Heap Overflow";
FAIL;
}
t = ParseTerm(oprprio, FailBuff PASS_REGS);
t = Yap_MkApplTerm(func, 1, &t);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
Yap_ErrorMessage = "Stack Overflow";
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}
curprio = opprio;
@ -511,21 +506,21 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
)
}
}
if (Yap_tokptr->Tok == Ord(Ponctuation_tok)
&& Unsigned(Yap_tokptr->TokInfo) == 'l')
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)
&& Unsigned(LOCAL_tokptr->TokInfo) == 'l')
t = ParseArgs((Atom) t, FailBuff PASS_REGS);
else
t = MkAtomTerm((Atom)t);
break;
case Number_tok:
t = Yap_tokptr->TokInfo;
t = LOCAL_tokptr->TokInfo;
NextToken;
break;
case String_tok: /* build list on the heap */
{
Volatile char *p = (char *) Yap_tokptr->TokInfo;
Volatile char *p = (char *) LOCAL_tokptr->TokInfo;
if (*p == 0)
t = MkAtomTerm(AtomNil);
else if (yap_flags[YAP_DOUBLE_QUOTES_FLAG] == STRING_AS_CHARS)
@ -533,7 +528,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
else if (yap_flags[YAP_DOUBLE_QUOTES_FLAG] == STRING_AS_ATOM) {
Atom at = Yap_LookupAtom(p);
if (at == NIL) {
Yap_ErrorMessage = "Heap Overflow";
LOCAL_ErrorMessage = "Heap Overflow";
FAIL;
}
t = MkAtomTerm(at);
@ -545,7 +540,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
case WString_tok: /* build list on the heap */
{
Volatile wchar_t *p = (wchar_t *) Yap_tokptr->TokInfo;
Volatile wchar_t *p = (wchar_t *) LOCAL_tokptr->TokInfo;
if (*p == 0)
t = MkAtomTerm(AtomNil);
else if (yap_flags[YAP_DOUBLE_QUOTES_FLAG] == STRING_AS_CHARS)
@ -559,7 +554,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
break;
case Var_tok:
varinfo = (VarEntry *) (Yap_tokptr->TokInfo);
varinfo = (VarEntry *) (LOCAL_tokptr->TokInfo);
if ((t = varinfo->VarAdr) == TermNil) {
t = varinfo->VarAdr = MkVarTerm();
}
@ -570,7 +565,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
FAIL;
case Ponctuation_tok:
switch ((int) Yap_tokptr->TokInfo) {
switch ((int) LOCAL_tokptr->TokInfo) {
case '(':
case 'l': /* non solo ( */
NextToken;
@ -588,7 +583,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
t = Yap_MkApplTerm(FunctorBraces, 1, &t);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
Yap_ErrorMessage = "Stack Overflow";
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}
checkfor((Term) '}', FailBuff PASS_REGS);
@ -605,17 +600,17 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
/* main loop to parse infix and posfix operators starts here */
while (TRUE) {
if (Yap_tokptr->Tok == Ord(Name_tok)
&& Yap_HasOp((Atom)(Yap_tokptr->TokInfo))) {
Atom save_opinfo = opinfo = (Atom)(Yap_tokptr->TokInfo);
if (LOCAL_tokptr->Tok == Ord(Name_tok)
&& Yap_HasOp((Atom)(LOCAL_tokptr->TokInfo))) {
Atom save_opinfo = opinfo = (Atom)(LOCAL_tokptr->TokInfo);
if (IsInfixOp(save_opinfo, &opprio, &oplprio, &oprprio PASS_REGS)
&& opprio <= prio && oplprio >= curprio) {
/* try parsing as infix operator */
Volatile int oldprio = curprio;
TRY3(
func = Yap_MkFunctor((Atom) Yap_tokptr->TokInfo, 2);
func = Yap_MkFunctor((Atom) LOCAL_tokptr->TokInfo, 2);
if (func == NULL) {
Yap_ErrorMessage = "Heap Overflow";
LOCAL_ErrorMessage = "Heap Overflow";
FAIL;
}
NextToken;
@ -626,7 +621,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
t = Yap_MkApplTerm(func, 2, args);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
Yap_ErrorMessage = "Stack Overflow";
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}
},
@ -641,15 +636,15 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
if (IsPosfixOp(opinfo, &opprio, &oplprio PASS_REGS)
&& opprio <= prio && oplprio >= curprio) {
/* parse as posfix operator */
Functor func = Yap_MkFunctor((Atom) Yap_tokptr->TokInfo, 1);
Functor func = Yap_MkFunctor((Atom) LOCAL_tokptr->TokInfo, 1);
if (func == NULL) {
Yap_ErrorMessage = "Heap Overflow";
LOCAL_ErrorMessage = "Heap Overflow";
FAIL;
}
t = Yap_MkApplTerm(func, 1, &t);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
Yap_ErrorMessage = "Stack Overflow";
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}
curprio = opprio;
@ -658,8 +653,8 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
}
break;
}
if (Yap_tokptr->Tok == Ord(Ponctuation_tok)) {
if (Unsigned(Yap_tokptr->TokInfo) == ',' &&
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)) {
if (Unsigned(LOCAL_tokptr->TokInfo) == ',' &&
prio >= 1000 && curprio <= 999) {
Volatile Term args[2];
NextToken;
@ -668,12 +663,12 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
t = Yap_MkApplTerm(FunctorComma, 2, args);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
Yap_ErrorMessage = "Stack Overflow";
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}
curprio = 1000;
continue;
} else if (Unsigned(Yap_tokptr->TokInfo) == '|' &&
} else if (Unsigned(LOCAL_tokptr->TokInfo) == '|' &&
IsInfixOp(AtomVBar, &opprio, &oplprio, &oprprio PASS_REGS)
&& opprio <= prio && oplprio >= curprio) {
Volatile Term args[2];
@ -683,23 +678,23 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
t = Yap_MkApplTerm(FunctorVBar, 2, args);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
Yap_ErrorMessage = "Stack Overflow";
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}
curprio = opprio;
continue;
}
}
if (Yap_tokptr->Tok <= Ord(WString_tok))
if (LOCAL_tokptr->Tok <= Ord(WString_tok))
FAIL;
break;
}
#ifdef DEBUG
if (Yap_Option['p' - 'a' + 1]) {
Yap_DebugPutc(Yap_c_error_stream,'[');
if (GLOBAL_Option['p' - 'a' + 1]) {
Yap_DebugPutc(LOCAL_c_error_stream,'[');
Yap_DebugPlWrite(t);
Yap_DebugPutc(Yap_c_error_stream,']');
Yap_DebugPutc(Yap_c_error_stream,'\n');
Yap_DebugPutc(LOCAL_c_error_stream,']');
Yap_DebugPutc(LOCAL_c_error_stream,'\n');
}
#endif
return t;
@ -715,7 +710,7 @@ Yap_Parse(void)
if (!sigsetjmp(FailBuff.JmpBuff, 0)) {
t = ParseTerm(1200, &FailBuff PASS_REGS);
if (Yap_tokptr->Tok != Ord(eot_tok))
if (LOCAL_tokptr->Tok != Ord(eot_tok))
return (0L);
return (t);
} else

362
C/save.c
View File

@ -164,19 +164,19 @@ do_system_error(yap_error_number etype, const char *msg)
CACHE_REGS
#if HAVE_SNPRINTF
#if HAVE_STRERROR
snprintf(Yap_ErrorSay,MAX_ERROR_MSG_SIZE,"%s (%s when reading %s)", msg, strerror(errno), Yap_FileNameBuf);
snprintf(LOCAL_ErrorSay,MAX_ERROR_MSG_SIZE,"%s (%s when reading %s)", msg, strerror(errno), LOCAL_FileNameBuf);
#else
snprintf(Yap_ErrorSay,MAX_ERROR_MSG_SIZE,"%s, (system error %d when reading %s)",msg,errno,Yap_FileNameBuf);
snprintf(LOCAL_ErrorSay,MAX_ERROR_MSG_SIZE,"%s, (system error %d when reading %s)",msg,errno,LOCAL_FileNameBuf);
#endif
#else
#if HAVE_STRERROR
sprintf(Yap_ErrorSay,"%s, (%s when reading %s)",msg,strerror(errno),Yap_FileNameBuf);
sprintf(LOCAL_ErrorSay,"%s, (%s when reading %s)",msg,strerror(errno),LOCAL_FileNameBuf);
#else
sprintf(Yap_ErrorSay,"%s, (system error %d when reading %s)",msg,errno,Yap_FileNameBuf);
sprintf(LOCAL_ErrorSay,"%s, (system error %d when reading %s)",msg,errno,LOCAL_FileNameBuf);
#endif
#endif
Yap_ErrorMessage = Yap_ErrorSay;
Yap_Error_TYPE = etype;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
LOCAL_Error_TYPE = etype;
return -1;
}
@ -227,7 +227,7 @@ static int splfild = 0;
#ifdef DEBUG_RESTORE4
static FILE *errout;
#else
#define errout Yap_stderr
#define errout GLOBAL_stderr
#endif
#endif /* DEBUG */
@ -349,13 +349,13 @@ put_info(int info, int mode USES_REGS)
return -1;
/* current state of stacks, to be used by SavedInfo */
/* space available in heap area */
if (putout(Unsigned(Yap_GlobalBase)-Unsigned(Yap_HeapBase)) < 0)
if (putout(Unsigned(LOCAL_GlobalBase)-Unsigned(Yap_HeapBase)) < 0)
return -1;
/* space available for stacks */
if (putout(Unsigned(Yap_LocalBase)-Unsigned(Yap_GlobalBase)) < 0)
if (putout(Unsigned(LOCAL_LocalBase)-Unsigned(LOCAL_GlobalBase)) < 0)
return -1;
/* space available for trail */
if (putout(Unsigned(Yap_TrailTop)-Unsigned(Yap_TrailBase)) < 0)
if (putout(Unsigned(LOCAL_TrailTop)-Unsigned(LOCAL_TrailBase)) < 0)
return -1;
/* Space used in heap area */
if (putout(Unsigned(HeapTop)-Unsigned(Yap_HeapBase)) < 0)
@ -364,10 +364,10 @@ put_info(int info, int mode USES_REGS)
if (putout(Unsigned(LCL0)-Unsigned(ASP)) < 0)
return -1;
/* Space used for global stack */
if (putout(Unsigned(H) - Unsigned(Yap_GlobalBase)) < 0)
if (putout(Unsigned(H) - Unsigned(LOCAL_GlobalBase)) < 0)
return -1;
/* Space used for trail */
if (putout(Unsigned(TR) - Unsigned(Yap_TrailBase)) < 0)
if (putout(Unsigned(TR) - Unsigned(LOCAL_TrailBase)) < 0)
return -1;
return 0;
}
@ -422,18 +422,18 @@ save_regs(int mode USES_REGS)
return -1;
if (mode == DO_EVERYTHING) {
#ifdef COROUTINING
if (putout(WokenGoals) < 0)
if (putout(LOCAL_WokenGoals) < 0)
return -1;
#endif
#ifdef DEPTH_LIMIT
if (putout(DEPTH) < 0)
return -1;
#endif
if (putout(GcGeneration) < 0)
if (putout(LOCAL_GcGeneration) < 0)
return -1;
if (putout(GcPhase) < 0)
if (putout(LOCAL_GcPhase) < 0)
return -1;
if (putout(GcCurrentPhase) < 0)
if (putout(LOCAL_GcCurrentPhase) < 0)
return -1;
}
/* The operand base */
@ -459,11 +459,11 @@ save_regs(int mode USES_REGS)
return -1;
if (putcellptr(CellPtr(AuxTop)) < 0)
return -1;
if (putcellptr(CellPtr(ScratchPad.ptr)) < 0)
if (putcellptr(CellPtr(LOCAL_ScratchPad.ptr)) < 0)
return -1;
if (putout(ScratchPad.sz) < 0)
if (putout(LOCAL_ScratchPad.sz) < 0)
return -1;
if (putout(ScratchPad.msz) < 0)
if (putout(LOCAL_ScratchPad.msz) < 0)
return -1;
if (mode == DO_EVERYTHING) {
/* put the old trail base, just in case it moves again */
@ -473,7 +473,7 @@ save_regs(int mode USES_REGS)
if (putout(ARG2) < 0)
return -1;
}
if (putcellptr(CellPtr(Yap_TrailBase)) < 0)
if (putcellptr(CellPtr(LOCAL_TrailBase)) < 0)
return -1;
}
return 0;
@ -528,18 +528,18 @@ save_stacks(int mode USES_REGS)
if (mywrite(splfild, (char *) ASP, j) < 0)
return -1;
/* Save the global stack */
j = Unsigned(H) - Unsigned(Yap_GlobalBase);
if (mywrite(splfild, (char *) Yap_GlobalBase, j) < 0)
j = Unsigned(H) - Unsigned(LOCAL_GlobalBase);
if (mywrite(splfild, (char *) LOCAL_GlobalBase, j) < 0)
return -1;
/* Save the trail */
j = Unsigned(TR) - Unsigned(Yap_TrailBase);
if (mywrite(splfild, (char *) Yap_TrailBase, j) < 0)
j = Unsigned(TR) - Unsigned(LOCAL_TrailBase);
if (mywrite(splfild, (char *) LOCAL_TrailBase, j) < 0)
return -1;
break;
case DO_ONLY_CODE:
{
tr_fr_ptr tr_ptr = TR;
while (tr_ptr != (tr_fr_ptr)Yap_TrailBase) {
while (tr_ptr != (tr_fr_ptr)LOCAL_TrailBase) {
CELL val = TrailTerm(tr_ptr-1);
if (IsVarTerm(val)) {
CELL *d1 = VarOfTerm(val);
@ -577,18 +577,18 @@ do_save(int mode USES_REGS) {
Term t1 = Deref(ARG1);
if (Yap_HoleSize) {
Yap_Error(SYSTEM_ERROR,MkAtomTerm(Yap_LookupAtom(Yap_FileNameBuf)),
Yap_Error(SYSTEM_ERROR,MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)),
"restore/1: address space has holes of size %ld, cannot save", (long int)Yap_HoleSize);
return FALSE;
}
if (!Yap_GetName(Yap_FileNameBuf, YAP_FILENAME_MAX, t1)) {
if (!Yap_GetName(LOCAL_FileNameBuf, YAP_FILENAME_MAX, t1)) {
Yap_Error(TYPE_ERROR_LIST,t1,"save/1");
return FALSE;
}
Scleanup();
Yap_CloseStreams(TRUE);
if ((splfild = open_file(Yap_FileNameBuf, O_WRONLY | O_CREAT)) < 0) {
Yap_Error(SYSTEM_ERROR,MkAtomTerm(Yap_LookupAtom(Yap_FileNameBuf)),
if ((splfild = open_file(LOCAL_FileNameBuf, O_WRONLY | O_CREAT)) < 0) {
Yap_Error(SYSTEM_ERROR,MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)),
"restore/1, open(%s)", strerror(errno));
return(FALSE);
}
@ -616,14 +616,14 @@ p_save2( USES_REGS1 )
Term t;
#ifdef YAPOR
if (Yap_number_workers != 1) {
if (GLOBAL_number_workers != 1) {
Yap_Error(SYSTEM_ERROR,TermNil,
"cannot perform save: more than a worker/thread running");
return(FALSE);
}
#endif /* YAPOR */
#ifdef THREADS
if (Yap_NOfThreads != 1) {
if (GLOBAL_NOfThreads != 1) {
Yap_Error(SYSTEM_ERROR,TermNil,
"cannot perform save: more than a worker/thread running");
return(FALSE);
@ -682,42 +682,42 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS)
}
}
if (strcmp(pp, msg) != 0) {
Yap_ErrorMessage = Yap_ErrorSay;
strncpy(Yap_ErrorMessage, "saved state ", MAX_ERROR_MSG_SIZE);
strncat(Yap_ErrorMessage, Yap_FileNameBuf, MAX_ERROR_MSG_SIZE);
strncat(Yap_ErrorMessage, " failed to match version ID", MAX_ERROR_MSG_SIZE);
Yap_Error_TYPE = CONSISTENCY_ERROR;
LOCAL_ErrorMessage = LOCAL_ErrorSay;
strncpy(LOCAL_ErrorMessage, "saved state ", MAX_ERROR_MSG_SIZE);
strncat(LOCAL_ErrorMessage, LOCAL_FileNameBuf, MAX_ERROR_MSG_SIZE);
strncat(LOCAL_ErrorMessage, " failed to match version ID", MAX_ERROR_MSG_SIZE);
LOCAL_Error_TYPE = CONSISTENCY_ERROR;
return FAIL_RESTORE;
}
/* check info on header */
/* ignore info on saved state */
*info = get_header_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return FAIL_RESTORE;
/* check the restore mode */
mode = get_header_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return FAIL_RESTORE;
if (mode != DO_EVERYTHING && mode != DO_ONLY_CODE) {
return FAIL_RESTORE;
}
/* ignore info on stacks size */
*AHeap = get_header_cell();
if (Yap_ErrorMessage) {
if (LOCAL_ErrorMessage) {
return FAIL_RESTORE;
}
*AStack = get_header_cell();
if (Yap_ErrorMessage) {
if (LOCAL_ErrorMessage) {
return FAIL_RESTORE;
}
*ATrail = get_header_cell();
if (Yap_ErrorMessage) {
if (LOCAL_ErrorMessage) {
return FAIL_RESTORE;
}
/* now, check whether we got enough enough space to load the
saved space */
hp_size = get_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return FAIL_RESTORE;
while (Yap_HeapBase != NULL &&
hp_size > Unsigned(HeapLim) - Unsigned(Yap_HeapBase)) {
@ -727,31 +727,31 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS)
}
if (mode == DO_EVERYTHING) {
lc_size = get_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return FAIL_RESTORE;
gb_size=get_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return FAIL_RESTORE;
if (Yap_HeapBase != NULL && lc_size+gb_size > Unsigned(Yap_LocalBase) - Unsigned(Yap_GlobalBase)) {
if (Yap_ErrorMessage != NULL)
Yap_ErrorMessage = "could not allocate enough stack space";
if (Yap_HeapBase != NULL && lc_size+gb_size > Unsigned(LOCAL_LocalBase) - Unsigned(LOCAL_GlobalBase)) {
if (LOCAL_ErrorMessage != NULL)
LOCAL_ErrorMessage = "could not allocate enough stack space";
return FAIL_RESTORE;
}
if (Yap_HeapBase != NULL && (tr_size = get_cell()) > Unsigned(Yap_TrailTop) - Unsigned(Yap_TrailBase)) {
if (Yap_ErrorMessage != NULL)
Yap_ErrorMessage = "could not allocate enough trail space";
if (Yap_HeapBase != NULL && (tr_size = get_cell()) > Unsigned(LOCAL_TrailTop) - Unsigned(LOCAL_TrailBase)) {
if (LOCAL_ErrorMessage != NULL)
LOCAL_ErrorMessage = "could not allocate enough trail space";
return FAIL_RESTORE;
}
} else {
/* skip cell size */
get_header_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return FAIL_RESTORE;
get_header_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return FAIL_RESTORE;
get_header_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return FAIL_RESTORE;
}
return(mode);
@ -761,38 +761,38 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS)
static int
get_heap_info(USES_REGS1)
{
OldHeapBase = (ADDR) get_cellptr();
if (Yap_ErrorMessage)
LOCAL_OldHeapBase = (ADDR) get_cellptr();
if (LOCAL_ErrorMessage)
return -1;
OldHeapTop = (ADDR) get_cellptr();
LOCAL_OldHeapTop = (ADDR) get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
OldHeapUsed = (Int) get_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
FreeBlocks = (BlockHeader *) get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
AuxBase = (ADDR)get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
AuxSp = get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
AuxTop = (ADDR)get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
ScratchPad.ptr = (ADDR)get_cellptr();
if (Yap_ErrorMessage)
LOCAL_ScratchPad.ptr = (ADDR)get_cellptr();
if (LOCAL_ErrorMessage)
return -1;
ScratchPad.sz = get_cell();
if (Yap_ErrorMessage)
LOCAL_ScratchPad.sz = get_cell();
if (LOCAL_ErrorMessage)
return -1;
ScratchPad.msz = get_cell();
if (Yap_ErrorMessage)
LOCAL_ScratchPad.msz = get_cell();
if (LOCAL_ErrorMessage)
return -1;
HDiff = Unsigned(Yap_HeapBase) - Unsigned(OldHeapBase);
LOCAL_HDiff = Unsigned(Yap_HeapBase) - Unsigned(LOCAL_OldHeapBase);
return 1;
}
@ -802,130 +802,130 @@ get_heap_info(USES_REGS1)
static int
get_regs(int flag USES_REGS)
{
CELL *NewGlobalBase = (CELL *)Yap_GlobalBase;
CELL *NewGlobalBase = (CELL *)LOCAL_GlobalBase;
CELL *NewLCL0 = LCL0;
CELL *OldXREGS;
/* Get regs */
compile_arrays = (int)get_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
if (flag == DO_EVERYTHING) {
CP = (yamop *)get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
ENV = get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
ASP = get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
/* N = get_cell(); */
H0 = get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
LCL0 = get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
H = get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
HB = get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
B = (choiceptr)get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
TR = (tr_fr_ptr)get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
YENV = get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
S = get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
P = (yamop *)get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
CreepFlag = get_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
EX = (struct DB_TERM *)get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
#if defined(YAPOR_SBA) || defined(TABLING)
H_FZ = get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
B_FZ = (choiceptr)get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
TR_FZ = (tr_fr_ptr)get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
#endif /* YAPOR_SBA || TABLING */
}
CurrentModule = get_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
if (flag == DO_EVERYTHING) {
#ifdef COROUTINING
WokenGoals = get_cell();
if (Yap_ErrorMessage)
LOCAL_WokenGoals = get_cell();
if (LOCAL_ErrorMessage)
return -1;
#endif
#ifdef DEPTH_LIMIT
DEPTH = get_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
#endif
GcGeneration = get_cell();
if (Yap_ErrorMessage)
LOCAL_GcGeneration = get_cell();
if (LOCAL_ErrorMessage)
return -1;
GcPhase = get_cell();
if (Yap_ErrorMessage)
LOCAL_GcPhase = get_cell();
if (LOCAL_ErrorMessage)
return -1;
GcCurrentPhase = get_cell();
if (Yap_ErrorMessage)
LOCAL_GcCurrentPhase = get_cell();
if (LOCAL_ErrorMessage)
return -1;
}
/* Get the old bases */
OldXREGS = get_cellptr();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
which_save = get_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
XDiff = (CELL)XREGS - (CELL)OldXREGS;
if (Yap_ErrorMessage)
LOCAL_XDiff = (CELL)XREGS - (CELL)OldXREGS;
if (LOCAL_ErrorMessage)
return -1;
if (get_heap_info( PASS_REGS1 ) < 0)
return -1;
if (flag == DO_EVERYTHING) {
ARG1 = get_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
if (which_save == 2) {
ARG2 = get_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
}
/* get old trail base */
OldTrailBase = (ADDR)get_cellptr();
if (Yap_ErrorMessage)
LOCAL_OldTrailBase = (ADDR)get_cellptr();
if (LOCAL_ErrorMessage)
return -1;
/* Save the old register where we can easily access them */
OldASP = ASP;
OldLCL0 = LCL0;
OldGlobalBase = (CELL *)Yap_GlobalBase;
OldH = H;
OldTR = TR;
GDiff = Unsigned(NewGlobalBase) - Unsigned(Yap_GlobalBase);
GDiff0 = 0;
LDiff = Unsigned(NewLCL0) - Unsigned(LCL0);
TrDiff = LDiff;
Yap_GlobalBase = (ADDR)NewGlobalBase;
LOCAL_OldASP = ASP;
LOCAL_OldLCL0 = LCL0;
LOCAL_OldGlobalBase = (CELL *)LOCAL_GlobalBase;
LOCAL_OldH = H;
LOCAL_OldTR = TR;
LOCAL_GDiff = Unsigned(NewGlobalBase) - Unsigned(LOCAL_GlobalBase);
LOCAL_GDiff0 = 0;
LOCAL_LDiff = Unsigned(NewLCL0) - Unsigned(LCL0);
LOCAL_TrDiff = LOCAL_LDiff;
LOCAL_GlobalBase = (ADDR)NewGlobalBase;
LCL0 = NewLCL0;
}
return 1;
@ -949,7 +949,7 @@ get_hash(void)
static int
CopyCode( USES_REGS1 )
{
if (myread(splfild, (char *) Yap_HeapBase, (Unsigned(OldHeapTop) - Unsigned(OldHeapBase))) < 0) {
if (myread(splfild, (char *) Yap_HeapBase, (Unsigned(LOCAL_OldHeapTop) - Unsigned(LOCAL_OldHeapBase))) < 0) {
return -1;
}
return 1;
@ -963,15 +963,15 @@ CopyStacks( USES_REGS1 )
Int j;
char *NewASP;
j = Unsigned(OldLCL0) - Unsigned(ASP);
NewASP = (char *) (Unsigned(ASP) + (Unsigned(LCL0) - Unsigned(OldLCL0)));
j = Unsigned(LOCAL_OldLCL0) - Unsigned(ASP);
NewASP = (char *) (Unsigned(ASP) + (Unsigned(LCL0) - Unsigned(LOCAL_OldLCL0)));
if (myread(splfild, (char *) NewASP, j) < 0)
return -1;
j = Unsigned(H) - Unsigned(OldGlobalBase);
if (myread(splfild, (char *) Yap_GlobalBase, j) < 0)
j = Unsigned(H) - Unsigned(LOCAL_OldGlobalBase);
if (myread(splfild, (char *) LOCAL_GlobalBase, j) < 0)
return -1;
j = Unsigned(TR) - Unsigned(OldTrailBase);
if (myread(splfild, Yap_TrailBase, j))
j = Unsigned(TR) - Unsigned(LOCAL_OldTrailBase);
if (myread(splfild, LOCAL_TrailBase, j))
return -1;
return 1;
}
@ -983,10 +983,10 @@ CopyTrailEntries( USES_REGS1 )
{
CELL entry, *Entries;
Entries = (CELL *)Yap_TrailBase;
Entries = (CELL *)LOCAL_TrailBase;
do {
*Entries++ = entry = get_cell();
if (Yap_ErrorMessage)
if (LOCAL_ErrorMessage)
return -1;
} while ((CODEADDR)entry != NULL);
return 1;
@ -1020,7 +1020,7 @@ get_coded(int flag, OPCODE old_ops[] USES_REGS)
if (myread(splfild, my_end_msg, 256) < 0)
return -1;
if (strcmp(end_msg,my_end_msg) != 0) {
Yap_ErrorMessage = "bad trailing CRC in saved state";
LOCAL_ErrorMessage = "bad trailing CRC in saved state";
return -1;
}
return 1;
@ -1035,7 +1035,7 @@ restore_heap_regs( USES_REGS1 )
*((YAP_SEG_SIZE *) HeapTop) = InUseFlag;
}
HeapMax = Yap_heap_regs->heap_used = OldHeapUsed;
HeapLim = Yap_GlobalBase;
HeapLim = LOCAL_GlobalBase;
}
/* adjust abstract machine registers */
@ -1061,7 +1061,7 @@ restore_regs(int flag USES_REGS)
EX = DBTermAdjust(EX);
RestoreDBTerm(EX, TRUE PASS_REGS);
}
WokenGoals = AbsAppl(PtoGloAdjust(RepAppl(WokenGoals)));
LOCAL_WokenGoals = AbsAppl(PtoGloAdjust(RepAppl(LOCAL_WokenGoals)));
}
}
@ -1137,13 +1137,13 @@ rehash(CELL *oldcode, int NOfE, int KindOfEntries USES_REGS)
CELL WorkTerm, failplace = 0;
CELL *Base = oldcode;
if (HDiff == 0)
if (LOCAL_HDiff == 0)
return;
basep = H;
if (H + (NOfE*2) > ASP) {
basep = (CELL *)TR;
if (basep + (NOfE*2) > (CELL *)Yap_TrailTop) {
if (!Yap_growtrail((ADDR)(basep + (NOfE*2))-Yap_TrailTop, TRUE)) {
if (basep + (NOfE*2) > (CELL *)LOCAL_TrailTop) {
if (!Yap_growtrail((ADDR)(basep + (NOfE*2))-LOCAL_TrailTop, TRUE)) {
Yap_Error(OUT_OF_TRAIL_ERROR, TermNil,
"not enough space to restore hash tables for indexing");
Yap_exit(1);
@ -1216,7 +1216,7 @@ RestoreFreeSpace( USES_REGS1 )
Yap_av = (struct malloc_state *)AddrAdjust((ADDR)Yap_av);
Yap_RestoreDLMalloc();
if (AuxSp != NULL) {
if (AuxBase < OldHeapBase || AuxBase > OldHeapTop) {
if (AuxBase < LOCAL_OldHeapBase || AuxBase > LOCAL_OldHeapTop) {
AuxSp = NULL;
AuxBase = NULL;
AuxTop = NULL;
@ -1224,7 +1224,7 @@ RestoreFreeSpace( USES_REGS1 )
AuxSp = PtoHeapCellAdjust(AuxSp);
AuxBase = AddrAdjust(AuxBase);
AuxTop = AddrAdjust(AuxTop);
ScratchPad.ptr = AddrAdjust(ScratchPad.ptr);
LOCAL_ScratchPad.ptr = AddrAdjust(LOCAL_ScratchPad.ptr);
}
}
#else
@ -1337,7 +1337,7 @@ ShowEntries(pp)
PropEntry *pp;
{
while (!EndOfPAEntr(pp)) {
fprintf(Yap_stderr,"Estou a ver a prop %x em %x\n", pp->KindOfPE, pp);
fprintf(GLOBAL_stderr,"Estou a ver a prop %x em %x\n", pp->KindOfPE, pp);
pp = RepProp(pp->NextOfPE);
}
}
@ -1352,7 +1352,7 @@ ShowAtoms()
AtomEntry *at;
at = RepAtom(HashPtr->Entry);
do {
fprintf(Yap_stderr,"Passei ao %s em %x\n", at->StrOfAE, at);
fprintf(GLOBAL_stderr,"Passei ao %s em %x\n", at->StrOfAE, at);
ShowEntries(RepProp(at->PropsOfAE));
} while (!EndOfPAEntr(at = RepAtom(at->NextOfAE)));
}
@ -1364,7 +1364,7 @@ ShowAtoms()
AtomEntry *at;
at = RepAtom(HashPtr->Entry);
do {
fprintf(Yap_stderr,"Passei ao %s em %x\n", at->StrOfAE, at);
fprintf(GLOBAL_stderr,"Passei ao %s em %x\n", at->StrOfAE, at);
ShowEntries(RepProp(at->PropsOfAE));
} while (!EndOfPAEntr(at = RepAtom(at->NextOfAE)));
}
@ -1383,12 +1383,12 @@ commit_to_saved_state(char *s, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *A
if ((mode = check_header(Astate,ATrail,AStack,AHeap PASS_REGS)) == FAIL_RESTORE)
return(FAIL_RESTORE);
Yap_PrologMode = BootMode;
LOCAL_PrologMode = BootMode;
if (Yap_HeapBase) {
extern void Scleanup(void);
if (!yap_flags[HALT_AFTER_CONSULT_FLAG] && !yap_flags[QUIET_MODE_FLAG]) {
Yap_TrueFileName(s,Yap_FileNameBuf2, YAP_FILENAME_MAX);
fprintf(stderr, "%% Restoring file %s\n", Yap_FileNameBuf2);
Yap_TrueFileName(s,LOCAL_FileNameBuf2, YAP_FILENAME_MAX);
fprintf(stderr, "%% Restoring file %s\n", LOCAL_FileNameBuf2);
}
Scleanup();
Yap_CloseStreams(TRUE);
@ -1397,7 +1397,7 @@ commit_to_saved_state(char *s, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *A
/*
* This should be another file, like the log file
*/
errout = Yap_stderr;
errout = GLOBAL_stderr;
#endif
return mode;
}
@ -1425,7 +1425,7 @@ static int try_open(char *inpf, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *
strncpy(buf, inpf, YAP_FILENAME_MAX);
if ((mode = commit_to_saved_state(inpf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE) {
CACHE_REGS
Yap_ErrorMessage = NULL;
LOCAL_ErrorMessage = NULL;
return mode;
}
return mode;
@ -1437,8 +1437,7 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
CACHE_REGS
int mode = FAIL_RESTORE;
char save_buffer[YAP_FILENAME_MAX+1];
// Yap_ErrorMessage = NULL;
// LOCAL_ErrorMessage = NULL;
if (inpf == NULL) {
#if _MSC_VER || defined(__MINGW32__)
if (!(inpf = Yap_RegistryGetString("startup")))
@ -1449,18 +1448,18 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
if (inpf[0] != '/') {
#if __simplescalar__
/* does not implement getcwd */
strncpy(Yap_FileNameBuf,yap_pwd,YAP_FILENAME_MAX);
strncpy(LOCAL_FileNameBuf,GLOBAL_pwd,YAP_FILENAME_MAX);
#elif HAVE_GETCWD
if (getcwd (Yap_FileNameBuf, YAP_FILENAME_MAX) == NULL)
Yap_FileNameBuf[0] = '\0';
if (getcwd (LOCAL_FileNameBuf, YAP_FILENAME_MAX) == NULL)
LOCAL_FileNameBuf[0] = '\0';
#else
if (getwd (Yap_FileNameBuf) == NULL)
Yap_FileNameBuf[0] = '\0';
if (getwd (LOCAL_FileNameBuf) == NULL)
LOCAL_FileNameBuf[0] = '\0';
#endif
strncat(Yap_FileNameBuf, "/", YAP_FILENAME_MAX-1);
strncat(Yap_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
strncat(LOCAL_FileNameBuf, "/", YAP_FILENAME_MAX-1);
strncat(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
} else {
strncat(Yap_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
strncat(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
}
if (inpf != NULL && (splfild = open_file(inpf, O_RDONLY)) > 0) {
if ((mode = try_open(inpf,Astate,ATrail,AStack,AHeap,save_buffer)) != FAIL_RESTORE) {
@ -1473,12 +1472,12 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
using YAPLIBDIR or friends.
*/
if (YapLibDir != NULL) {
cat_file_name(Yap_FileNameBuf, Yap_LibDir, inpf, YAP_FILENAME_MAX);
if ((mode = try_open(Yap_FileNameBuf,Astate,ATrail,AStack,AHeap,save_buffer)) != FAIL_RESTORE) {
cat_file_name(LOCAL_FileNameBuf, Yap_LibDir, inpf, YAP_FILENAME_MAX);
if ((mode = try_open(LOCAL_FileNameBuf,Astate,ATrail,AStack,AHeap,save_buffer)) != FAIL_RESTORE) {
return mode;
}
} else {
if ((mode = try_open(Yap_FileNameBuf,Astate,ATrail,AStack,AHeap,save_buffer)) != FAIL_RESTORE) {
if ((mode = try_open(LOCAL_FileNameBuf,Astate,ATrail,AStack,AHeap,save_buffer)) != FAIL_RESTORE) {
return mode;
}
}
@ -1486,17 +1485,17 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
{
char *yap_env = getenv("YAPLIBDIR");
if (yap_env != NULL) {
cat_file_name(Yap_FileNameBuf, yap_env, inpf, YAP_FILENAME_MAX);
if ((mode = try_open(Yap_FileNameBuf,Astate,ATrail,AStack,AHeap,save_buffer)) != FAIL_RESTORE) {
cat_file_name(LOCAL_FileNameBuf, yap_env, inpf, YAP_FILENAME_MAX);
if ((mode = try_open(LOCAL_FileNameBuf,Astate,ATrail,AStack,AHeap,save_buffer)) != FAIL_RESTORE) {
return mode;
}
}
}
#endif
if (YAP_LIBDIR != NULL) {
cat_file_name(Yap_FileNameBuf, YAP_LIBDIR, inpf, YAP_FILENAME_MAX);
if ((splfild = open_file(Yap_FileNameBuf, O_RDONLY)) > 0) {
if ((mode = try_open(Yap_FileNameBuf,Astate,ATrail,AStack,AHeap,save_buffer)) != FAIL_RESTORE) {
cat_file_name(LOCAL_FileNameBuf, YAP_LIBDIR, inpf, YAP_FILENAME_MAX);
if ((splfild = open_file(LOCAL_FileNameBuf, O_RDONLY)) > 0) {
if ((mode = try_open(LOCAL_FileNameBuf,Astate,ATrail,AStack,AHeap,save_buffer)) != FAIL_RESTORE) {
return mode;
}
}
@ -1509,34 +1508,34 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
char *pt;
/* try to get it from current executable */
if ((fatts = GetFileAttributes(Yap_FileNameBuf)) == 0xFFFFFFFFL ||
if ((fatts = GetFileAttributes(LOCAL_FileNameBuf)) == 0xFFFFFFFFL ||
!(fatts & FILE_ATTRIBUTE_DIRECTORY)) {
/* couldn't find it where it was supposed to be,
let's try using the executable */
if (!GetModuleFileNameEx( GetCurrentProcess(), NULL, Yap_FileNameBuf, YAP_FILENAME_MAX)) {
if (!GetModuleFileNameEx( GetCurrentProcess(), NULL, LOCAL_FileNameBuf, YAP_FILENAME_MAX)) {
/* do nothing */
goto end;
}
buflen = strlen(Yap_FileNameBuf);
pt = Yap_FileNameBuf+strlen(Yap_FileNameBuf);
buflen = strlen(LOCAL_FileNameBuf);
pt = LOCAL_FileNameBuf+strlen(LOCAL_FileNameBuf);
while (*--pt != '\\') {
/* skip executable */
if (pt == Yap_FileNameBuf) {
if (pt == LOCAL_FileNameBuf) {
/* do nothing */
goto end;
}
}
while (*--pt != '\\') {
/* skip parent directory "bin\\" */
if (pt == Yap_FileNameBuf) {
if (pt == LOCAL_FileNameBuf) {
goto end;
}
}
/* now, this is a possible location for the ROOT_DIR, let's look for a share directory here */
pt[1] = '\0';
strncat(Yap_FileNameBuf,"lib/Yap/startup.yss",YAP_FILENAME_MAX);
strncat(LOCAL_FileNameBuf,"lib/Yap/startup.yss",YAP_FILENAME_MAX);
}
if ((mode = try_open(Yap_FileNameBuf,Astate,ATrail,AStack,AHeap,save_buffer)) != FAIL_RESTORE) {
if ((mode = try_open(LOCAL_FileNameBuf,Astate,ATrail,AStack,AHeap,save_buffer)) != FAIL_RESTORE) {
return mode;
}
}
@ -1544,12 +1543,12 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
#endif
/* try to open from current directory */
/* could not open file */
if (Yap_ErrorMessage == NULL) {
if (LOCAL_ErrorMessage == NULL) {
if (save_buffer[0]) {
strncpy(Yap_FileNameBuf, save_buffer, YAP_FILENAME_MAX-1);
strncpy(LOCAL_FileNameBuf, save_buffer, YAP_FILENAME_MAX-1);
do_system_error(PERMISSION_ERROR_OPEN_SOURCE_SINK,"incorrect saved state");
} else {
strncpy(Yap_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
strncpy(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
do_system_error(PERMISSION_ERROR_OPEN_SOURCE_SINK,"could not open saved state");
}
}
@ -1559,11 +1558,12 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
static void
CloseRestore(void)
{
CACHE_REGS
#ifdef DEBUG_RESTORE3
ShowAtoms();
#endif
close_file();
Yap_PrologMode = UserMode;
LOCAL_PrologMode = UserMode;
}
#if !defined(_WIN32)
@ -1590,8 +1590,8 @@ check_opcodes(OPCODE old_ops[])
static void
RestoreHeap(OPCODE old_ops[] USES_REGS)
{
int heap_moved = (OldHeapBase != Yap_HeapBase ||
XDiff), opcodes_moved;
int heap_moved = (LOCAL_OldHeapBase != Yap_HeapBase ||
LOCAL_XDiff), opcodes_moved;
Term mod = CurrentModule;
CurrentModule = PROLOG_MODULE;
@ -1660,7 +1660,7 @@ UnmarkTrEntries( USES_REGS1 )
B = (choiceptr)LCL0;
B--;
B->cp_ap = NOCODE;
Entries = (CELL *)Yap_TrailBase;
Entries = (CELL *)LOCAL_TrailBase;
while ((entry = *Entries++) != (CELL)NULL) {
if (!IsVarTerm(entry)) {
if(IsPairTerm(entry)) {
@ -1740,10 +1740,10 @@ Restore(char *s, char *lib_dir USES_REGS)
RestoreHeap(old_ops PASS_REGS);
switch(restore_mode) {
case DO_EVERYTHING:
if (OldHeapBase != Yap_HeapBase ||
OldLCL0 != LCL0 ||
OldGlobalBase != (CELL *)Yap_GlobalBase ||
OldTrailBase != Yap_TrailBase) {
if (LOCAL_OldHeapBase != Yap_HeapBase ||
LOCAL_OldLCL0 != LCL0 ||
LOCAL_OldGlobalBase != (CELL *)LOCAL_GlobalBase ||
LOCAL_OldTrailBase != LOCAL_TrailBase) {
Yap_AdjustStacksAndTrail();
if (which_save == 2) {
Yap_AdjustRegs(2);
@ -1796,13 +1796,13 @@ p_restore( USES_REGS1 )
Term t1 = Deref(ARG1);
#ifdef YAPOR
if (Yap_number_workers != 1) {
if (GLOBAL_number_workers != 1) {
Yap_Error(SYSTEM_ERROR,TermNil,"cannot perform save: more than a worker/thread running");
return(FALSE);
}
#endif /* YAPOR */
#ifdef THREADS
if (Yap_NOfThreads != 1) {
if (GLOBAL_NOfThreads != 1) {
Yap_Error(SYSTEM_ERROR,TermNil,"cannot perform save: more than a worker/thread running");
return(FALSE);
}
@ -1816,7 +1816,7 @@ p_restore( USES_REGS1 )
restore_absmi_regs(&Yap_standard_regs);
#endif
/* back to the top level we go */
siglongjmp(Yap_RestartEnv,3);
siglongjmp(LOCAL_RestartEnv,3);
}
return(mode != FAIL_RESTORE);
}

View File

@ -173,18 +173,18 @@ AllocScannerMemory(unsigned int size)
CACHE_REGS
char *AuxSpScan;
AuxSpScan = ScannerStack;
AuxSpScan = LOCAL_ScannerStack;
size = AdjustSize(size);
if (ScannerExtraBlocks) {
if (LOCAL_ScannerExtraBlocks) {
struct scanner_extra_alloc *ptr;
if (!(ptr = (struct scanner_extra_alloc *)malloc(size+sizeof(ScannerExtraBlock)))) {
return NULL;
}
ptr->next = ScannerExtraBlocks;
ScannerExtraBlocks = ptr;
ptr->next = LOCAL_ScannerExtraBlocks;
LOCAL_ScannerExtraBlocks = ptr;
return (char *)(ptr+1);
} else if (Yap_TrailTop <= AuxSpScan+size) {
} else if (LOCAL_TrailTop <= AuxSpScan+size) {
UInt alloc_size = sizeof(CELL) * K16;
if (size > alloc_size)
@ -195,12 +195,12 @@ AllocScannerMemory(unsigned int size)
if (!(ptr = (struct scanner_extra_alloc *)malloc(size+sizeof(ScannerExtraBlock)))) {
return NULL;
}
ptr->next = ScannerExtraBlocks;
ScannerExtraBlocks = ptr;
ptr->next = LOCAL_ScannerExtraBlocks;
LOCAL_ScannerExtraBlocks = ptr;
return (char *)(ptr+1);
}
}
ScannerStack = AuxSpScan+size;
LOCAL_ScannerStack = AuxSpScan+size;
return AuxSpScan;
}
@ -208,12 +208,12 @@ static void
PopScannerMemory(char *block, unsigned int size)
{
CACHE_REGS
if (block == ScannerStack-size) {
ScannerStack -= size;
} else if (block == (char *)(ScannerExtraBlocks+1)) {
struct scanner_extra_alloc *ptr = ScannerExtraBlocks;
if (block == LOCAL_ScannerStack-size) {
LOCAL_ScannerStack -= size;
} else if (block == (char *)(LOCAL_ScannerExtraBlocks+1)) {
struct scanner_extra_alloc *ptr = LOCAL_ScannerExtraBlocks;
ScannerExtraBlocks = ptr->next;
LOCAL_ScannerExtraBlocks = ptr->next;
free(ptr);
}
}
@ -235,7 +235,7 @@ float_send(char *s, int sign)
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) { /* iso */
if (!finite(f)) {
CACHE_REGS
Yap_ErrorMessage = "Float overflow while scanning";
LOCAL_ErrorMessage = "Float overflow while scanning";
return(MkEvalFl(0.0));
}
}
@ -268,7 +268,7 @@ static int
send_error_message(char s[])
{
CACHE_REGS
Yap_ErrorMessage = s;
LOCAL_ErrorMessage = s;
return 0;
}
@ -502,7 +502,7 @@ static int
num_send_error_message(char s[])
{
CACHE_REGS
Yap_ErrorMessage = s;
LOCAL_ErrorMessage = s;
return TermNil;
}
@ -727,12 +727,12 @@ Yap_scan_num(IOSTREAM *inp)
int ch, cherr;
char *ptr;
Yap_ErrorMessage = NULL;
ScannerStack = (char *)TR;
ScannerExtraBlocks = NULL;
LOCAL_ErrorMessage = NULL;
LOCAL_ScannerStack = (char *)TR;
LOCAL_ScannerExtraBlocks = NULL;
if (!(ptr = AllocScannerMemory(4096))) {
Yap_ErrorMessage = "Trail Overflow";
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
LOCAL_ErrorMessage = "Trail Overflow";
LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR;
return TermNil;
}
ch = getchr(inp);
@ -755,7 +755,7 @@ Yap_scan_num(IOSTREAM *inp)
out = get_num(&ch, &cherr, inp, ptr, 4096, sign); /* */
PopScannerMemory(ptr, 4096);
Yap_clean_tokenizer(NULL, NULL, NULL);
if (Yap_ErrorMessage != NULL || ch != -1 || cherr)
if (LOCAL_ErrorMessage != NULL || ch != -1 || cherr)
return TermNil;
return out;
}
@ -769,8 +769,8 @@ ch_to_wide(char *base, char *charp)
wchar_t *nb = (wchar_t *)base;
if ((nb+n) + 1024 > (wchar_t *)AuxSp) {
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
Yap_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)";
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)";
return NULL;
}
for (i=n; i > 0; i--) {
@ -800,13 +800,12 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
int ch;
wchar_t *wcharp;
Yap_ErrorMessage = NULL;
Yap_Error_Size = 0;
Yap_VarTable = NULL;
Yap_AnonVarTable = NULL;
Yap_eot_before_eof = FALSE;
ScannerStack = (char *)TR;
ScannerExtraBlocks = NULL;
LOCAL_ErrorMessage = NULL;
LOCAL_Error_Size = 0;
LOCAL_VarTable = NULL;
LOCAL_AnonVarTable = NULL;
LOCAL_ScannerStack = (char *)TR;
LOCAL_ScannerExtraBlocks = NULL;
l = NULL;
p = NULL; /* Just to make lint happy */
ch = getchr(inp_stream);
@ -814,7 +813,7 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
ch = getchr(inp_stream);
}
*tposp = Yap_StreamPosition(inp_stream);
StartLine = inp_stream->posbuf.lineno;
LOCAL_StartLine = inp_stream->posbuf.lineno;
do {
wchar_t och;
int quote, isvar;
@ -826,8 +825,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
t = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
t->TokNext = NULL;
if (t == NULL) {
Yap_ErrorMessage = "Trail Overflow";
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
LOCAL_ErrorMessage = "Trail Overflow";
LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR;
if (p)
p->Tok = Ord(kind = eot_tok);
/* serious error now */
@ -855,6 +854,15 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
while (chtype(ch) == BS) {
ch = getchr(inp_stream);
}
if (ASP-H < 1024) {
LOCAL_ErrorMessage = "Stack Overflow";
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
LOCAL_Error_Size = 0L;
if (p)
p->Tok = Ord(kind = eot_tok);
/* serious error now */
return l;
}
*tposp = Yap_StreamPosition(inp_stream);
}
goto restart;
@ -878,8 +886,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
if (charp == (char *)AuxSp-1024) {
huge_var_error:
/* huge atom or variable, we are in trouble */
Yap_ErrorMessage = "Code Space Overflow due to huge atom";
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_ErrorMessage = "Code Space Overflow due to huge atom";
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
if (p)
p->Tok = Ord(kind = eot_tok);
@ -905,8 +913,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
ae = Yap_LookupAtom(TokImage);
}
if (ae == NIL) {
Yap_Error_TYPE = OUT_OF_HEAP_ERROR;
Yap_ErrorMessage = "Code Space Overflow";
LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR;
LOCAL_ErrorMessage = "Code Space Overflow";
if (p)
t->Tok = Ord(kind = eot_tok);
/* serious error now */
@ -932,17 +940,17 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
cherr = 0;
if (!(ptr = AllocScannerMemory(4096))) {
Yap_ErrorMessage = "Trail Overflow";
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
LOCAL_ErrorMessage = "Trail Overflow";
LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR;
if (p)
t->Tok = Ord(kind = eot_tok);
/* serious error now */
return l;
}
if (ASP-H < 1024) {
Yap_ErrorMessage = "Stack Overflow";
Yap_Error_TYPE = OUT_OF_STACK_ERROR;
Yap_Error_Size = 0L;
LOCAL_ErrorMessage = "Stack Overflow";
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
LOCAL_Error_Size = 0L;
if (p)
p->Tok = Ord(kind = eot_tok);
/* serious error now */
@ -962,8 +970,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
t->TokPos = GetCurInpPos(inp_stream);
e = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
if (e == NULL) {
Yap_ErrorMessage = "Trail Overflow";
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
LOCAL_ErrorMessage = "Trail Overflow";
LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR;
if (p)
p->Tok = Ord(kind = eot_tok);
/* serious error now */
@ -991,8 +999,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
t->TokPos = GetCurInpPos(inp_stream);
e2 = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
if (e2 == NULL) {
Yap_ErrorMessage = "Trail Overflow";
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
LOCAL_ErrorMessage = "Trail Overflow";
LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR;
if (p)
p->Tok = Ord(kind = eot_tok);
/* serious error now */
@ -1022,8 +1030,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
t->TokPos = GetCurInpPos(inp_stream);
e2 = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
if (e2 == NULL) {
Yap_ErrorMessage = "Trail Overflow";
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
LOCAL_ErrorMessage = "Trail Overflow";
LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR;
t->Tok = Ord(kind = eot_tok);
/* serious error now */
return l;
@ -1055,13 +1063,13 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
while (TRUE) {
if (charp + 1024 > (char *)AuxSp) {
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
Yap_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)";
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)";
break;
}
if (ch == 10 && yap_flags[CHARACTER_ESCAPE_FLAG] == ISO_CHARACTER_ESCAPES) {
/* in ISO a new line terminates a string */
Yap_ErrorMessage = "layout character \n inside quotes";
LOCAL_ErrorMessage = "layout character \n inside quotes";
break;
}
if (ch == quote) {
@ -1088,8 +1096,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
++len;
if (charp > (char *)AuxSp - 1024) {
/* Not enough space to read in the string. */
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
Yap_ErrorMessage = "not enough space to read in string or quoted atom";
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_ErrorMessage = "not enough space to read in string or quoted atom";
/* serious error now */
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
t->Tok = Ord(kind = eot_tok);
@ -1108,7 +1116,7 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
mp = AllocScannerMemory(len + 1);
}
if (mp == NULL) {
Yap_ErrorMessage = "not enough heap space to read in string or quoted atom";
LOCAL_ErrorMessage = "not enough heap space to read in string or quoted atom";
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
t->Tok = Ord(kind = eot_tok);
return l;
@ -1131,8 +1139,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
t->TokInfo = Unsigned(Yap_LookupAtom(TokImage));
}
if (!(t->TokInfo)) {
Yap_Error_TYPE = OUT_OF_HEAP_ERROR;
Yap_ErrorMessage = "Code Space Overflow";
LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR;
LOCAL_ErrorMessage = "Code Space Overflow";
if (p)
t->Tok = Ord(kind = eot_tok);
/* serious error now */
@ -1162,6 +1170,15 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
while (chtype(ch) == BS) {
ch = getchr(inp_stream);
}
if (ASP-H < 1024) {
LOCAL_ErrorMessage = "Stack Overflow";
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
LOCAL_Error_Size = 0L;
if (p)
p->Tok = Ord(kind = eot_tok);
/* serious error now */
return l;
}
*tposp = Yap_StreamPosition(inp_stream);
}
goto restart;
@ -1169,7 +1186,6 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
enter_symbol:
if (och == '.' && (chtype(ch) == BS || chtype(ch) == EF
|| chtype(ch) == CC)) {
Yap_eot_before_eof = TRUE;
if (chtype(ch) == CC)
while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF);
t->Tok = Ord(kind = eot_tok);
@ -1183,8 +1199,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
*charp = '\0';
t->TokInfo = Unsigned(Yap_LookupAtom(TokImage));
if (t->TokInfo == (CELL)NIL) {
Yap_Error_TYPE = OUT_OF_HEAP_ERROR;
Yap_ErrorMessage = "Code Space Overflow";
LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR;
LOCAL_ErrorMessage = "Code Space Overflow";
if (p)
t->Tok = Ord(kind = eot_tok);
/* serious error now */
@ -1247,29 +1263,29 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
default:
#ifdef DEBUG
fprintf(Yap_stderr, "\n++++ token: wrong char type %c %d\n", ch, chtype(ch));
fprintf(GLOBAL_stderr, "\n++++ token: wrong char type %c %d\n", ch, chtype(ch));
#endif
t->Tok = Ord(kind = eot_tok);
}
#ifdef DEBUG
if(Yap_Option[2]) fprintf(Yap_stderr,"[Token %d %ld]",Ord(kind),(unsigned long int)t->TokInfo);
if(GLOBAL_Option[2]) fprintf(GLOBAL_stderr,"[Token %d %ld]",Ord(kind),(unsigned long int)t->TokInfo);
#endif
if (Yap_ErrorMessage) {
if (LOCAL_ErrorMessage) {
/* insert an error token to inform the system of what happened */
TokEntry *e = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
if (e == NULL) {
Yap_ErrorMessage = "Trail Overflow";
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
LOCAL_ErrorMessage = "Trail Overflow";
LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR;
p->Tok = Ord(kind = eot_tok);
/* serious error now */
return l;
}
p->TokNext = e;
e->Tok = Error_tok;
e->TokInfo = MkAtomTerm(Yap_LookupAtom(Yap_ErrorMessage));
e->TokInfo = MkAtomTerm(Yap_LookupAtom(LOCAL_ErrorMessage));
e->TokPos = GetCurInpPos(inp_stream);
e->TokNext = NULL;
Yap_ErrorMessage = NULL;
LOCAL_ErrorMessage = NULL;
p = e;
}
} while (kind != eot_tok);
@ -1280,7 +1296,7 @@ void
Yap_clean_tokenizer(TokEntry *tokstart, VarEntry *vartable, VarEntry *anonvartable)
{
CACHE_REGS
struct scanner_extra_alloc *ptr = ScannerExtraBlocks;
struct scanner_extra_alloc *ptr = LOCAL_ScannerExtraBlocks;
while (ptr) {
struct scanner_extra_alloc *next = ptr->next;
free(ptr);

View File

@ -59,7 +59,7 @@ build_new_list(CELL *pt, Term t USES_REGS)
pt += 2;
if (pt > ASP - 4096) {
if (!Yap_gcl((ASP-H)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return(FALSE);
}
t = Deref(ARG1);

View File

@ -477,22 +477,22 @@ p_values( USES_REGS1 )
inline static void
do_signal(yap_signals sig USES_REGS)
{
LOCK(SignalLock);
if (!Yap_InterruptsDisabled)
LOCK(LOCAL_SignalLock);
if (!LOCAL_InterruptsDisabled)
CreepFlag = Unsigned(LCL0);
ActiveSignals |= sig;
UNLOCK(SignalLock);
LOCAL_ActiveSignals |= sig;
UNLOCK(LOCAL_SignalLock);
}
inline static void
undo_signal(yap_signals sig USES_REGS)
{
LOCK(SignalLock);
if (ActiveSignals == sig) {
LOCK(LOCAL_SignalLock);
if (LOCAL_ActiveSignals == sig) {
CreepFlag = CalculateStackGap();
}
ActiveSignals &= ~sig;
UNLOCK(SignalLock);
LOCAL_ActiveSignals &= ~sig;
UNLOCK(LOCAL_SignalLock);
}
@ -518,24 +518,24 @@ p_signal_creep( USES_REGS1 )
at = AtomCreep;
pred = RepPredProp(PredPropByFunc(Yap_MkFunctor(at, 1),0));
CreepCode = pred;
LOCK(SignalLock);
ActiveSignals |= YAP_CREEP_SIGNAL;
UNLOCK(SignalLock);
LOCK(LOCAL_SignalLock);
LOCAL_ActiveSignals |= YAP_CREEP_SIGNAL;
UNLOCK(LOCAL_SignalLock);
return TRUE;
}
static Int
p_disable_creep( USES_REGS1 )
{
LOCK(SignalLock);
if (ActiveSignals & YAP_CREEP_SIGNAL) {
ActiveSignals &= ~YAP_CREEP_SIGNAL;
if (!ActiveSignals)
LOCK(LOCAL_SignalLock);
if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_CREEP_SIGNAL;
if (!LOCAL_ActiveSignals)
CreepFlag = CalculateStackGap();
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return TRUE;
}
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return FALSE;
}
@ -543,14 +543,14 @@ p_disable_creep( USES_REGS1 )
static Int
p_disable_docreep( USES_REGS1 )
{
LOCK(SignalLock);
if (ActiveSignals & YAP_CREEP_SIGNAL) {
ActiveSignals &= ~YAP_CREEP_SIGNAL;
if (!ActiveSignals)
LOCK(LOCAL_SignalLock);
if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_CREEP_SIGNAL;
if (!LOCAL_ActiveSignals)
CreepFlag = CalculateStackGap();
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
} else {
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
}
return TRUE;
}
@ -558,12 +558,12 @@ p_disable_docreep( USES_REGS1 )
static Int
p_stop_creep( USES_REGS1 )
{
LOCK(SignalLock);
ActiveSignals &= ~YAP_CREEP_SIGNAL;
if (!ActiveSignals) {
LOCK(LOCAL_SignalLock);
LOCAL_ActiveSignals &= ~YAP_CREEP_SIGNAL;
if (!LOCAL_ActiveSignals) {
CreepFlag = CalculateStackGap();
}
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return TRUE;
}
@ -797,9 +797,9 @@ p_runtime( USES_REGS1 )
now -= gc_time;
ss_time = Yap_total_stack_shift_time();
now -= ss_time;
interval -= (gc_time-LastGcTime)+(ss_time-LastSSTime);
LastGcTime = gc_time;
LastSSTime = ss_time;
interval -= (gc_time-LOCAL_LastGcTime)+(ss_time-LOCAL_LastSSTime);
LOCAL_LastGcTime = gc_time;
LOCAL_LastSSTime = ss_time;
tnow = MkIntegerTerm(now);
tinterval = MkIntegerTerm(interval);
return( Yap_unify_constant(ARG1, tnow) &&
@ -904,8 +904,8 @@ ch_to_wide(char *base, char *charp USES_REGS)
wchar_t *nb = (wchar_t *)base;
if ((nb+n) + 1024 > (wchar_t *)AuxSp) {
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
Yap_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)";
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)";
return NULL;
}
for (i=n; i > 0; i--) {
@ -1241,7 +1241,7 @@ p_atom_chars( USES_REGS1 )
*ws++ = '\0';
while ((at = Yap_LookupWideAtom((wchar_t *)String)) == NIL) {
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -1249,7 +1249,7 @@ p_atom_chars( USES_REGS1 )
*s++ = '\0';
while ((at = Yap_LookupAtom(String)) == NIL) {
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -1313,7 +1313,7 @@ p_atom_concat( USES_REGS1 )
if (cptr+sz >= top-1024) {
Yap_ReleasePreAllocCodeSpace((ADDR)cpt0);
if (!Yap_growheap(FALSE, sz+1024, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
goto restart;
@ -1340,7 +1340,7 @@ p_atom_concat( USES_REGS1 )
cptr[0] = '\0';
while ((at = Yap_LookupWideAtom(cpt0)) == NIL) {
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -1376,7 +1376,7 @@ p_atom_concat( USES_REGS1 )
if (cptr+sz >= top-1024) {
Yap_ReleasePreAllocCodeSpace((ADDR)cpt0);
if (!Yap_growheap(FALSE, sz+1024, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
goto restart;
@ -1396,7 +1396,7 @@ p_atom_concat( USES_REGS1 )
cptr[0] = '\0';
while ((at = Yap_LookupAtom(cpt0)) == NIL) {
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -1460,7 +1460,7 @@ p_atomic_concat( USES_REGS1 )
if (wcptr+sz >= wtop-1024) {
Yap_ReleasePreAllocCodeSpace((ADDR)cpt0);
if (!Yap_growheap(FALSE, sz+1024, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
goto restart;
@ -1474,7 +1474,7 @@ p_atomic_concat( USES_REGS1 )
if (wcptr+sz >= wtop-1024) {
Yap_ReleasePreAllocCodeSpace((ADDR)cpt0);
if (!Yap_growheap(FALSE, sz+1024, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
goto restart;
@ -1517,7 +1517,7 @@ p_atomic_concat( USES_REGS1 )
if (!Yap_gmp_to_string(thead, tmp, (wtop-wcptr)-1024, 10 )) {
Yap_ReleasePreAllocCodeSpace((ADDR)cpt0);
if (!Yap_growheap(FALSE, sz+1024, NULL)) {
Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, LOCAL_ErrorMessage);
return(FALSE);
}
goto restart;
@ -1541,7 +1541,7 @@ p_atomic_concat( USES_REGS1 )
wcptr[0] = '\0';
while ((at = Yap_LookupWideAtom(wcpt0)) == NIL) {
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -1580,7 +1580,7 @@ p_atomic_concat( USES_REGS1 )
if (cptr+sz >= top-1024) {
Yap_ReleasePreAllocCodeSpace((ADDR)cpt0);
if (!Yap_growheap(FALSE, sz+1024, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return(FALSE);
}
goto restart;
@ -1607,7 +1607,7 @@ p_atomic_concat( USES_REGS1 )
size_t sz = Yap_gmp_to_size(thead, 10);
Yap_ReleasePreAllocCodeSpace((ADDR)cpt0);
if (!Yap_growheap(FALSE, sz+1024, NULL)) {
Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, LOCAL_ErrorMessage);
return(FALSE);
}
goto restart;
@ -1628,7 +1628,7 @@ p_atomic_concat( USES_REGS1 )
cptr[0] = '\0';
while ((at = Yap_LookupAtom(cpt0)) == NIL) {
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -2001,7 +2001,7 @@ p_number_chars( USES_REGS1 )
size_t sz = Yap_gmp_to_size(t1, 10);
Yap_ReleasePreAllocCodeSpace((ADDR)String);
if (!Yap_ExpandPreAllocCodeSpace(sz, NULL, TRUE)) {
Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
goto restart_aux;
@ -2159,7 +2159,7 @@ p_number_atom( USES_REGS1 )
while (!Yap_gmp_to_string(t1, String, ((char *)AuxSp-String)-1024, 10 )) {
size_t sz = Yap_gmp_to_size(t1, 10);
if (!(String = Yap_ExpandPreAllocCodeSpace(sz, NULL, TRUE))) {
Yap_Error(OUT_OF_AUXSPACE_ERROR, t1, Yap_ErrorMessage);
Yap_Error(OUT_OF_AUXSPACE_ERROR, t1, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -2170,7 +2170,7 @@ p_number_atom( USES_REGS1 )
}
while ((at = Yap_LookupAtom(String)) == NIL) {
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -2221,7 +2221,7 @@ p_number_codes( USES_REGS1 )
while (!Yap_gmp_to_string(t1, String, ((char *)AuxSp-String)-1024, 10 )) {
size_t sz = Yap_gmp_to_size(t1, 10);
if (!(String = Yap_ExpandPreAllocCodeSpace(sz, NULL, TRUE))) {
Yap_Error(OUT_OF_AUXSPACE_ERROR, t1, Yap_ErrorMessage);
Yap_Error(OUT_OF_AUXSPACE_ERROR, t1, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -2318,7 +2318,7 @@ p_atom_number( USES_REGS1 )
while (!Yap_gmp_to_string(t2, String, ((char *)AuxSp-String)-1024, 10 )) {
size_t sz = Yap_gmp_to_size(t2, 10);
if (!(String = Yap_ExpandPreAllocCodeSpace(sz, NULL, TRUE))) {
Yap_Error(OUT_OF_AUXSPACE_ERROR, t2, Yap_ErrorMessage);
Yap_Error(OUT_OF_AUXSPACE_ERROR, t2, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -2415,7 +2415,7 @@ p_univ( USES_REGS1 )
/* restore space */
H = Ar;
if (!Yap_gcl((ASP-H)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
twork = TailOfTerm(Deref(ARG2));
@ -2480,7 +2480,7 @@ p_univ( USES_REGS1 )
twork = Yap_ArrayToList(CellPtr(TR), argno - 1);
while (IsIntTerm(twork)) {
if (!Yap_gc(2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return(FALSE);
}
twork = Yap_ArrayToList(CellPtr(TR), argno - 1);
@ -2490,7 +2490,7 @@ p_univ( USES_REGS1 )
{
while (H+arity*2 > ASP-1024) {
if (!Yap_gcl((arity*2)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return(FALSE);
}
tin = Deref(ARG1);
@ -3135,7 +3135,7 @@ p_debug( USES_REGS1 )
int i = IntOfTerm(Deref(ARG1));
if (i >= 'a' && i <= 'z')
Yap_Option[i - 96] = !Yap_Option[i - 96];
GLOBAL_Option[i - 96] = !GLOBAL_Option[i - 96];
return (1);
}
#endif
@ -3329,21 +3329,21 @@ Yap_show_statistics(void)
#endif
frag = (100.0*(heap_space_taken-HeapUsed))/heap_space_taken;
fprintf(Yap_stderr, "Code Space: %ld (%ld bytes needed, %ld bytes used, fragmentation %.3f%%).\n",
fprintf(GLOBAL_stderr, "Code Space: %ld (%ld bytes needed, %ld bytes used, fragmentation %.3f%%).\n",
(unsigned long int)(Unsigned (H0) - Unsigned (Yap_HeapBase)),
(unsigned long int)(Unsigned(HeapTop)-Unsigned(Yap_HeapBase)),
(unsigned long int)(HeapUsed),
frag);
fprintf(Yap_stderr, "Stack Space: %ld (%ld for Global, %ld for local).\n",
fprintf(GLOBAL_stderr, "Stack Space: %ld (%ld for Global, %ld for local).\n",
(unsigned long int)(sizeof(CELL)*(LCL0-H0)),
(unsigned long int)(sizeof(CELL)*(H-H0)),
(unsigned long int)(sizeof(CELL)*(LCL0-ASP)));
fprintf(Yap_stderr, "Trail Space: %ld (%ld used).\n",
(unsigned long int)(sizeof(tr_fr_ptr)*(Unsigned(Yap_TrailTop)-Unsigned(Yap_TrailBase))),
(unsigned long int)(sizeof(tr_fr_ptr)*(Unsigned(TR)-Unsigned(Yap_TrailBase))));
fprintf(Yap_stderr, "Runtime: %lds.\n", (unsigned long int)(runtime ( PASS_REGS1 )));
fprintf(Yap_stderr, "Cputime: %lds.\n", (unsigned long int)(Yap_cputime ()));
fprintf(Yap_stderr, "Walltime: %lds.\n", (unsigned long int)(Yap_walltime ()));
fprintf(GLOBAL_stderr, "Trail Space: %ld (%ld used).\n",
(unsigned long int)(sizeof(tr_fr_ptr)*(Unsigned(LOCAL_TrailTop)-Unsigned(LOCAL_TrailBase))),
(unsigned long int)(sizeof(tr_fr_ptr)*(Unsigned(TR)-Unsigned(LOCAL_TrailBase))));
fprintf(GLOBAL_stderr, "Runtime: %lds.\n", (unsigned long int)(runtime ( PASS_REGS1 )));
fprintf(GLOBAL_stderr, "Cputime: %lds.\n", (unsigned long int)(Yap_cputime ()));
fprintf(GLOBAL_stderr, "Walltime: %lds.\n", (unsigned long int)(Yap_walltime ()));
}
static Int
@ -3366,12 +3366,12 @@ TrailMax(void)
{
CACHE_REGS
Int i;
Int TrWidth = Unsigned(Yap_TrailTop) - Unsigned(Yap_TrailBase);
Int TrWidth = Unsigned(LOCAL_TrailTop) - Unsigned(LOCAL_TrailBase);
CELL *pt;
if (TrailTide != TrWidth) {
pt = (CELL *)TR;
while (pt+2 < (CELL *)Yap_TrailTop) {
while (pt+2 < (CELL *)LOCAL_TrailTop) {
if (pt[0] == 0 &&
pt[1] == 0 &&
pt[2] == 0)
@ -3379,8 +3379,8 @@ TrailMax(void)
else
pt++;
}
if (pt+2 < (CELL *)Yap_TrailTop)
i = Unsigned(pt) - Unsigned(Yap_TrailBase);
if (pt+2 < (CELL *)LOCAL_TrailTop)
i = Unsigned(pt) - Unsigned(LOCAL_TrailBase);
else
i = TrWidth;
} else
@ -3495,12 +3495,12 @@ p_statistics_heap_info( USES_REGS1 )
#if USE_SYSTEM_MALLOC && HAVE_MALLINFO
struct mallinfo mi = mallinfo();
UInt sstack = Yap_HoleSize+(Yap_TrailTop-Yap_GlobalBase);
UInt sstack = Yap_HoleSize+(LOCAL_TrailTop-LOCAL_GlobalBase);
UInt mmax = (mi.arena+mi.hblkhd);
Term tmax = MkIntegerTerm(mmax-sstack);
tusage = MkIntegerTerm(mmax-(mi.fordblks+sstack));
#else
Term tmax = MkIntegerTerm((Yap_GlobalBase - Yap_HeapBase)-Yap_HoleSize);
Term tmax = MkIntegerTerm((LOCAL_GlobalBase - Yap_HeapBase)-Yap_HoleSize);
#endif
return(Yap_unify(tmax, ARG1) && Yap_unify(tusage,ARG2));
@ -3524,8 +3524,8 @@ p_statistics_stacks_info( USES_REGS1 )
static Int
p_statistics_trail_info( USES_REGS1 )
{
Term tmax = MkIntegerTerm(Unsigned(Yap_TrailTop) - Unsigned(Yap_TrailBase));
Term tusage = MkIntegerTerm(Unsigned(TR) - Unsigned(Yap_TrailBase));
Term tmax = MkIntegerTerm(Unsigned(LOCAL_TrailTop) - Unsigned(LOCAL_TrailBase));
Term tusage = MkIntegerTerm(Unsigned(TR) - Unsigned(LOCAL_TrailBase));
return(Yap_unify(tmax, ARG1) && Yap_unify(tusage,ARG2));
@ -3623,8 +3623,8 @@ mk_argc_list( USES_REGS1 )
{
int i =0;
Term t = TermNil;
while (i < Yap_argc) {
char *arg = Yap_argv[i];
while (i < GLOBAL_argc) {
char *arg = GLOBAL_argv[i];
/* check for -L -- */
if (arg[0] == '-' && arg[1] == 'L') {
arg += 2;
@ -3633,15 +3633,15 @@ mk_argc_list( USES_REGS1 )
if (*arg == '-' && arg[1] == '-' && arg[2] == '\0') {
/* we found the separator */
int j;
for (j = Yap_argc-1; j > i+1; --j) {
t = MkPairTerm(MkAtomTerm(Yap_LookupAtom(Yap_argv[j])),t);
for (j = GLOBAL_argc-1; j > i+1; --j) {
t = MkPairTerm(MkAtomTerm(Yap_LookupAtom(GLOBAL_argv[j])),t);
}
return t;
} else if (Yap_argv[i+1] && Yap_argv[i+1][0] == '-' && Yap_argv[i+1][1] == '-' && Yap_argv[i+1][2] == '\0') {
} else if (GLOBAL_argv[i+1] && GLOBAL_argv[i+1][0] == '-' && GLOBAL_argv[i+1][1] == '-' && GLOBAL_argv[i+1][2] == '\0') {
/* we found the separator */
int j;
for (j = Yap_argc-1; j > i+2; --j) {
t = MkPairTerm(MkAtomTerm(Yap_LookupAtom(Yap_argv[j])),t);
for (j = GLOBAL_argc-1; j > i+2; --j) {
t = MkPairTerm(MkAtomTerm(Yap_LookupAtom(GLOBAL_argv[j])),t);
}
return t;
}
@ -3649,8 +3649,8 @@ mk_argc_list( USES_REGS1 )
if (arg[0] == '-' && arg[1] == '-' && arg[2] == '\0') {
/* we found the separator */
int j;
for (j = Yap_argc-1; j > i; --j) {
t = MkPairTerm(MkAtomTerm(Yap_LookupAtom(Yap_argv[j])),t);
for (j = GLOBAL_argc-1; j > i; --j) {
t = MkPairTerm(MkAtomTerm(Yap_LookupAtom(GLOBAL_argv[j])),t);
}
return(t);
}
@ -3670,8 +3670,8 @@ static Int
p_executable( USES_REGS1 )
{
Yap_TrueFileName (Yap_argv[0], Yap_FileNameBuf, FALSE);
return Yap_unify(MkAtomTerm(Yap_LookupAtom(Yap_FileNameBuf)),ARG1);
Yap_TrueFileName (GLOBAL_argv[0], LOCAL_FileNameBuf, FALSE);
return Yap_unify(MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)),ARG1);
}
static Int
@ -3832,49 +3832,49 @@ p_set_yap_flags( USES_REGS1 )
#ifdef TABLING
case TABLING_MODE_FLAG:
if (value == 0) { /* default */
tab_ent_ptr tab_ent = Yap_root_tab_ent;
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
while(tab_ent) {
TabEnt_mode(tab_ent) = TabEnt_flags(tab_ent);
tab_ent = TabEnt_next(tab_ent);
}
yap_flags[TABLING_MODE_FLAG] = 0;
} else if (value == 1) { /* batched */
tab_ent_ptr tab_ent = Yap_root_tab_ent;
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
while(tab_ent) {
SetMode_Batched(TabEnt_mode(tab_ent));
tab_ent = TabEnt_next(tab_ent);
}
SetMode_Batched(yap_flags[TABLING_MODE_FLAG]);
} else if (value == 2) { /* local */
tab_ent_ptr tab_ent = Yap_root_tab_ent;
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
while(tab_ent) {
SetMode_Local(TabEnt_mode(tab_ent));
tab_ent = TabEnt_next(tab_ent);
}
SetMode_Local(yap_flags[TABLING_MODE_FLAG]);
} else if (value == 3) { /* exec_answers */
tab_ent_ptr tab_ent = Yap_root_tab_ent;
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
while(tab_ent) {
SetMode_ExecAnswers(TabEnt_mode(tab_ent));
tab_ent = TabEnt_next(tab_ent);
}
SetMode_ExecAnswers(yap_flags[TABLING_MODE_FLAG]);
} else if (value == 4) { /* load_answers */
tab_ent_ptr tab_ent = Yap_root_tab_ent;
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
while(tab_ent) {
SetMode_LoadAnswers(TabEnt_mode(tab_ent));
tab_ent = TabEnt_next(tab_ent);
}
SetMode_LoadAnswers(yap_flags[TABLING_MODE_FLAG]);
} else if (value == 5) { /* local_trie */
tab_ent_ptr tab_ent = Yap_root_tab_ent;
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
while(tab_ent) {
SetMode_LocalTrie(TabEnt_mode(tab_ent));
tab_ent = TabEnt_next(tab_ent);
}
SetMode_LocalTrie(yap_flags[TABLING_MODE_FLAG]);
} else if (value == 6) { /* global_trie */
tab_ent_ptr tab_ent = Yap_root_tab_ent;
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
while(tab_ent) {
SetMode_GlobalTrie(TabEnt_mode(tab_ent));
tab_ent = TabEnt_next(tab_ent);
@ -3904,41 +3904,41 @@ p_system_mode( USES_REGS1 )
{
Int i = IntegerOfTerm(Deref(ARG1));
if (i == 0)
Yap_PrologMode &= ~SystemMode;
LOCAL_PrologMode &= ~SystemMode;
else
Yap_PrologMode |= SystemMode;
LOCAL_PrologMode |= SystemMode;
return TRUE;
}
static Int
p_lock_system( USES_REGS1 )
{
LOCK(Yap_BGL);
LOCK(GLOBAL_BGL);
return TRUE;
}
static Int
p_unlock_system( USES_REGS1 )
{
UNLOCK(Yap_BGL);
UNLOCK(GLOBAL_BGL);
return TRUE;
}
static Int
p_enterundefp( USES_REGS1 )
{
if (DoingUndefp) {
if (LOCAL_DoingUndefp) {
return FALSE;
}
DoingUndefp = TRUE;
LOCAL_DoingUndefp = TRUE;
return TRUE;
}
static Int
p_exitundefp( USES_REGS1 )
{
if (DoingUndefp) {
DoingUndefp = FALSE;
if (LOCAL_DoingUndefp) {
LOCAL_DoingUndefp = FALSE;
return TRUE;
}
return FALSE;
@ -4110,7 +4110,7 @@ Proc E_Modules[]= {/* init_fc,*/ (Proc) 0 };
#ifndef YAPOR
static
Int p_yapor_threads(void) {
Int p_yapor_threads( USES_REGS1 ) {
return FALSE;
}
#endif

View File

@ -88,7 +88,7 @@ static char SccsId[] = "%W% %G%";
#include <readline/readline.h>
#endif
STATIC_PROTO (void InitPageSize, (void));
STATIC_PROTO (void InitTime, (void));
STATIC_PROTO (void InitWTime, (void));
STATIC_PROTO (Int p_sh, ( USES_REGS1 ));
@ -107,9 +107,6 @@ STATIC_PROTO (int chdir, (char *));
/* #define signal skel_signal */
#endif /* MACYAP */
#if __simplescalar__
char yap_pwd[YAP_FILENAME_MAX];
#endif
STD_PROTO (void exit, (int));
@ -202,27 +199,27 @@ Yap_InitSysPath(void) {
if (dir_done && commons_done)
return;
#endif
strncpy(Yap_FileNameBuf, YAP_SHAREDIR, YAP_FILENAME_MAX);
strncpy(LOCAL_FileNameBuf, YAP_SHAREDIR, YAP_FILENAME_MAX);
#if _MSC_VER || defined(__MINGW32__)
{
DWORD fatts;
int buflen;
char *pt;
if ((fatts = GetFileAttributes(Yap_FileNameBuf)) == 0xFFFFFFFFL ||
if ((fatts = GetFileAttributes(LOCAL_FileNameBuf)) == 0xFFFFFFFFL ||
!(fatts & FILE_ATTRIBUTE_DIRECTORY)) {
/* couldn't find it where it was supposed to be,
let's try using the executable */
if (!GetModuleFileNameEx( GetCurrentProcess(), NULL, Yap_FileNameBuf, YAP_FILENAME_MAX)) {
if (!GetModuleFileNameEx( GetCurrentProcess(), NULL, LOCAL_FileNameBuf, YAP_FILENAME_MAX)) {
Yap_Error(OPERATING_SYSTEM_ERROR, TermNil, "could not find executable name");
/* do nothing */
return;
}
buflen = strlen(Yap_FileNameBuf);
pt = Yap_FileNameBuf+strlen(Yap_FileNameBuf);
buflen = strlen(LOCAL_FileNameBuf);
pt = LOCAL_FileNameBuf+strlen(LOCAL_FileNameBuf);
while (*--pt != '\\') {
/* skip executable */
if (pt == Yap_FileNameBuf) {
if (pt == LOCAL_FileNameBuf) {
Yap_Error(OPERATING_SYSTEM_ERROR, TermNil, "could not find executable name");
/* do nothing */
return;
@ -230,7 +227,7 @@ Yap_InitSysPath(void) {
}
while (*--pt != '\\') {
/* skip parent directory "bin\\" */
if (pt == Yap_FileNameBuf) {
if (pt == LOCAL_FileNameBuf) {
Yap_Error(OPERATING_SYSTEM_ERROR, TermNil, "could not find executable name");
/* do nothing */
}
@ -238,34 +235,34 @@ Yap_InitSysPath(void) {
/* now, this is a possible location for the ROOT_DIR, let's look for a share directory here */
pt[1] = '\0';
/* grosse */
strncat(Yap_FileNameBuf,"lib\\Yap",YAP_FILENAME_MAX);
libdir = Yap_AllocCodeSpace(strlen(Yap_FileNameBuf)+1);
strncpy(libdir, Yap_FileNameBuf, strlen(Yap_FileNameBuf)+1);
strncat(LOCAL_FileNameBuf,"lib\\Yap",YAP_FILENAME_MAX);
libdir = Yap_AllocCodeSpace(strlen(LOCAL_FileNameBuf)+1);
strncpy(libdir, LOCAL_FileNameBuf, strlen(LOCAL_FileNameBuf)+1);
pt[1] = '\0';
strncat(Yap_FileNameBuf,"share",YAP_FILENAME_MAX);
strncat(LOCAL_FileNameBuf,"share",YAP_FILENAME_MAX);
}
}
strncat(Yap_FileNameBuf,"\\", YAP_FILENAME_MAX);
strncat(LOCAL_FileNameBuf,"\\", YAP_FILENAME_MAX);
#else
strncat(Yap_FileNameBuf,"/", YAP_FILENAME_MAX);
strncat(LOCAL_FileNameBuf,"/", YAP_FILENAME_MAX);
#endif
len = strlen(Yap_FileNameBuf);
strncat(Yap_FileNameBuf, "Yap", YAP_FILENAME_MAX);
len = strlen(LOCAL_FileNameBuf);
strncat(LOCAL_FileNameBuf, "Yap", YAP_FILENAME_MAX);
#if _MSC_VER || defined(__MINGW32__)
if (!dir_done)
#endif
{
Yap_PutValue(AtomSystemLibraryDir,
MkAtomTerm(Yap_LookupAtom(Yap_FileNameBuf)));
MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)));
}
#if _MSC_VER || defined(__MINGW32__)
if (!commons_done)
#endif
{
Yap_FileNameBuf[len] = '\0';
strncat(Yap_FileNameBuf, "PrologCommons", YAP_FILENAME_MAX);
LOCAL_FileNameBuf[len] = '\0';
strncat(LOCAL_FileNameBuf, "PrologCommons", YAP_FILENAME_MAX);
Yap_PutValue(AtomPrologCommonsDir,
MkAtomTerm(Yap_LookupAtom(Yap_FileNameBuf)));
MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)));
}
}
@ -287,8 +284,8 @@ p_dir_sp ( USES_REGS1 )
}
static void
InitPageSize(void)
void
Yap_InitPageSize(void)
{
#ifdef _WIN32
SYSTEM_INFO si;
@ -334,8 +331,8 @@ bla bla
#endif
#if THREADS
#define StartOfTimes (*(MY_ThreadHandle.start_of_timesp))
#define last_time (*(MY_ThreadHandle.last_timep))
#define StartOfTimes (*(LOCAL_ThreadHandle.start_of_timesp))
#define last_time (*(LOCAL_ThreadHandle.last_timep))
#else
/* since the point YAP was started */
@ -355,8 +352,8 @@ InitTime (void)
struct rusage rusage;
#if THREADS
MY_ThreadHandle.start_of_timesp = (struct timeval *)malloc(sizeof(struct timeval));
MY_ThreadHandle.last_timep = (struct timeval *)malloc(sizeof(struct timeval));
LOCAL_ThreadHandle.start_of_timesp = (struct timeval *)malloc(sizeof(struct timeval));
LOCAL_ThreadHandle.last_timep = (struct timeval *)malloc(sizeof(struct timeval));
#endif
getrusage(RUSAGE_SELF, &rusage);
last_time.tv_sec = StartOfTimes.tv_sec = rusage.ru_utime.tv_sec;
@ -1197,7 +1194,7 @@ HandleSIGSEGV(int sig, siginfo_t *sip, ucontext_t *uap)
sip->si_code != SI_NOINFO &&
sip->si_code == SEGV_MAPERR &&
(void *)(sip->si_addr) > (void *)(Yap_HeapBase) &&
(void *)(sip->si_addr) < (void *)(Yap_TrailTop+K64)) {
(void *)(sip->si_addr) < (void *)(LOCAL_TrailTop+K64)) {
Yap_growtrail(K64, TRUE);
} else
#endif
@ -1211,6 +1208,7 @@ HandleSIGSEGV(int sig, siginfo_t *sip, ucontext_t *uap)
static void
HandleMatherr(int sig, siginfo_t *sip, ucontext_t *uap)
{
CACHE_REGS
yap_error_number error_no;
/* reset the registers so that we don't have trash in abstract machine */
@ -1308,6 +1306,7 @@ STATIC_PROTO (void my_signal, (int, void (*)(int)));
static RETSIGTYPE
HandleMatherr(int sig)
{
CACHE_REGS
#if HAVE_FETESTEXCEPT
/* This should work in Linux, but it doesn't seem to. */
@ -1315,19 +1314,19 @@ HandleMatherr(int sig)
int raised = fetestexcept(FE_ALL_EXCEPT);
if (raised & FE_OVERFLOW) {
Yap_matherror = EVALUATION_ERROR_FLOAT_OVERFLOW;
LOCAL_matherror = EVALUATION_ERROR_FLOAT_OVERFLOW;
} else if (raised & (FE_INVALID|FE_INEXACT)) {
Yap_matherror = EVALUATION_ERROR_UNDEFINED;
LOCAL_matherror = EVALUATION_ERROR_UNDEFINED;
} else if (raised & FE_DIVBYZERO) {
Yap_matherror = EVALUATION_ERROR_ZERO_DIVISOR;
LOCAL_matherror = EVALUATION_ERROR_ZERO_DIVISOR;
} else if (raised & FE_UNDERFLOW) {
Yap_matherror = EVALUATION_ERROR_FLOAT_UNDERFLOW;
LOCAL_matherror = EVALUATION_ERROR_FLOAT_UNDERFLOW;
} else
#endif
Yap_matherror = EVALUATION_ERROR_UNDEFINED;
LOCAL_matherror = EVALUATION_ERROR_UNDEFINED;
/* something very bad happened on the way to the forum */
set_fpu_exceptions(FALSE);
Yap_Error(Yap_matherror, TermNil, "");
Yap_Error(LOCAL_matherror , TermNil, "");
}
#if HAVE_SIGSEGV && !defined(THREADS)
@ -1358,8 +1357,8 @@ SearchForTrailFault(siginfo_t *siginfo)
crash again
*/
#if OS_HANDLES_TR_OVERFLOW && !USE_SYSTEM_MALLOC
if ((ptr > (void *)Yap_TrailTop-1024 &&
TR < (tr_fr_ptr) Yap_TrailTop+(64*1024))) {
if ((ptr > (void *)LOCAL_TrailTop-1024 &&
TR < (tr_fr_ptr) LOCAL_TrailTop+(64*1024))) {
if (!Yap_growtrail(64*1024, TRUE)) {
Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, "YAP failed to reserve %ld bytes in growtrail", K64);
}
@ -1376,8 +1375,8 @@ SearchForTrailFault(siginfo_t *siginfo)
static RETSIGTYPE
HandleSIGSEGV(int sig, siginfo_t *siginfo, void *context)
{
if (Yap_PrologMode & ExtendStackMode) {
Yap_Error(FATAL_ERROR, TermNil, "OS memory allocation crashed at address %p, bailing out\n",Yap_TrailTop);
if (LOCAL_PrologMode & ExtendStackMode) {
Yap_Error(FATAL_ERROR, TermNil, "OS memory allocation crashed at address %p, bailing out\n",LOCAL_TrailTop);
}
SearchForTrailFault(siginfo);
}
@ -1445,19 +1444,19 @@ HandleMatherr(int sig)
int raised = fetestexcept(FE_ALL_EXCEPT);
if (raised & FE_OVERFLOW) {
Yap_matherror = EVALUATION_ERROR_FLOAT_OVERFLOW;
LOCAL_matherror = EVALUATION_ERROR_FLOAT_OVERFLOW;
} else if (raised & (FE_INVALID|FE_INEXACT)) {
Yap_matherror = EVALUATION_ERROR_UNDEFINED;
LOCAL_matherror = EVALUATION_ERROR_UNDEFINED;
} else if (raised & FE_DIVBYZERO) {
Yap_matherror = EVALUATION_ERROR_ZERO_DIVISOR;
LOCAL_matherror = EVALUATION_ERROR_ZERO_DIVISOR;
} else if (raised & FE_UNDERFLOW) {
Yap_matherror = EVALUATION_ERROR_FLOAT_UNDERFLOW;
LOCAL_matherror = EVALUATION_ERROR_FLOAT_UNDERFLOW;
} else
#endif
Yap_matherror = EVALUATION_ERROR_UNDEFINED;
LOCAL_matherror = EVALUATION_ERROR_UNDEFINED;
/* something very bad happened on the way to the forum */
set_fpu_exceptions(FALSE);
Yap_Error(Yap_matherror, TermNil, "");
Yap_Error(LOCAL_matherror , TermNil, "");
}
static void
@ -1472,11 +1471,11 @@ SearchForTrailFault(void)
/* fprintf(stderr,"Catching a sigsegv at %p with %p\n", TR, TrailTop); */
#endif
#if OS_HANDLES_TR_OVERFLOW && !USE_SYSTEM_MALLOC
if ((TR > (tr_fr_ptr)Yap_TrailTop-1024 &&
TR < (tr_fr_ptr)Yap_TrailTop+(64*1024))|| Yap_DBTrailOverflow()) {
if ((TR > (tr_fr_ptr)LOCAL_TrailTop-1024 &&
TR < (tr_fr_ptr)LOCAL_TrailTop+(64*1024))|| Yap_DBTrailOverflow()) {
long trsize = K64;
while ((CELL)TR > (CELL)Yap_TrailTop+trsize) {
while ((CELL)TR > (CELL)LOCAL_TrailTop+trsize) {
trsize += K64;
}
if (!Yap_growtrail(trsize, TRUE)) {
@ -1493,9 +1492,9 @@ SearchForTrailFault(void)
static RETSIGTYPE
HandleSIGSEGV(int sig)
{
if (Yap_PrologMode & ExtendStackMode) {
if (LOCAL_PrologMode & ExtendStackMode) {
CACHE_REGS
Yap_Error(FATAL_ERROR, TermNil, "OS memory allocation crashed at address %p, bailing out\n",Yap_TrailTop);
Yap_Error(FATAL_ERROR, TermNil, "OS memory allocation crashed at address %p, bailing out\n",LOCAL_TrailTop);
}
SearchForTrailFault();
}
@ -1554,71 +1553,71 @@ void (*handler)(int);
static int
InteractSIGINT(int ch) {
CACHE_REGS
Yap_PrologMode |= AsyncIntMode;
LOCAL_PrologMode |= AsyncIntMode;
switch (ch) {
case 'a':
/* abort computation */
if (Yap_PrologMode & (GCMode|ConsoleGetcMode|GrowStackMode|GrowHeapMode)) {
Yap_PrologMode |= AbortMode;
if (LOCAL_PrologMode & (GCMode|ConsoleGetcMode|GrowStackMode|GrowHeapMode)) {
LOCAL_PrologMode |= AbortMode;
} else {
Yap_Error(PURE_ABORT, TermNil, "abort from console");
/* in case someone mangles the P register */
}
Yap_PrologMode &= ~AsyncIntMode;
siglongjmp(Yap_RestartEnv,1);
LOCAL_PrologMode &= ~AsyncIntMode;
siglongjmp(LOCAL_RestartEnv,1);
return -1;
case 'b':
/* continue */
Yap_signal (YAP_BREAK_SIGNAL);
Yap_PrologMode &= ~AsyncIntMode;
LOCAL_PrologMode &= ~AsyncIntMode;
return 1;
case 'c':
/* continue */
return 1;
case 'd':
Yap_signal (YAP_DEBUG_SIGNAL);
Yap_PrologMode &= ~AsyncIntMode;
LOCAL_PrologMode &= ~AsyncIntMode;
/* enter debug mode */
return 1;
case 'e':
/* exit */
Yap_PrologMode &= ~AsyncIntMode;
LOCAL_PrologMode &= ~AsyncIntMode;
Yap_exit(0);
return -1;
case 'g':
/* exit */
Yap_signal (YAP_STACK_DUMP_SIGNAL);
Yap_PrologMode &= ~AsyncIntMode;
LOCAL_PrologMode &= ~AsyncIntMode;
return -1;
case 't':
/* start tracing */
Yap_signal (YAP_TRACE_SIGNAL);
Yap_PrologMode &= ~AsyncIntMode;
LOCAL_PrologMode &= ~AsyncIntMode;
return 1;
#ifdef LOW_LEVEL_TRACER
case 'T':
toggle_low_level_trace();
Yap_PrologMode &= ~AsyncIntMode;
LOCAL_PrologMode &= ~AsyncIntMode;
return 1;
#endif
case 's':
/* show some statistics */
Yap_signal (YAP_STATISTICS_SIGNAL);
Yap_PrologMode &= ~AsyncIntMode;
LOCAL_PrologMode &= ~AsyncIntMode;
return 1;
case EOF:
Yap_PrologMode &= ~AsyncIntMode;
LOCAL_PrologMode &= ~AsyncIntMode;
return(0);
break;
case 'h':
case '?':
default:
/* show an helpful message */
fprintf(Yap_stderr, "Please press one of:\n");
fprintf(Yap_stderr, " a for abort\n c for continue\n d for debug\n");
fprintf(Yap_stderr, " e for exit\n g for stack dump\n s for statistics\n t for trace\n");
fprintf(Yap_stderr, " b for break\n");
Yap_PrologMode &= ~AsyncIntMode;
fprintf(GLOBAL_stderr, "Please press one of:\n");
fprintf(GLOBAL_stderr, " a for abort\n c for continue\n d for debug\n");
fprintf(GLOBAL_stderr, " e for exit\n g for stack dump\n s for statistics\n t for trace\n");
fprintf(GLOBAL_stderr, " b for break\n");
LOCAL_PrologMode &= ~AsyncIntMode;
return(0);
}
}
@ -1666,16 +1665,16 @@ HandleSIGINT (int sig)
my_signal(SIGINT, HandleSIGINT);
/* do this before we act */
#if HAVE_ISATTY
if (!isatty(0) && !Yap_sockets_io) {
if (!isatty(0)) {
Yap_Error(INTERRUPT_ERROR,MkIntTerm(SIGINT),NULL);
return;
}
#endif
if (Yap_InterruptsDisabled) {
if (LOCAL_InterruptsDisabled) {
return;
}
if (Yap_PrologMode & (CritMode|ConsoleGetcMode)) {
Yap_PrologMode |= InterruptMode;
if (LOCAL_PrologMode & (CritMode|ConsoleGetcMode)) {
LOCAL_PrologMode |= InterruptMode;
}
#ifdef HAVE_SETBUF
/* make sure we are not waiting for the end of line */
@ -1777,7 +1776,7 @@ ReceiveSignal (int s)
break;
#endif /* defined(SIGHUP) */
default:
fprintf(Yap_stderr, "\n[ Unexpected signal ]\n");
fprintf(GLOBAL_stderr, "\n[ Unexpected signal ]\n");
exit (EXIT_FAILURE);
}
}
@ -1786,14 +1785,14 @@ ReceiveSignal (int s)
#if (_MSC_VER || defined(__MINGW32__))
static BOOL WINAPI
MSCHandleSignal(DWORD dwCtrlType) {
if (Yap_InterruptsDisabled) {
if (LOCAL_InterruptsDisabled) {
return FALSE;
}
switch(dwCtrlType) {
case CTRL_C_EVENT:
case CTRL_BREAK_EVENT:
Yap_signal(YAP_ALARM_SIGNAL);
Yap_PrologMode |= InterruptMode;
LOCAL_PrologMode |= InterruptMode;
return(TRUE);
default:
return(FALSE);
@ -1805,7 +1804,7 @@ MSCHandleSignal(DWORD dwCtrlType) {
static void
InitSignals (void)
{
if (Yap_PrologShouldHandleInterrupts) {
if (GLOBAL_PrologShouldHandleInterrupts) {
#if !defined(LIGHT) && !_MSC_VER && !defined(__MINGW32__) && !defined(LIGHT)
my_signal (SIGQUIT, ReceiveSignal);
my_signal (SIGKILL, ReceiveSignal);
@ -1878,7 +1877,7 @@ int Yap_getcwd(const char *buf, int len)
CACHE_REGS
#if __simplescalar__
/* does not implement getcwd */
strncpy(Yap_buf,yap_pwd,len);
strncpy(Yap_buf,GLOBAL_pwd,len);
#elif HAVE_GETCWD
if (getcwd ((char *)buf, len) == NULL) {
#if HAVE_STRERROR
@ -2007,7 +2006,7 @@ TrueFileName (char *source, char *root, char *result, int in_lib)
if ((tmpf = open(ares1, O_RDONLY)) < 0) {
/* not in current directory, let us try the library */
if (Yap_LibDir != NULL) {
strncpy(Yap_FileNameBuf, Yap_LibDir, YAP_FILENAME_MAX);
strncpy(LOCAL_FileNameBuf, Yap_LibDir, YAP_FILENAME_MAX);
#if HAVE_GETENV
} else {
char *yap_env = getenv("YAPLIBDIR");
@ -2105,8 +2104,8 @@ p_true_file_name ( USES_REGS1 )
Yap_Error(TYPE_ERROR_ATOM,t,"argument to true_file_name");
return FALSE;
}
TrueFileName (RepAtom(AtomOfTerm(t))->StrOfAE, NULL, Yap_FileNameBuf, FALSE);
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(Yap_FileNameBuf)));
TrueFileName (RepAtom(AtomOfTerm(t))->StrOfAE, NULL, LOCAL_FileNameBuf, FALSE);
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)));
}
static Int
@ -2130,8 +2129,8 @@ p_true_file_name3 ( USES_REGS1 )
}
root = RepAtom(AtomOfTerm(t2))->StrOfAE;
}
TrueFileName (RepAtom(AtomOfTerm(t))->StrOfAE, root, Yap_FileNameBuf, FALSE);
return Yap_unify(ARG3, MkAtomTerm(Yap_LookupAtom(Yap_FileNameBuf)));
TrueFileName (RepAtom(AtomOfTerm(t))->StrOfAE, root, LOCAL_FileNameBuf, FALSE);
return Yap_unify(ARG3, MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)));
}
/* Executes $SHELL under Prolog */
@ -2239,11 +2238,11 @@ p_system ( USES_REGS1 )
} else if (IsAtomTerm(t1)) {
s = RepAtom(AtomOfTerm(t1))->StrOfAE;
} else {
if (!Yap_GetName (Yap_FileNameBuf, YAP_FILENAME_MAX, t1)) {
if (!Yap_GetName (LOCAL_FileNameBuf, YAP_FILENAME_MAX, t1)) {
Yap_Error(TYPE_ERROR_ATOM,t1,"argument to system/1");
return FALSE;
}
s = Yap_FileNameBuf;
s = LOCAL_FileNameBuf;
}
/* Yap_CloseStreams(TRUE); */
#if _MSC_VER
@ -2397,7 +2396,7 @@ static Int p_putenv( USES_REGS1 )
} else s2 = RepAtom(AtomOfTerm(t2))->StrOfAE;
while (!(p0 = p = Yap_AllocAtomSpace(strlen(s)+strlen(s2)+3))) {
if (!Yap_growheap(FALSE, MinHeapGap, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -2478,14 +2477,14 @@ p_alarm( USES_REGS1 )
i1 = IntegerOfTerm(t);
i2 = IntegerOfTerm(t2);
if (i1 == 0 && i2 == 0) {
LOCK(SignalLock);
if (ActiveSignals & YAP_ALARM_SIGNAL) {
ActiveSignals &= ~YAP_ALARM_SIGNAL;
if (!ActiveSignals) {
LOCK(LOCAL_SignalLock);
if (LOCAL_ActiveSignals & YAP_ALARM_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_ALARM_SIGNAL;
if (!LOCAL_ActiveSignals) {
CreepFlag = CalculateStackGap();
}
}
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
}
#if _MSC_VER || defined(__MINGW32__)
{
@ -2730,10 +2729,9 @@ Yap_InitSysbits (void)
#if __simplescalar__
{
char *pwd = getenv("PWD");
strncpy(yap_pwd,pwd,YAP_FILENAME_MAX);
strncpy(GLOBAL_pwd,pwd,YAP_FILENAME_MAX);
}
#endif
InitPageSize();
InitWTime ();
InitRandom ();
/* let the caller control signals as it sees fit */
@ -2758,146 +2756,146 @@ Yap_ReInitWallTime (void)
static Int
p_first_signal( USES_REGS1 )
{
LOCK(SignalLock);
LOCK(LOCAL_SignalLock);
#ifdef THREADS
pthread_mutex_lock(&(MY_ThreadHandle.tlock));
pthread_mutex_lock(&(LOCAL_ThreadHandle.tlock));
#endif
/* always do wakeups first, because you don't want to keep the
non-backtrackable variable bad */
if (ActiveSignals & YAP_WAKEUP_SIGNAL) {
ActiveSignals &= ~YAP_WAKEUP_SIGNAL;
if (LOCAL_ActiveSignals & YAP_WAKEUP_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_WAKEUP_SIGNAL;
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomSigWakeUp));
}
if (ActiveSignals & YAP_ITI_SIGNAL) {
ActiveSignals &= ~YAP_ITI_SIGNAL;
if (LOCAL_ActiveSignals & YAP_ITI_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_ITI_SIGNAL;
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomSigIti));
}
if (ActiveSignals & YAP_INT_SIGNAL) {
ActiveSignals &= ~YAP_INT_SIGNAL;
if (LOCAL_ActiveSignals & YAP_INT_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_INT_SIGNAL;
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomSigInt));
}
if (ActiveSignals & YAP_USR2_SIGNAL) {
ActiveSignals &= ~YAP_USR2_SIGNAL;
if (LOCAL_ActiveSignals & YAP_USR2_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_USR2_SIGNAL;
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomSigUsr2));
}
if (ActiveSignals & YAP_USR1_SIGNAL) {
ActiveSignals &= ~YAP_USR1_SIGNAL;
if (LOCAL_ActiveSignals & YAP_USR1_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_USR1_SIGNAL;
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomSigUsr1));
}
if (ActiveSignals & YAP_PIPE_SIGNAL) {
ActiveSignals &= ~YAP_PIPE_SIGNAL;
if (LOCAL_ActiveSignals & YAP_PIPE_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_PIPE_SIGNAL;
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomSigPipe));
}
if (ActiveSignals & YAP_HUP_SIGNAL) {
ActiveSignals &= ~YAP_HUP_SIGNAL;
if (LOCAL_ActiveSignals & YAP_HUP_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_HUP_SIGNAL;
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomSigHup));
}
if (ActiveSignals & YAP_ALARM_SIGNAL) {
ActiveSignals &= ~YAP_ALARM_SIGNAL;
UNLOCK(SignalLock);
if (LOCAL_ActiveSignals & YAP_ALARM_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_ALARM_SIGNAL;
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomSigAlarm));
}
if (ActiveSignals & YAP_VTALARM_SIGNAL) {
ActiveSignals &= ~YAP_VTALARM_SIGNAL;
UNLOCK(SignalLock);
if (LOCAL_ActiveSignals & YAP_VTALARM_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_VTALARM_SIGNAL;
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomSigVTAlarm));
}
if (ActiveSignals & YAP_DELAY_CREEP_SIGNAL) {
ActiveSignals &= ~(YAP_CREEP_SIGNAL|YAP_DELAY_CREEP_SIGNAL);
if (LOCAL_ActiveSignals & YAP_DELAY_CREEP_SIGNAL) {
LOCAL_ActiveSignals &= ~(YAP_CREEP_SIGNAL|YAP_DELAY_CREEP_SIGNAL);
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomSigDelayCreep));
}
if (ActiveSignals & YAP_CREEP_SIGNAL) {
ActiveSignals &= ~YAP_CREEP_SIGNAL;
if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_CREEP_SIGNAL;
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomSigCreep));
}
if (ActiveSignals & YAP_TRACE_SIGNAL) {
ActiveSignals &= ~YAP_TRACE_SIGNAL;
if (LOCAL_ActiveSignals & YAP_TRACE_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_TRACE_SIGNAL;
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomSigTrace));
}
if (ActiveSignals & YAP_DEBUG_SIGNAL) {
ActiveSignals &= ~YAP_DEBUG_SIGNAL;
if (LOCAL_ActiveSignals & YAP_DEBUG_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_DEBUG_SIGNAL;
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomSigDebug));
}
if (ActiveSignals & YAP_BREAK_SIGNAL) {
ActiveSignals &= ~YAP_BREAK_SIGNAL;
if (LOCAL_ActiveSignals & YAP_BREAK_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_BREAK_SIGNAL;
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomSigBreak));
}
if (ActiveSignals & YAP_STACK_DUMP_SIGNAL) {
ActiveSignals &= ~YAP_STACK_DUMP_SIGNAL;
if (LOCAL_ActiveSignals & YAP_STACK_DUMP_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_STACK_DUMP_SIGNAL;
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomSigStackDump));
}
if (ActiveSignals & YAP_STATISTICS_SIGNAL) {
ActiveSignals &= ~YAP_STATISTICS_SIGNAL;
if (LOCAL_ActiveSignals & YAP_STATISTICS_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_STATISTICS_SIGNAL;
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomSigStatistics));
}
if (ActiveSignals & YAP_FAIL_SIGNAL) {
ActiveSignals &= ~YAP_FAIL_SIGNAL;
if (LOCAL_ActiveSignals & YAP_FAIL_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_FAIL_SIGNAL;
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return Yap_unify(ARG1, MkAtomTerm(AtomFail));
}
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return FALSE;
}
@ -2905,53 +2903,53 @@ static Int
p_continue_signals( USES_REGS1 )
{
/* hack to force the signal anew */
if (ActiveSignals & YAP_ITI_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_ITI_SIGNAL) {
Yap_signal(YAP_ITI_SIGNAL);
}
if (ActiveSignals & YAP_INT_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_INT_SIGNAL) {
Yap_signal(YAP_INT_SIGNAL);
}
if (ActiveSignals & YAP_USR2_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_USR2_SIGNAL) {
Yap_signal(YAP_USR2_SIGNAL);
}
if (ActiveSignals & YAP_USR1_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_USR1_SIGNAL) {
Yap_signal(YAP_USR1_SIGNAL);
}
if (ActiveSignals & YAP_HUP_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_HUP_SIGNAL) {
Yap_signal(YAP_HUP_SIGNAL);
}
if (ActiveSignals & YAP_ALARM_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_ALARM_SIGNAL) {
Yap_signal(YAP_ALARM_SIGNAL);
}
if (ActiveSignals & YAP_VTALARM_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_VTALARM_SIGNAL) {
Yap_signal(YAP_VTALARM_SIGNAL);
}
if (ActiveSignals & YAP_CREEP_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL) {
Yap_signal(YAP_CREEP_SIGNAL);
}
if (ActiveSignals & YAP_DELAY_CREEP_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_DELAY_CREEP_SIGNAL) {
Yap_signal(YAP_DELAY_CREEP_SIGNAL|YAP_CREEP_SIGNAL);
}
if (ActiveSignals & YAP_TRACE_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_TRACE_SIGNAL) {
Yap_signal(YAP_TRACE_SIGNAL);
}
if (ActiveSignals & YAP_DEBUG_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_DEBUG_SIGNAL) {
Yap_signal(YAP_DEBUG_SIGNAL);
}
if (ActiveSignals & YAP_BREAK_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_BREAK_SIGNAL) {
Yap_signal(YAP_BREAK_SIGNAL);
}
if (ActiveSignals & YAP_STACK_DUMP_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_STACK_DUMP_SIGNAL) {
Yap_signal(YAP_STACK_DUMP_SIGNAL);
}
if (ActiveSignals & YAP_STATISTICS_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_STATISTICS_SIGNAL) {
Yap_signal(YAP_STATISTICS_SIGNAL);
}
if (ActiveSignals & YAP_FAIL_SIGNAL) {
if (LOCAL_ActiveSignals & YAP_FAIL_SIGNAL) {
Yap_signal(YAP_FAIL_SIGNAL);
}
#ifdef THREADS
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
#endif
return TRUE;
}
@ -2992,24 +2990,24 @@ p_win32( USES_REGS1 )
static Int
p_enable_interrupts( USES_REGS1 )
{
LOCK(SignalLock);
Yap_InterruptsDisabled--;
if (ActiveSignals && !Yap_InterruptsDisabled) {
LOCK(LOCAL_SignalLock);
LOCAL_InterruptsDisabled--;
if (LOCAL_ActiveSignals && !LOCAL_InterruptsDisabled) {
CreepFlag = Unsigned(LCL0);
}
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return TRUE;
}
static Int
p_disable_interrupts( USES_REGS1 )
{
LOCK(SignalLock);
Yap_InterruptsDisabled++;
if (ActiveSignals) {
LOCK(LOCAL_SignalLock);
LOCAL_InterruptsDisabled++;
if (LOCAL_ActiveSignals) {
CreepFlag = CalculateStackGap();
}
UNLOCK(SignalLock);
UNLOCK(LOCAL_SignalLock);
return TRUE;
}

View File

@ -1,4 +1,3 @@
/*************************************************************************
* *
* YAP Prolog *
@ -51,29 +50,29 @@ static int
allocate_new_tid(void)
{
int new_worker_id = 0;
LOCK(Yap_ThreadHandlesLock);
LOCK(GLOBAL_ThreadHandlesLock);
while(new_worker_id < MAX_THREADS &&
Yap_WLocal[new_worker_id] &&
(FOREIGN_ThreadHandle(new_worker_id).in_use == TRUE ||
FOREIGN_ThreadHandle(new_worker_id).zombie == TRUE) )
Yap_local[new_worker_id] &&
(REMOTE_ThreadHandle(new_worker_id).in_use == TRUE ||
REMOTE_ThreadHandle(new_worker_id).zombie == TRUE) )
new_worker_id++;
if (new_worker_id >= MAX_THREADS) {
new_worker_id = -1;
} else if (!Yap_WLocal[new_worker_id]) {
} else if (!Yap_local[new_worker_id]) {
DEBUG_TLOCK_ACCESS(new_worker_id, 0);
if (!Yap_InitThread(new_worker_id)) {
return -1;
}
pthread_mutex_lock(&(FOREIGN_ThreadHandle(new_worker_id).tlock));
FOREIGN_ThreadHandle(new_worker_id).in_use = TRUE;
pthread_mutex_lock(&(REMOTE_ThreadHandle(new_worker_id).tlock));
REMOTE_ThreadHandle(new_worker_id).in_use = TRUE;
} else if (new_worker_id < MAX_THREADS) {
DEBUG_TLOCK_ACCESS(new_worker_id, 0);
pthread_mutex_lock(&(FOREIGN_ThreadHandle(new_worker_id).tlock));
FOREIGN_ThreadHandle(new_worker_id).in_use = TRUE;
pthread_mutex_lock(&(REMOTE_ThreadHandle(new_worker_id).tlock));
REMOTE_ThreadHandle(new_worker_id).in_use = TRUE;
} else {
new_worker_id = -1;
}
UNLOCK(Yap_ThreadHandlesLock);
UNLOCK(GLOBAL_ThreadHandlesLock);
return new_worker_id;
}
@ -89,31 +88,31 @@ store_specs(int new_worker_id, UInt ssize, UInt tsize, UInt sysize, Term *tpgoal
tsize = MinTrailSpace;
if (ssize < MinStackSpace)
ssize = MinStackSpace;
FOREIGN_ThreadHandle(new_worker_id).ssize = ssize;
FOREIGN_ThreadHandle(new_worker_id).tsize = tsize;
FOREIGN_ThreadHandle(new_worker_id).sysize = sysize;
FOREIGN(new_worker_id)->c_input_stream = Yap_c_input_stream;
FOREIGN(new_worker_id)->c_output_stream = Yap_c_output_stream;
FOREIGN(new_worker_id)->c_error_stream = Yap_c_error_stream;
REMOTE_ThreadHandle(new_worker_id).ssize = ssize;
REMOTE_ThreadHandle(new_worker_id).tsize = tsize;
REMOTE_ThreadHandle(new_worker_id).sysize = sysize;
REMOTE_c_input_stream(new_worker_id) = LOCAL_c_input_stream;
REMOTE_c_output_stream(new_worker_id) = LOCAL_c_output_stream;
REMOTE_c_error_stream(new_worker_id) = LOCAL_c_error_stream;
pm = (ssize + tsize)*1024;
if (!(FOREIGN_ThreadHandle(new_worker_id).stack_address = malloc(pm))) {
if (!(REMOTE_ThreadHandle(new_worker_id).stack_address = malloc(pm))) {
return FALSE;
}
FOREIGN_ThreadHandle(new_worker_id).tgoal =
REMOTE_ThreadHandle(new_worker_id).tgoal =
Yap_StoreTermInDB(Deref(*tpgoal),7);
FOREIGN_ThreadHandle(new_worker_id).cmod =
REMOTE_ThreadHandle(new_worker_id).cmod =
CurrentModule;
tdetach = Deref(*tpdetach);
if (IsVarTerm(tdetach)){
FOREIGN_ThreadHandle(new_worker_id).tdetach =
REMOTE_ThreadHandle(new_worker_id).tdetach =
MkAtomTerm(AtomFalse);
} else {
FOREIGN_ThreadHandle(new_worker_id).tdetach =
REMOTE_ThreadHandle(new_worker_id).tdetach =
tdetach;
}
tgoal = Yap_StripModule(Deref(*tpexit), &tmod);
FOREIGN_ThreadHandle(new_worker_id).texit_mod = tmod;
FOREIGN_ThreadHandle(new_worker_id).texit =
REMOTE_ThreadHandle(new_worker_id).texit_mod = tmod;
REMOTE_ThreadHandle(new_worker_id).texit =
Yap_StoreTermInDB(tgoal,7);
return TRUE;
}
@ -123,11 +122,11 @@ static void
kill_thread_engine (int wid, int always_die)
{
CACHE_REGS
Prop p0 = AbsPredProp(FOREIGN_ThreadHandle(wid).local_preds);
GlobalEntry *gl = GlobalVariables;
Prop p0 = AbsPredProp(REMOTE_ThreadHandle(wid).local_preds);
GlobalEntry *gl = LOCAL_GlobalVariables;
FOREIGN_ThreadHandle(wid).local_preds = NIL;
GlobalVariables = NULL;
REMOTE_ThreadHandle(wid).local_preds = NIL;
LOCAL_GlobalVariables = NULL;
/* kill all thread local preds */
while(p0) {
PredEntry *ap = RepPredProp(p0);
@ -140,22 +139,22 @@ kill_thread_engine (int wid, int always_die)
gl = gl->NextGE;
}
Yap_KillStacks(wid);
FOREIGN(wid)->active_signals = 0L;
free(FOREIGN(wid)->scratchpad.ptr);
free(FOREIGN_ThreadHandle(wid).default_yaam_regs);
FOREIGN_ThreadHandle(wid).current_yaam_regs = NULL;
free(FOREIGN_ThreadHandle(wid).start_of_timesp);
free(FOREIGN_ThreadHandle(wid).last_timep);
Yap_FreeCodeSpace((ADDR)FOREIGN_ThreadHandle(wid).texit);
LOCK(Yap_ThreadHandlesLock);
if (FOREIGN_ThreadHandle(wid).tdetach == MkAtomTerm(AtomTrue) ||
REMOTE_ActiveSignals(wid) = 0L;
free(REMOTE_ScratchPad(wid).ptr);
free(REMOTE_ThreadHandle(wid).default_yaam_regs);
REMOTE_ThreadHandle(wid).current_yaam_regs = NULL;
free(REMOTE_ThreadHandle(wid).start_of_timesp);
free(REMOTE_ThreadHandle(wid).last_timep);
Yap_FreeCodeSpace((ADDR)REMOTE_ThreadHandle(wid).texit);
LOCK(GLOBAL_ThreadHandlesLock);
if (REMOTE_ThreadHandle(wid).tdetach == MkAtomTerm(AtomTrue) ||
always_die) {
FOREIGN_ThreadHandle(wid).zombie = FALSE;
FOREIGN_ThreadHandle(wid).in_use = FALSE;
REMOTE_ThreadHandle(wid).zombie = FALSE;
REMOTE_ThreadHandle(wid).in_use = FALSE;
DEBUG_TLOCK_ACCESS(1, wid);
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(wid).tlock));
pthread_mutex_unlock(&(REMOTE_ThreadHandle(wid).tlock));
}
UNLOCK(Yap_ThreadHandlesLock);
UNLOCK(GLOBAL_ThreadHandlesLock);
}
static void
@ -163,7 +162,7 @@ thread_die(int wid, int always_die)
{
if (!always_die) {
/* called by thread itself */
Yap_ThreadsTotalTime += Yap_cputime();
GLOBAL_ThreadsTotalTime += Yap_cputime();
}
kill_thread_engine(wid, always_die);
}
@ -177,26 +176,21 @@ setup_engine(int myworker_id, int init_thread)
standard_regs = (REGSTORE *)calloc(1,sizeof(REGSTORE));
regcache = standard_regs;
/* create the YAAM descriptor */
FOREIGN_ThreadHandle(myworker_id).default_yaam_regs = standard_regs;
REMOTE_ThreadHandle(myworker_id).default_yaam_regs = standard_regs;
if (init_thread) {
pthread_setspecific(Yap_yaamregs_key, (void *)FOREIGN_ThreadHandle(myworker_id).default_yaam_regs);
pthread_setspecific(Yap_yaamregs_key, (void *)REMOTE_ThreadHandle(myworker_id).default_yaam_regs);
}
worker_id = myworker_id;
Yap_InitExStacks(FOREIGN_ThreadHandle(myworker_id).tsize, FOREIGN_ThreadHandle(myworker_id).ssize);
CurrentModule = FOREIGN_ThreadHandle(myworker_id).cmod;
LOCAL = REMOTE(worker_id);
Yap_InitExStacks(REMOTE_ThreadHandle(myworker_id).tsize, REMOTE_ThreadHandle(myworker_id).ssize);
CurrentModule = REMOTE_ThreadHandle(myworker_id).cmod;
Yap_InitTime();
Yap_InitYaamRegs();
#ifdef YAPOR
Yap_init_local();
#endif
#ifdef TABLING
new_dependency_frame(REMOTE_top_dep_fr(myworker_id)), FALSE, NULL, NULL, NULL, NULL, NULL);
#endif
Yap_ReleasePreAllocCodeSpace(Yap_PreAllocCodeSpace());
/* I exist */
Yap_NOfThreadsCreated++;
GLOBAL_NOfThreadsCreated++;
DEBUG_TLOCK_ACCESS(2, myworker_id);
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(myworker_id).tlock));
pthread_mutex_unlock(&(REMOTE_ThreadHandle(myworker_id).tlock));
}
static void
@ -216,27 +210,27 @@ thread_run(void *widp)
start_thread(myworker_id);
regcache = ((REGSTORE *)pthread_getspecific(Yap_yaamregs_key));
do {
t = tgs[0] = Yap_PopTermFromDB(MY_ThreadHandle.tgoal);
t = tgs[0] = Yap_PopTermFromDB(LOCAL_ThreadHandle.tgoal);
if (t == 0) {
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
thread_die(worker_id, FALSE);
return NULL;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growstack(MY_ThreadHandle.tgoal->NOfCells*CellSize)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growstack(LOCAL_ThreadHandle.tgoal->NOfCells*CellSize)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
thread_die(worker_id, FALSE);
return NULL;
}
}
}
} while (t == 0);
FOREIGN_ThreadHandle(myworker_id).tgoal = NULL;
tgs[1] = MY_ThreadHandle.tdetach;
REMOTE_ThreadHandle(myworker_id).tgoal = NULL;
tgs[1] = LOCAL_ThreadHandle.tdetach;
tgoal = Yap_MkApplTerm(FunctorThreadRun, 2, tgs);
Yap_RunTopGoal(tgoal);
thread_die(worker_id, FALSE);
@ -287,10 +281,10 @@ p_create_thread( USES_REGS1 )
/* make sure we can proceed */
if (!init_thread_engine(new_worker_id, ssize, tsize, sysize, &ARG1, &ARG5, &ARG6))
return FALSE;
FOREIGN_ThreadHandle(new_worker_id).pthread_handle = 0L;
FOREIGN_ThreadHandle(new_worker_id).id = new_worker_id;
FOREIGN_ThreadHandle(new_worker_id).ref_count = 1;
if ((FOREIGN_ThreadHandle(new_worker_id).ret = pthread_create(&FOREIGN_ThreadHandle(new_worker_id).pthread_handle, NULL, thread_run, (void *)(&(FOREIGN_ThreadHandle(new_worker_id).id)))) == 0) {
REMOTE_ThreadHandle(new_worker_id).pthread_handle = 0L;
REMOTE_ThreadHandle(new_worker_id).id = new_worker_id;
REMOTE_ThreadHandle(new_worker_id).ref_count = 1;
if ((REMOTE_ThreadHandle(new_worker_id).ret = pthread_create(&REMOTE_ThreadHandle(new_worker_id).pthread_handle, NULL, thread_run, (void *)(&(REMOTE_ThreadHandle(new_worker_id).id)))) == 0) {
/* wait until the client is initialised */
return TRUE;
}
@ -348,15 +342,15 @@ p_thread_zombie_self( USES_REGS1 )
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
return Yap_unify(MkIntegerTerm(-1), ARG1);
DEBUG_TLOCK_ACCESS(4, worker_id);
pthread_mutex_lock(&(MY_ThreadHandle.tlock));
if (ActiveSignals &= YAP_ITI_SIGNAL) {
pthread_mutex_lock(&(LOCAL_ThreadHandle.tlock));
if (LOCAL_ActiveSignals &= YAP_ITI_SIGNAL) {
DEBUG_TLOCK_ACCESS(5, worker_id);
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
return FALSE;
}
// fprintf(stderr," -- %d\n", worker_id);
MY_ThreadHandle.in_use = FALSE;
MY_ThreadHandle.zombie = TRUE;
LOCAL_ThreadHandle.in_use = FALSE;
LOCAL_ThreadHandle.zombie = TRUE;
return Yap_unify(MkIntegerTerm(worker_id), ARG1);
}
@ -366,7 +360,7 @@ p_thread_status_lock( USES_REGS1 )
/* make sure the lock is available */
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
return FALSE;
pthread_mutex_lock(&(MY_ThreadHandle.tlock_status));
pthread_mutex_lock(&(LOCAL_ThreadHandle.tlock_status));
return Yap_unify(MkIntegerTerm(worker_id), ARG1);
}
@ -376,7 +370,7 @@ p_thread_status_unlock( USES_REGS1 )
/* make sure the lock is available */
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
return FALSE;
pthread_mutex_unlock(&(MY_ThreadHandle.tlock_status));
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock_status));
return Yap_unify(MkIntegerTerm(worker_id), ARG1);
}
@ -411,20 +405,20 @@ Yap_thread_create_engine(thread_attr *ops)
ops->sysize = 0;
ops->egoal = t;
}
if (pthread_self() != Yap_master_thread) {
if (pthread_self() != GLOBAL_master_thread) {
/* we are worker_id 0 for now, lock master thread so that no one messes with us */
pthread_setspecific(Yap_yaamregs_key, (const void *)&Yap_standard_regs);
pthread_mutex_lock(&(FOREIGN_ThreadHandle(0).tlock));
pthread_mutex_lock(&(REMOTE_ThreadHandle(0).tlock));
}
if (!init_thread_engine(new_id, ops->ssize, ops->tsize, ops->sysize, &t, &t, &(ops->egoal)))
return -1;
FOREIGN_ThreadHandle(new_id).pthread_handle = 0L;
FOREIGN_ThreadHandle(new_id).id = new_id;
FOREIGN_ThreadHandle(new_id).ref_count = 0;
REMOTE_ThreadHandle(new_id).pthread_handle = 0L;
REMOTE_ThreadHandle(new_id).id = new_id;
REMOTE_ThreadHandle(new_id).ref_count = 0;
setup_engine(new_id, FALSE);
if (pthread_self() != Yap_master_thread) {
if (pthread_self() != GLOBAL_master_thread) {
pthread_setspecific(Yap_yaamregs_key, NULL);
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(0).tlock));
pthread_mutex_unlock(&(REMOTE_ThreadHandle(0).tlock));
}
return new_id;
}
@ -435,21 +429,21 @@ Yap_thread_attach_engine(int wid)
CACHE_REGS
/*
already locked
pthread_mutex_lock(&(FOREIGN_ThreadHandle(wid).tlock));
pthread_mutex_lock(&(REMOTE_ThreadHandle(wid).tlock));
*/
if (FOREIGN_ThreadHandle(wid).ref_count ) {
if (REMOTE_ThreadHandle(wid).ref_count ) {
DEBUG_TLOCK_ACCESS(8, wid);
FOREIGN_ThreadHandle(wid).ref_count++;
FOREIGN_ThreadHandle(wid).pthread_handle = pthread_self();
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(wid).tlock));
REMOTE_ThreadHandle(wid).ref_count++;
REMOTE_ThreadHandle(wid).pthread_handle = pthread_self();
pthread_mutex_unlock(&(REMOTE_ThreadHandle(wid).tlock));
return TRUE;
}
FOREIGN_ThreadHandle(wid).pthread_handle = pthread_self();
FOREIGN_ThreadHandle(wid).ref_count++;
pthread_setspecific(Yap_yaamregs_key, (const void *)FOREIGN_ThreadHandle(wid).default_yaam_regs);
worker_id = wid;
REMOTE_ThreadHandle(wid).pthread_handle = pthread_self();
REMOTE_ThreadHandle(wid).ref_count++;
pthread_setspecific(Yap_yaamregs_key, (const void *)REMOTE_ThreadHandle(wid).default_yaam_regs);
worker_id = wid; /* ricroc: for what I understand, this shouldn't be necessary */
DEBUG_TLOCK_ACCESS(9, wid);
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(wid).tlock));
pthread_mutex_unlock(&(REMOTE_ThreadHandle(wid).tlock));
return TRUE;
}
@ -457,12 +451,12 @@ Int
Yap_thread_detach_engine(int wid)
{
DEBUG_TLOCK_ACCESS(10, wid);
pthread_mutex_lock(&(FOREIGN_ThreadHandle(wid).tlock));
FOREIGN_ThreadHandle(wid).pthread_handle = 0;
FOREIGN_ThreadHandle(wid).ref_count--;
pthread_mutex_lock(&(REMOTE_ThreadHandle(wid).tlock));
REMOTE_ThreadHandle(wid).pthread_handle = 0;
REMOTE_ThreadHandle(wid).ref_count--;
pthread_setspecific(Yap_yaamregs_key, NULL);
DEBUG_TLOCK_ACCESS(11, wid);
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(wid).tlock));
pthread_mutex_unlock(&(REMOTE_ThreadHandle(wid).tlock));
return TRUE;
}
@ -470,13 +464,13 @@ Int
Yap_thread_destroy_engine(int wid)
{
DEBUG_TLOCK_ACCESS(10, wid);
pthread_mutex_lock(&(FOREIGN_ThreadHandle(wid).tlock));
if (FOREIGN_ThreadHandle(wid).ref_count == 0) {
pthread_mutex_lock(&(REMOTE_ThreadHandle(wid).tlock));
if (REMOTE_ThreadHandle(wid).ref_count == 0) {
kill_thread_engine(wid, TRUE);
return TRUE;
} else {
DEBUG_TLOCK_ACCESS(12, wid);
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(wid).tlock));
pthread_mutex_unlock(&(REMOTE_ThreadHandle(wid).tlock));
return FALSE;
}
}
@ -487,19 +481,19 @@ p_thread_join( USES_REGS1 )
{
Int tid = IntegerOfTerm(Deref(ARG1));
LOCK(Yap_ThreadHandlesLock);
if (!FOREIGN_ThreadHandle(tid).in_use &&
!FOREIGN_ThreadHandle(tid).zombie) {
UNLOCK(Yap_ThreadHandlesLock);
LOCK(GLOBAL_ThreadHandlesLock);
if (!REMOTE_ThreadHandle(tid).in_use &&
!REMOTE_ThreadHandle(tid).zombie) {
UNLOCK(GLOBAL_ThreadHandlesLock);
return FALSE;
}
if (!FOREIGN_ThreadHandle(tid).tdetach == MkAtomTerm(AtomTrue)) {
UNLOCK(Yap_ThreadHandlesLock);
if (!REMOTE_ThreadHandle(tid).tdetach == MkAtomTerm(AtomTrue)) {
UNLOCK(GLOBAL_ThreadHandlesLock);
return FALSE;
}
UNLOCK(Yap_ThreadHandlesLock);
UNLOCK(GLOBAL_ThreadHandlesLock);
/* make sure this lock is accessible */
if (pthread_join(FOREIGN_ThreadHandle(tid).pthread_handle, NULL) < 0) {
if (pthread_join(REMOTE_ThreadHandle(tid).pthread_handle, NULL) < 0) {
/* ERROR */
return FALSE;
}
@ -512,12 +506,12 @@ p_thread_destroy( USES_REGS1 )
{
Int tid = IntegerOfTerm(Deref(ARG1));
LOCK(Yap_ThreadHandlesLock);
FOREIGN_ThreadHandle(tid).zombie = FALSE;
FOREIGN_ThreadHandle(tid).in_use = FALSE;
LOCK(GLOBAL_ThreadHandlesLock);
REMOTE_ThreadHandle(tid).zombie = FALSE;
REMOTE_ThreadHandle(tid).in_use = FALSE;
DEBUG_TLOCK_ACCESS(32, tid);
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(tid).tlock));
UNLOCK(Yap_ThreadHandlesLock);
pthread_mutex_unlock(&(REMOTE_ThreadHandle(tid).tlock));
UNLOCK(GLOBAL_ThreadHandlesLock);
return TRUE;
}
@ -525,26 +519,26 @@ static Int
p_thread_detach( USES_REGS1 )
{
Int tid = IntegerOfTerm(Deref(ARG1));
pthread_mutex_lock(&(FOREIGN_ThreadHandle(tid).tlock));
pthread_mutex_lock(&(REMOTE_ThreadHandle(tid).tlock));
DEBUG_TLOCK_ACCESS(14, tid);
if (pthread_detach(FOREIGN_ThreadHandle(tid).pthread_handle) < 0) {
if (pthread_detach(REMOTE_ThreadHandle(tid).pthread_handle) < 0) {
/* ERROR */
DEBUG_TLOCK_ACCESS(15, tid);
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(tid).tlock));
pthread_mutex_unlock(&(REMOTE_ThreadHandle(tid).tlock));
return FALSE;
}
FOREIGN_ThreadHandle(tid).tdetach =
REMOTE_ThreadHandle(tid).tdetach =
MkAtomTerm(AtomTrue);
DEBUG_TLOCK_ACCESS(30, tid);
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(tid).tlock));
pthread_mutex_unlock(&(REMOTE_ThreadHandle(tid).tlock));
return TRUE;
}
static Int
p_thread_detached( USES_REGS1 )
{
if (MY_ThreadHandle.tdetach)
return Yap_unify(ARG1,MY_ThreadHandle.tdetach);
if (LOCAL_ThreadHandle.tdetach)
return Yap_unify(ARG1,LOCAL_ThreadHandle.tdetach);
else
return FALSE;
}
@ -553,8 +547,8 @@ static Int
p_thread_detached2( USES_REGS1 )
{
Int tid = IntegerOfTerm(Deref(ARG1));
if (FOREIGN_ThreadHandle(tid).tdetach)
return Yap_unify(ARG2,FOREIGN_ThreadHandle(tid).tdetach);
if (REMOTE_ThreadHandle(tid).tdetach)
return Yap_unify(ARG2,REMOTE_ThreadHandle(tid).tdetach);
else
return FALSE;
}
@ -602,7 +596,7 @@ static Int
p_valid_thread( USES_REGS1 )
{
Int i = IntegerOfTerm(Deref(ARG1));
return FOREIGN_ThreadHandle(i).in_use || FOREIGN_ThreadHandle(i).zombie;
return REMOTE_ThreadHandle(i).in_use || REMOTE_ThreadHandle(i).zombie;
}
/* Mutex Support */
@ -753,16 +747,16 @@ p_thread_stacks( USES_REGS1 )
Int tid = IntegerOfTerm(Deref(ARG1));
Int status= TRUE;
LOCK(Yap_ThreadHandlesLock);
if (!FOREIGN_ThreadHandle(tid).in_use &&
!FOREIGN_ThreadHandle(tid).zombie) {
UNLOCK(Yap_ThreadHandlesLock);
LOCK(GLOBAL_ThreadHandlesLock);
if (!REMOTE_ThreadHandle(tid).in_use &&
!REMOTE_ThreadHandle(tid).zombie) {
UNLOCK(GLOBAL_ThreadHandlesLock);
return FALSE;
}
status &= Yap_unify(ARG2,MkIntegerTerm(FOREIGN_ThreadHandle(tid).ssize));
status &= Yap_unify(ARG3,MkIntegerTerm(FOREIGN_ThreadHandle(tid).tsize));
status &= Yap_unify(ARG4,MkIntegerTerm(FOREIGN_ThreadHandle(tid).sysize));
UNLOCK(Yap_ThreadHandlesLock);
status &= Yap_unify(ARG2,MkIntegerTerm(REMOTE_ThreadHandle(tid).ssize));
status &= Yap_unify(ARG3,MkIntegerTerm(REMOTE_ThreadHandle(tid).tsize));
status &= Yap_unify(ARG4,MkIntegerTerm(REMOTE_ThreadHandle(tid).sysize));
UNLOCK(GLOBAL_ThreadHandlesLock);
return status;
}
@ -771,32 +765,32 @@ p_thread_atexit( USES_REGS1 )
{ /* '$thread_signal'(+P) */
Term t;
if (!MY_ThreadHandle.texit ||
MY_ThreadHandle.texit->Entry == MkAtomTerm(AtomTrue)) {
if (!LOCAL_ThreadHandle.texit ||
LOCAL_ThreadHandle.texit->Entry == MkAtomTerm(AtomTrue)) {
return FALSE;
}
do {
t = Yap_PopTermFromDB(MY_ThreadHandle.texit);
MY_ThreadHandle.texit = NULL;
t = Yap_PopTermFromDB(LOCAL_ThreadHandle.texit);
LOCAL_ThreadHandle.texit = NULL;
if (t == 0) {
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
Yap_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growglobal(NULL)) {
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage);
thread_die(worker_id, FALSE);
return FALSE;
}
} else {
Yap_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growstack(MY_ThreadHandle.tgoal->NOfCells*CellSize)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_growstack(LOCAL_ThreadHandle.tgoal->NOfCells*CellSize)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
thread_die(worker_id, FALSE);
return FALSE;
}
}
}
} while (t == 0);
return Yap_unify(ARG1, t) && Yap_unify(ARG2, MY_ThreadHandle.texit_mod);
return Yap_unify(ARG1, t) && Yap_unify(ARG2, LOCAL_ThreadHandle.texit_mod);
}
@ -806,21 +800,21 @@ p_thread_signal( USES_REGS1 )
{ /* '$thread_signal'(+P) */
Int wid = IntegerOfTerm(Deref(ARG1));
/* make sure the lock is available */
pthread_mutex_lock(&(FOREIGN_ThreadHandle(wid).tlock));
pthread_mutex_lock(&(REMOTE_ThreadHandle(wid).tlock));
DEBUG_TLOCK_ACCESS(16, wid);
if (!FOREIGN_ThreadHandle(wid).in_use ||
!FOREIGN_ThreadHandle(wid).current_yaam_regs) {
if (!REMOTE_ThreadHandle(wid).in_use ||
!REMOTE_ThreadHandle(wid).current_yaam_regs) {
DEBUG_TLOCK_ACCESS(17, wid);
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(wid).tlock));
pthread_mutex_unlock(&(REMOTE_ThreadHandle(wid).tlock));
return TRUE;
}
LOCK(FOREIGN(wid)->signal_lock);
FOREIGN_ThreadHandle(wid).current_yaam_regs->CreepFlag_ =
Unsigned(FOREIGN_ThreadHandle(wid).current_yaam_regs->LCL0_);
FOREIGN(wid)->active_signals |= YAP_ITI_SIGNAL;
UNLOCK(FOREIGN(wid)->signal_lock);
LOCK(REMOTE_SignalLock(wid));
REMOTE_ThreadHandle(wid).current_yaam_regs->CreepFlag_ =
Unsigned(REMOTE_ThreadHandle(wid).current_yaam_regs->LCL0_);
REMOTE_ActiveSignals(wid) |= YAP_ITI_SIGNAL;
UNLOCK(REMOTE_SignalLock(wid));
DEBUG_TLOCK_ACCESS(18, wid);
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(wid).tlock));
pthread_mutex_unlock(&(REMOTE_ThreadHandle(wid).tlock));
return TRUE;
}
@ -834,13 +828,13 @@ static Int
p_nof_threads( USES_REGS1 )
{ /* '$nof_threads'(+P) */
int i = 0, wid;
LOCK(Yap_ThreadHandlesLock);
LOCK(GLOBAL_ThreadHandlesLock);
for (wid = 0; wid < MAX_THREADS; wid++) {
if (!Yap_WLocal[wid]) break;
if (FOREIGN_ThreadHandle(wid).in_use)
if (!Yap_local[wid]) break;
if (REMOTE_ThreadHandle(wid).in_use)
i++;
}
UNLOCK(Yap_ThreadHandlesLock);
UNLOCK(GLOBAL_ThreadHandlesLock);
return Yap_unify(ARG1,MkIntegerTerm(i));
}
@ -859,19 +853,19 @@ p_max_threads( USES_REGS1 )
static Int
p_nof_threads_created( USES_REGS1 )
{ /* '$nof_threads'(+P) */
return Yap_unify(ARG1,MkIntTerm(Yap_NOfThreadsCreated));
return Yap_unify(ARG1,MkIntTerm(GLOBAL_NOfThreadsCreated));
}
static Int
p_thread_runtime( USES_REGS1 )
{ /* '$thread_runtime'(+P) */
return Yap_unify(ARG1,MkIntegerTerm(Yap_ThreadsTotalTime));
return Yap_unify(ARG1,MkIntegerTerm(GLOBAL_ThreadsTotalTime));
}
static Int
p_thread_self_lock( USES_REGS1 )
{ /* '$thread_unlock' */
pthread_mutex_lock(&(MY_ThreadHandle.tlock));
pthread_mutex_lock(&(LOCAL_ThreadHandle.tlock));
return Yap_unify(ARG1,MkIntegerTerm(worker_id));
}
@ -880,7 +874,7 @@ p_thread_unlock( USES_REGS1 )
{ /* '$thread_unlock' */
Int wid = IntegerOfTerm(Deref(ARG1));
DEBUG_TLOCK_ACCESS(19, wid);
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(wid).tlock));
pthread_mutex_unlock(&(REMOTE_ThreadHandle(wid).tlock));
return TRUE;
}

View File

@ -28,12 +28,12 @@
STATIC_PROTO(int TracePutchar, (int, int));
STATIC_PROTO(void send_tracer_message, (char *, char *, Int, char *, CELL *));
static int do_trace_primitives = TRUE;
static int
TracePutchar(int sno, int ch)
{
return(putc(ch, Yap_stderr)); /* use standard error stream, which is supposed to be 2*/
return(putc(ch, GLOBAL_stderr)); /* use standard error stream, which is supposed to be 2*/
}
static void
@ -42,24 +42,24 @@ send_tracer_message(char *start, char *name, Int arity, char *mname, CELL *args)
CACHE_REGS
if (name == NULL) {
#ifdef YAPOR
fprintf(Yap_stderr, "(%d)%s", worker_id, start);
fprintf(GLOBAL_stderr, "(%d)%s", worker_id, start);
#else
fprintf(Yap_stderr, "%s", start);
fprintf(GLOBAL_stderr, "%s", start);
#endif
} else {
int i;
if (arity) {
if (args)
fprintf(Yap_stderr, "%s %s:%s(", start, mname, name);
fprintf(GLOBAL_stderr, "%s %s:%s(", start, mname, name);
else
fprintf(Yap_stderr, "%s %s:%s/%lu", start, mname, name, (unsigned long int)arity);
fprintf(GLOBAL_stderr, "%s %s:%s/%lu", start, mname, name, (unsigned long int)arity);
} else {
fprintf(Yap_stderr, "%s %s:%s", start, mname, name);
fprintf(GLOBAL_stderr, "%s %s:%s", start, mname, name);
}
if (args) {
for (i= 0; i < arity; i++) {
if (i > 0) fprintf(Yap_stderr, ",");
if (i > 0) fprintf(GLOBAL_stderr, ",");
#if DEBUG
#if COROUTINING
Yap_Portray_delays = TRUE;
@ -73,11 +73,11 @@ send_tracer_message(char *start, char *name, Int arity, char *mname, CELL *args)
#endif
}
if (arity) {
fprintf(Yap_stderr, ")");
fprintf(GLOBAL_stderr, ")");
}
}
}
fprintf(Yap_stderr, "\n");
fprintf(GLOBAL_stderr, "\n");
}
#if defined(__GNUC__)
@ -94,7 +94,7 @@ static int thread_trace;
static int
check_trail_consistency(void) {
tr_fr_ptr ptr = TR;
while (ptr > (CELL *)Yap_TrailBase) {
while (ptr > (CELL *)LOCAL_TrailBase) {
ptr = --ptr;
if (!IsVarTerm(TrailTerm(ptr))) {
if (IsApplTerm(TrailTerm(ptr))) {
@ -164,7 +164,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
sc = Yap_heap_regs;
vsc_count++;
#ifdef THREADS
MY_ThreadHandle.thread_inst_count++;
LOCAL_ThreadHandle.thread_inst_count++;
#endif
#ifdef COMMENTED
{ choiceptr myB = B;
@ -186,7 +186,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
} else
return;
{
tr_fr_ptr pt = (tr_fr_ptr)Yap_TrailBase;
tr_fr_ptr pt = (tr_fr_ptr)LOCAL_TrailBase;
if (pt[140].term == 0 && pt[140].value != 0)
jmp_deb(1);
}
@ -235,7 +235,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
if (TR_FZ > TR)
jmp_deb(1);
{
tr_fr_ptr pt = (tr_fr_ptr)Yap_TrailBase;
tr_fr_ptr pt = (tr_fr_ptr)LOCAL_TrailBase;
if (pt[153].term == 0 && pt[153].value == 0 &&
pt[154].term != 0 && pt[154].value != 0 && ( TR > pt+154 ||
TR_FZ > pt+154))
@ -293,16 +293,16 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
printf("\n");
}
#endif
fprintf(Yap_stderr,"%lld ",vsc_count);
fprintf(GLOBAL_stderr,"%lld ",vsc_count);
#if defined(THREADS) || defined(YAPOR)
fprintf(Yap_stderr,"(%d)", worker_id);
fprintf(GLOBAL_stderr,"(%d)", worker_id);
#endif
/* check_trail_consistency(); */
if (pred == NULL) {
UNLOCK(Yap_heap_regs->low_level_trace_lock);
return;
}
if (pred->ModuleOfPred == 0 && !do_trace_primitives) {
if (pred->ModuleOfPred == 0 && !LOCAL_do_trace_primitives) {
UNLOCK(Yap_heap_regs->low_level_trace_lock);
return;
}
@ -396,12 +396,12 @@ static Int p_start_low_level_trace( USES_REGS1 )
static Int p_total_choicepoints( USES_REGS1 )
{
return Yap_unify(MkIntegerTerm(Yap_total_choicepoints),ARG1);
return Yap_unify(MkIntegerTerm(LOCAL_total_choicepoints),ARG1);
}
static Int p_reset_total_choicepoints( USES_REGS1 )
{
Yap_total_choicepoints = 0;
LOCAL_total_choicepoints = 0;
return TRUE;
}
@ -425,7 +425,7 @@ static Int p_start_low_level_trace2( USES_REGS1 )
static Int p_stop_low_level_trace( USES_REGS1 )
{
Yap_do_low_level_trace = FALSE;
do_trace_primitives = TRUE;
LOCAL_do_trace_primitives = TRUE;
return(TRUE);
}

View File

@ -244,7 +244,7 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
CELL new;
bp = to_visit;
if (!attas[ExtFromCell(ptd0)].copy_term_op(ptd0, &bp, ptf PASS_REGS)) {
if (!GLOBAL_attas[ExtFromCell(ptd0)].copy_term_op(ptd0, &bp, ptf PASS_REGS)) {
goto overflow;
}
to_visit = bp;
@ -255,7 +255,7 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
#endif
/* first time we met this term */
RESET_VARIABLE(ptf);
if (TR > (tr_fr_ptr)Yap_TrailTop - 256) {
if (TR > (tr_fr_ptr)LOCAL_TrailTop - 256) {
/* Trail overflow */
if (!Yap_growtrail((TR-TR0)*sizeof(tr_fr_ptr *), TRUE)) {
goto trail_overflow;
@ -355,7 +355,7 @@ trail_overflow:
}
#endif
reset_trail(TR0);
Yap_Error_Size = (ADDR)AuxSp-(ADDR)to_visit0;
LOCAL_Error_Size = (ADDR)AuxSp-(ADDR)to_visit0;
return -3;
}
@ -368,7 +368,7 @@ handle_cp_overflow(int res, tr_fr_ptr TR0, UInt arity, Term t)
switch(res) {
case -1:
if (!Yap_gcl((ASP-H)*sizeof(CELL), arity+1, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return 0L;
}
return Deref(XREGS[arity+1]);
@ -376,19 +376,19 @@ handle_cp_overflow(int res, tr_fr_ptr TR0, UInt arity, Term t)
return Deref(XREGS[arity+1]);
case -3:
{
UInt size = Yap_Error_Size;
Yap_Error_Size = 0L;
UInt size = LOCAL_Error_Size;
LOCAL_Error_Size = 0L;
if (size > 4*1024*1024)
size = 4*1024*1024;
if (!Yap_ExpandPreAllocCodeSpace(size, NULL, TRUE)) {
Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, LOCAL_ErrorMessage);
return 0L;
}
}
return Deref(XREGS[arity+1]);
case -4:
if (!Yap_growtrail((TR-TR0)*sizeof(tr_fr_ptr *), FALSE)) {
Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, Yap_ErrorMessage);
Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, LOCAL_ErrorMessage);
return 0L;
}
return Deref(XREGS[arity+1]);
@ -751,7 +751,7 @@ break_rationals_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, CELL *HLow USE
}
#endif
reset_trail(TR0);
Yap_Error_Size = (ADDR)AuxSp-(ADDR)to_visit0;
LOCAL_Error_Size = (ADDR)AuxSp-(ADDR)to_visit0;
return -3;
}
@ -1066,7 +1066,7 @@ restore_rationals_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, CELL *HLow,
}
#endif
reset_trail(TR0);
Yap_Error_Size = (ADDR)AuxSp-(ADDR)to_visit0;
LOCAL_Error_Size = (ADDR)AuxSp-(ADDR)to_visit0;
return -3;
}
@ -1400,7 +1400,7 @@ export_complex_term(Term tf, CELL *pt0, CELL *pt0_end, char * buf, size_t len0,
CELL new;
bp = to_visit;
if (!attas[ExtFromCell(ptd0)].copy_term_op(ptd0, &bp, ptf PASS_REGS)) {
if (!GLOBAL_attas[ExtFromCell(ptd0)].copy_term_op(ptd0, &bp, ptf PASS_REGS)) {
goto overflow;
}
to_visit = bp;
@ -1411,7 +1411,7 @@ export_complex_term(Term tf, CELL *pt0, CELL *pt0_end, char * buf, size_t len0,
#endif
/* first time we met this term */
*ptf = (CELL)CellDifH(ptf,HLow);
if (TR > (tr_fr_ptr)Yap_TrailTop - 256) {
if (TR > (tr_fr_ptr)LOCAL_TrailTop - 256) {
/* Trail overflow */
if (!Yap_growtrail((TR-TR0)*sizeof(tr_fr_ptr *), TRUE)) {
goto trail_overflow;
@ -1501,7 +1501,7 @@ trail_overflow:
}
#endif
reset_trail(TR0);
Yap_Error_Size = (ADDR)AuxSp-(ADDR)to_visit0;
LOCAL_Error_Size = (ADDR)AuxSp-(ADDR)to_visit0;
return -3;
}
@ -1749,7 +1749,7 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Ter
H += 2;
H[-2] = (CELL)ptd0;
/* next make sure noone will see this as a variable again */
if (TR > (tr_fr_ptr)Yap_TrailTop - 256) {
if (TR > (tr_fr_ptr)LOCAL_TrailTop - 256) {
/* Trail overflow */
if (!Yap_growtrail((TR-TR0)*sizeof(tr_fr_ptr *), TRUE)) {
goto trail_overflow;
@ -1796,15 +1796,15 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Ter
*pt0 = (CELL)to_visit[2];
}
#endif
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
Yap_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *);
LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR;
LOCAL_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *);
clean_tr(TR0 PASS_REGS);
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0);
H = InitialH;
return 0L;
aux_overflow:
Yap_Error_Size = (to_visit-to_visit0)*sizeof(CELL **);
LOCAL_Error_Size = (to_visit-to_visit0)*sizeof(CELL **);
#ifdef RATIONAL_TREES
while (to_visit > to_visit0) {
to_visit -= 3;
@ -1812,7 +1812,7 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Ter
*pt0 = (CELL)to_visit[2];
}
#endif
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
clean_tr(TR0 PASS_REGS);
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0);
H = InitialH;
@ -1829,8 +1829,8 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Ter
clean_tr(TR0 PASS_REGS);
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0);
H = InitialH;
Yap_Error_TYPE = OUT_OF_STACK_ERROR;
Yap_Error_Size = (ASP-H)*sizeof(CELL);
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
LOCAL_Error_Size = (ASP-H)*sizeof(CELL);
return 0L;
}
@ -1838,11 +1838,11 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Ter
static int
expand_vts( USES_REGS1 )
{
UInt expand = Yap_Error_Size;
yap_error_number yap_errno = Yap_Error_TYPE;
UInt expand = LOCAL_Error_Size;
yap_error_number yap_errno = LOCAL_Error_TYPE;
Yap_Error_Size = 0;
Yap_Error_TYPE = YAP_NO_ERROR;
LOCAL_Error_Size = 0;
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (yap_errno == OUT_OF_TRAIL_ERROR) {
/* Trail overflow */
if (!Yap_growtrail(expand, FALSE)) {
@ -1881,7 +1881,7 @@ p_variables_in_term( USES_REGS1 ) /* variables in term t */
*ptr = TermFoundVar;
TrailTerm(TR++) = t;
count++;
if (TR > (tr_fr_ptr)Yap_TrailTop - 256) {
if (TR > (tr_fr_ptr)LOCAL_TrailTop - 256) {
clean_tr(TR-count PASS_REGS);
if (!Yap_growtrail(count*sizeof(tr_fr_ptr *), FALSE)) {
return FALSE;
@ -2032,7 +2032,7 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end,
/* do or pt2 are unbound */
*ptd0 = TermNil;
/* next make sure noone will see this as a variable again */
if (TR > (tr_fr_ptr)Yap_TrailTop - 256) {
if (TR > (tr_fr_ptr)LOCAL_TrailTop - 256) {
/* Trail overflow */
if (!Yap_growtrail((TR-TR0)*sizeof(tr_fr_ptr *), TRUE)) {
goto trail_overflow;
@ -2106,15 +2106,15 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end,
*pt0 = (CELL)to_visit[2];
}
#endif
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
Yap_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *);
LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR;
LOCAL_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *);
clean_tr(TR0 PASS_REGS);
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0);
H = InitialH;
return 0L;
aux_overflow:
Yap_Error_Size = (to_visit-to_visit0)*sizeof(CELL **);
LOCAL_Error_Size = (to_visit-to_visit0)*sizeof(CELL **);
#ifdef RATIONAL_TREES
while (to_visit > to_visit0) {
to_visit -= 3;
@ -2122,7 +2122,7 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end,
*pt0 = (CELL)to_visit[2];
}
#endif
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
clean_tr(TR0 PASS_REGS);
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0);
H = InitialH;
@ -2139,8 +2139,8 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end,
clean_tr(TR0 PASS_REGS);
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0);
H = InitialH;
Yap_Error_TYPE = OUT_OF_STACK_ERROR;
Yap_Error_Size = (ASP-H)*sizeof(CELL);
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
LOCAL_Error_Size = (ASP-H)*sizeof(CELL);
return 0L;
}
@ -2225,7 +2225,7 @@ static Term vars_within_complex_term(register CELL *pt0, register CELL *pt0_end,
CELL *ptr = VarOfTerm(t);
*ptr = TermFoundVar;
TrailTerm(TR++) = t;
if (TR > (tr_fr_ptr)Yap_TrailTop - 256) {
if (TR > (tr_fr_ptr)LOCAL_TrailTop - 256) {
if (!Yap_growtrail((TR-TR0)*sizeof(tr_fr_ptr *), TRUE)) {
goto trail_overflow;
}
@ -2338,15 +2338,15 @@ static Term vars_within_complex_term(register CELL *pt0, register CELL *pt0_end,
*pt0 = (CELL)to_visit[2];
}
#endif
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
Yap_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *);
LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR;
LOCAL_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *);
clean_tr(TR0 PASS_REGS);
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0);
H = InitialH;
return 0L;
aux_overflow:
Yap_Error_Size = (to_visit-to_visit0)*sizeof(CELL **);
LOCAL_Error_Size = (to_visit-to_visit0)*sizeof(CELL **);
#ifdef RATIONAL_TREES
while (to_visit > to_visit0) {
to_visit -= 3;
@ -2354,7 +2354,7 @@ static Term vars_within_complex_term(register CELL *pt0, register CELL *pt0_end,
*pt0 = (CELL)to_visit[2];
}
#endif
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
clean_tr(TR0 PASS_REGS);
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0);
H = InitialH;
@ -2371,8 +2371,8 @@ static Term vars_within_complex_term(register CELL *pt0, register CELL *pt0_end,
clean_tr(TR0 PASS_REGS);
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0);
H = InitialH;
Yap_Error_TYPE = OUT_OF_STACK_ERROR;
Yap_Error_Size = (ASP-H)*sizeof(CELL);
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
LOCAL_Error_Size = (ASP-H)*sizeof(CELL);
return 0L;
}
@ -2422,7 +2422,7 @@ static Term new_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end,
CELL *ptr = VarOfTerm(t);
*ptr = TermFoundVar;
TrailTerm(TR++) = t;
if (TR > (tr_fr_ptr)Yap_TrailTop - 256) {
if (TR > (tr_fr_ptr)LOCAL_TrailTop - 256) {
if (!Yap_growtrail((TR-TR0)*sizeof(tr_fr_ptr *), TRUE)) {
goto trail_overflow;
}
@ -2503,7 +2503,7 @@ static Term new_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end,
H += 2;
H[-2] = (CELL)ptd0;
/* next make sure noone will see this as a variable again */
if (TR > (tr_fr_ptr)Yap_TrailTop - 256) {
if (TR > (tr_fr_ptr)LOCAL_TrailTop - 256) {
/* Trail overflow */
if (!Yap_growtrail((TR-TR0)*sizeof(tr_fr_ptr *), TRUE)) {
goto trail_overflow;
@ -2543,15 +2543,15 @@ static Term new_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end,
*pt0 = (CELL)to_visit[2];
}
#endif
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
Yap_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *);
LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR;
LOCAL_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *);
clean_tr(TR0 PASS_REGS);
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0);
H = InitialH;
return 0L;
aux_overflow:
Yap_Error_Size = (to_visit-to_visit0)*sizeof(CELL **);
LOCAL_Error_Size = (to_visit-to_visit0)*sizeof(CELL **);
#ifdef RATIONAL_TREES
while (to_visit > to_visit0) {
to_visit -= 3;
@ -2559,7 +2559,7 @@ static Term new_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end,
*pt0 = (CELL)to_visit[2];
}
#endif
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
clean_tr(TR0 PASS_REGS);
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0);
H = InitialH;
@ -2576,8 +2576,8 @@ static Term new_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end,
clean_tr(TR0 PASS_REGS);
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0);
H = InitialH;
Yap_Error_TYPE = OUT_OF_STACK_ERROR;
Yap_Error_Size = (ASP-H)*sizeof(CELL);
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
LOCAL_Error_Size = (ASP-H)*sizeof(CELL);
return 0L;
}

View File

@ -85,7 +85,7 @@ STATIC_PROTO(wtype AtomIsSymbols, (unsigned char *));
STATIC_PROTO(void putAtom, (Atom, int, wrf));
STATIC_PROTO(void writeTerm, (Term, int, int, int, struct write_globs *, struct rewind_term *));
#define wrputc(X,WF) ((*WF)(Yap_c_output_stream,X)) /* writes a character */
#define wrputc(X,WF) ((*WF)(LOCAL_c_output_stream,X)) /* writes a character */
static void
wrputn(Int n, wrf writewch) /* writes an integer */
@ -149,7 +149,7 @@ ensure_space(size_t sz) {
}
if (!s) {
s = (char *)TR;
while (s+sz >= Yap_TrailTop) {
while (s+sz >= LOCAL_TrailTop) {
if (!Yap_growtrail(sz/sizeof(CELL), FALSE)) {
s = NULL;
break;
@ -746,26 +746,26 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
lastw = separator;
if (wglb->keep_terms) {
/* garbage collection may be called */
sl = Yap_InitSlot(t);
sl = Yap_InitSlot(t PASS_REGS);
}
writeTerm(HeadOfTerm(t), 999, depth + 1, FALSE, wglb, &nrwt);
restore_from_write(&nrwt, wglb);
if (wglb->keep_terms) {
/* garbage collection may be called */
t = Yap_GetFromSlot(sl);
Yap_RecoverSlots(1);
t = Yap_GetFromSlot(sl PASS_REGS);
Yap_RecoverSlots(1 PASS_REGS);
}
wrputs(",",wglb->writewch);
if (wglb->keep_terms) {
/* garbage collection may be called */
sl = Yap_InitSlot(t);
sl = Yap_InitSlot(t PASS_REGS);
}
writeTerm(TailOfTerm(t), 999, depth + 1, FALSE, wglb, &nrwt);
restore_from_write(&nrwt, wglb);
if (wglb->keep_terms) {
/* garbage collection may be called */
t = Yap_GetFromSlot(sl);
Yap_RecoverSlots(1);
t = Yap_GetFromSlot(sl PASS_REGS);
Yap_RecoverSlots(1 PASS_REGS);
}
wrputc(')', wglb->writewch);
lastw = separator;

View File

@ -126,9 +126,10 @@ typedef struct regstore_t
#endif /* YAPOR_SBA || TABLING */
struct pred_entry *PP_;
#if defined(YAPOR) || defined(THREADS)
unsigned int worker_id_;
struct worker_local *worker_local_;
/* recursive write-locks for PredEntry */
yamop **PREG_ADDR_;
unsigned int worker_id_;
#ifdef YAPOR_SBA
choiceptr BSEG_;
struct or_frame *frame_head_, *frame_tail_;
@ -138,9 +139,6 @@ typedef struct regstore_t
int sba_size_;
#endif /* YAPOR_SBA */
#endif /* YAPOR || THREADS */
#if defined(YAPOR) || defined(TABLING)
struct local_data *LOCAL_;
#endif
#if PUSH_REGS
/* On a X86 machine, the best solution is to keep the
X registers on a global variable, whose address is known between
@ -210,7 +208,6 @@ extern REGSTORE Yap_REGS;
#define MinTrailGap (sizeof(CELL)*1024)
#define MinHeapGap (sizeof(CELL)*4096)
#define MinStackGap (sizeof(CELL)*8*1024)
extern int Yap_stack_overflows;
#define ENV Yap_REGS.ENV_ /* current environment */
@ -642,8 +639,9 @@ EXTERN inline void restore_B(void) {
#endif /* YAPOR_SBA || TABLING */
#define PP (Yap_REGS.PP_)
#if defined(YAPOR) || defined(THREADS)
#define worker_id (Yap_REGS.worker_id_)
#define PREG_ADDR (Yap_REGS.PREG_ADDR_)
#define worker_id (Yap_REGS.worker_id_)
#define LOCAL (Yap_REGS.worker_local_)
#define PREG_ADDR (Yap_REGS.PREG_ADDR_)
#ifdef YAPOR_SBA
#define BSEG Yap_REGS.BSEG_
#define binding_array Yap_REGS.binding_array_
@ -653,10 +651,9 @@ EXTERN inline void restore_B(void) {
#define frame_head Yap_REGS.frame_head_
#define frame_tail Yap_REGS.frame_tail_
#endif /* YAPOR_SBA */
#endif /* YAPOR */
#if defined(YAPOR) || defined(TABLING)
#define LOCAL Yap_REGS.LOCAL_
#endif
#else
#define LOCAL (&Yap_local)
#endif /* YAPOR || THREADS */
#define CurrentModule Yap_REGS.CurrentModule_
#define ARITH_EXCEPTION Yap_REGS.ARITH_EXCEPTION_
#define Yap_isint Yap_REGS.isint_

28
H/ScannerTypes.h Normal file
View File

@ -0,0 +1,28 @@
typedef enum TokenKinds {
Name_tok,
Number_tok,
Var_tok,
String_tok,
WString_tok,
Ponctuation_tok,
Error_tok,
eot_tok
} tkinds;
typedef struct TOKEN {
enum TokenKinds Tok;
Term TokInfo;
int TokPos;
struct TOKEN *TokNext;
} TokEntry;
#define Ord(X) ((enum TokenKinds) (X))
#define NextToken GNextToken( PASS_REGS1 )
typedef struct VARSTRUCT {
Term VarAdr;
CELL hv;
struct VARSTRUCT *VarLeft, *VarRight;
char VarRep[1];
} VarEntry;

View File

@ -136,8 +136,7 @@ typedef enum
exts;
/* array with the ops for your favourite extensions */
extern ext_op attas[attvars_ext + 1];
#endif

718
H/Yap.h
View File

@ -45,11 +45,8 @@
/*
#define RATIONAL_TREES 1
#define DEPTH_LIMIT 1
#define COROUTINING 1
#define ANALYST 1
*/
@ -73,52 +70,47 @@
#define USE_SYSTEM_MALLOC 1
#endif /* THREADS || SUPPORT_CONDOR */
#ifdef ANALYST
#ifdef USE_THREADED_CODE
#if defined(ANALYST) && defined(USE_THREADED_CODE)
#undef USE_THREADED_CODE
#endif
#endif
#endif /* ANALYST && USE_THREADED_CODE */
#ifdef COROUTINING
#ifndef TERM_EXTENSIONS
#if defined(COROUTINING) && !defined(TERM_EXTENSIONS)
#define TERM_EXTENSIONS 1
#endif
#endif
#endif /* COROUTINING && !TERM_EXTENSIONS */
#ifdef _MSC_VER /* Microsoft's Visual C++ Compiler */
/* adjust a config.h from mingw32 to work with vc++ */
/* Microsoft's Visual C++ Compiler */
#ifdef _MSC_VER /* adjust a config.h from mingw32 to work with vc++ */
#ifdef HAVE_GCC
#undef HAVE_GCC
#endif
#undef HAVE_GCC
#endif /* HAVE_GCC */
#ifdef USE_THREADED_CODE
#undef USE_THREADED_CODE
#endif
#endif /* USE_THREADED_CODE */
#define inline __inline
#define YAP_VERSION "YAP-6.3.0"
#define BIN_DIR "c:\\Yap\\bin"
#define LIB_DIR "c:\\Yap\\lib\\Yap"
#define SHARE_DIR "c:\\Yap\\share\\Yap"
#ifdef HOST_ALIAS
#undef HOST_ALIAS
#endif
#ifdef HOST_ALIAS
#undef HOST_ALIAS
#endif /* HOST_ALIAS */
#define HOST_ALIAS "i386-pc-win32"
#ifdef HAVE_IEEEFP_H
#undef HAVE_IEEEFP_H
#endif
#ifdef HAVE_UNISTD_H
#undef HAVE_UNISTD_H
#endif
#ifdef HAVE_SYS_TIME_H
#undef HAVE_SYS_TIME_H
#endif
#endif
#ifdef HAVE_IEEEFP_H
#undef HAVE_IEEEFP_H
#endif /* HAVE_IEEEFP_H */
#ifdef HAVE_UNISTD_H
#undef HAVE_UNISTD_H
#endif /* HAVE_UNISTD_H */
#ifdef HAVE_SYS_TIME_H
#undef HAVE_SYS_TIME_H
#endif /* HAVE_SYS_TIME_H */
#endif /* _MSC_VER */
#ifdef __MINGW32__
#ifndef _WIN32
#define _WIN32 1
#endif
#endif
#endif /* _WIN32 */
#endif /* __MINGW32__ */
#if HAVE_GCC
#define MIN_ARRAY 0
@ -126,35 +118,36 @@
#else
#define MIN_ARRAY 1
#define DUMMY_FILLER_FOR_ABS_TYPE int dummy;
#endif
#endif /* HAVE_GCC */
#ifndef ADTDEFS_C
#define EXTERN static
#else
#define EXTERN
#endif
#endif /* ADTDEFS_C */
/* truth-values */
/* truth-values */
#define TRUE 1
#define FALSE 0
/* null pointer */
/* null pointer */
#define NIL 0
/* Basic types */
/* defines integer types Int and UInt (unsigned) with the same size as a ptr
** and integer types Short and UShort with half the size of a ptr
*/
** and integer types Short and UShort with half the size of a ptr */
#ifdef THREADS
#if USE_PTHREAD_LOCKING
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#endif
#endif
#endif /* !_XOPEN_SOURCE */
#endif /* USE_PTHREAD_LOCKING */
#include <pthread.h>
#endif
#endif /* THREADS */
#if SIZEOF_INT_P==4
@ -173,7 +166,7 @@
#define UInt_FORMAT "%lu"
#else
# error Yap require integer types of the same size as a pointer
#error Yap require integer types of the same size as a pointer
#endif
#if SIZEOF_SHORT_INT==2
@ -249,16 +242,13 @@ typedef unsigned long int YAP_ULONG_LONG;
#define LOW_PROF 1
#endif
#ifdef DEBUG
extern char Yap_Option[20];
#endif
/* #define FORCE_SECOND_QUADRANT 1 */
#if defined(FORCE_SECOND_QUADRANT)
#define IN_SECOND_QUADRANT 1
#define MMAP_ADDR 0x42000000
#endif
#endif /* FORCE_SECOND_QUADRANT */
#if !defined(IN_SECOND_QUADRANT)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(mips) || defined(__APPLE__) || defined(__DragonFly__)
@ -276,10 +266,10 @@ extern char Yap_Option[20];
#define MMAP_ADDR 0x20000000
#else
#define MMAP_ADDR 0x10000000
#endif
#endif /* YAPOR && __alpha */
#elif __svr4__ || defined(__SVR4)
#define MMAP_ADDR 0x02000000
#endif
#endif /* __linux__ || __FreeBSD__ || __NetBSD__ || mips || __APPLE__ || __DragonFly__ */
#endif /* !IN_SECOND_QUADRANT */
/* #define RANDOMIZE_START_ADDRESS 1 */
@ -287,15 +277,15 @@ extern char Yap_Option[20];
#ifdef USE_SYSTEM_MALLOC
#define HEAP_INIT_BASE 0L
#define AtomBase NULL
#else
#else /* !USE_SYSTEM_MALLOC */
#if defined(MMAP_ADDR) && (defined(USE_MMAP) || USE_SHMAT) && !defined(__simplescalar__) && !defined(RANDOMIZE_START_ADDRESS)
#define HEAP_INIT_BASE (MMAP_ADDR)
#define AtomBase ((char *)MMAP_ADDR)
#else
#else /*! (MMAP_ADDR && (USE_MMAP || USE_SHMAT) && !__simplescalar__ && !RANDOMIZE_START_ADDRESS) */
#define HEAP_INIT_BASE ((CELL)Yap_HeapBase)
#define AtomBase (Yap_HeapBase)
#endif
#endif
#endif /* MMAP_ADDR && (USE_MMAP || USE_SHMAT) && !__simplescalar__ && !RANDOMIZE_START_ADDRESS */
#endif /* USE_SYSTEM_MALLOC */
@ -315,7 +305,9 @@ extern char Yap_Option[20];
#define M1 ((CELL)(1024*1024))
#define M2 ((CELL)(2048*1024))
/* basic data types */
/*************************************************************************************************
basic data types
*************************************************************************************************/
typedef UInt CELL;
typedef UShort BITS16;
@ -336,7 +328,9 @@ typedef unsigned char *CODEADDR;
#define CellSize sizeof(CELL)
#define SmallSize sizeof(SMALLUNSGN)
/* type casting macros */
/*************************************************************************************************
type casting macros
*************************************************************************************************/
#define Addr(V) ((ADDR) (V))
#define Unsigned(V) ((CELL) (V))
@ -351,7 +345,9 @@ typedef unsigned char *CODEADDR;
#define DisplPtr(V) ((DISPREG *)(V))
#define TermPtr(V) ((Term *) (V))
/* Abstract Type Definitions for YAPProlog */
/*************************************************************************************************
Abstract Type Definitions for YAPProlog
*************************************************************************************************/
typedef CELL Term;
@ -390,7 +386,9 @@ typedef pthread_rwlock_t rwlock_t;
#include <locks_pthread.h>
#endif
/********************** use an auxiliary function for ranges ************/
/*************************************************************************************************
use an auxiliary function for ranges
*************************************************************************************************/
#ifdef __GNUC__
#define IN_BETWEEN(MIN,X,MAX) (Unsigned((Int)(X)-(Int)(MIN)) <= \
@ -404,19 +402,25 @@ typedef pthread_rwlock_t rwlock_t;
#define OUTSIDE(MIN,X,MAX) ((void *)(X) < (void *)(MIN) || (void *)(X) > (void *)(MAX))
#endif
/* ************************* Atoms *************************************/
/*************************************************************************************************
Atoms
*************************************************************************************************/
#include "Atoms.h"
/* ************************* Coroutining **********************************/
/*************************************************************************************************
Coroutining
*************************************************************************************************/
#ifdef COROUTINING
/* Support for co-routining */
#include "corout.h"
#endif
/********* abstract machine registers **********************************/
/*************************************************************************************************
abstract machine registers
*************************************************************************************************/
#include "amidefs.h"
@ -431,7 +435,9 @@ typedef pthread_rwlock_t rwlock_t;
#endif
#endif
/************ variables concerned with Error Handling *************/
/*************************************************************************************************
variables concerned with Error Handling
*************************************************************************************************/
#include <setjmp.h>
@ -444,7 +450,6 @@ typedef pthread_rwlock_t rwlock_t;
/* Support for arrays */
#include "arrays.h"
/************ variables concerned with Error Handling *************/
/* Types of Errors */
typedef enum
@ -622,7 +627,9 @@ typedef enum
#define NUMBER_OF_YAP_FLAGS LAST_FLAG
/************************ prototypes **********************************/
/*************************************************************************************************
prototypes
*************************************************************************************************/
#include "Yapproto.h"
@ -740,7 +747,9 @@ typedef enum
#define TermSize sizeof(Term)
/************* variables related to memory allocation *******************/
/*************************************************************************************************
variables related to memory allocation
*************************************************************************************************/
/* must be before TermExt.h */
extern ADDR Yap_HeapBase;
@ -750,71 +759,17 @@ extern ADDR Yap_HeapBase;
#define MAX_ERROR_MSG_SIZE YAP_FILENAME_MAX
#ifdef THREADS
typedef struct thread_globs
{
ADDR local_base;
ADDR global_base;
ADDR trail_base;
ADDR trail_top;
char *error_message;
Term error_term;
Term error_type;
UInt error_size;
char error_say[MAX_ERROR_MSG_SIZE];
jmp_buf io_botch;
sigjmp_buf restart_env;
struct TOKEN *tokptr;
struct TOKEN *toktide;
struct VARSTRUCT *var_table;
struct VARSTRUCT *anon_var_table;
int eot_before_eof;
char file_name_buf[YAP_FILENAME_MAX];
char file_name_buf2[YAP_FILENAME_MAX];
} tglobs;
extern struct thread_globs Yap_thread_gl[MAX_THREADS];
#define Yap_LocalBase Yap_thread_gl[worker_id].local_base
#define Yap_GlobalBase Yap_thread_gl[worker_id].global_base
#define Yap_TrailBase Yap_thread_gl[worker_id].trail_base
#define Yap_TrailTop Yap_thread_gl[worker_id].trail_top
#define Yap_ErrorMessage Yap_thread_gl[worker_id].error_message
#define Yap_Error_Term Yap_thread_gl[worker_id].error_term
#define Yap_Error_TYPE Yap_thread_gl[worker_id].error_type
#define Yap_Error_Size Yap_thread_gl[worker_id].error_size
#define Yap_ErrorSay Yap_thread_gl[worker_id].error_say
#define Yap_RestartEnv Yap_thread_gl[worker_id].restart_env
/* This is the guy who actually started the system, and who has the correct registers */
extern pthread_t Yap_master_thread;
#else
extern ADDR Yap_HeapBase,
Yap_LocalBase, Yap_GlobalBase, Yap_TrailBase, Yap_TrailTop;
extern sigjmp_buf Yap_RestartEnv; /* used to restart after an abort */
extern char *Yap_ErrorMessage; /* used to pass error messages */
extern Term Yap_Error_Term; /* used to pass error terms */
extern yap_error_number Yap_Error_TYPE; /* used to pass the error */
extern UInt Yap_Error_Size; /* used to pass the error */
/******************* storing error messages ****************************/
extern char Yap_ErrorSay[MAX_ERROR_MSG_SIZE];
#endif
#ifdef DEBUG
/************** Debugging Support ***************************/
extern int Yap_output_msg;
#endif
/*************************************************************************************************
???
*************************************************************************************************/
#define MkVarTerm() MkVarTerm__( PASS_REGS1 )
#define MkPairTerm(A,B) MkPairTerm__( A, B PASS_REGS )
/* applies to unbound variables */
/*************************************************************************************************
applies to unbound variables
*************************************************************************************************/
inline EXTERN Term *VarOfTerm (Term t);
@ -1058,18 +1013,317 @@ IntegerOfTerm (Term t)
/*************************************************************************************************
variables concerned with atoms table
*************************************************************************************************/
/*************** unification routines ***********************************/
#define MaxHash 3333
#define MaxWideHash (MaxHash/10+1)
#define FAIL_RESTORE 0
#define DO_EVERYTHING 1
#define DO_ONLY_CODE 2
/*************************************************************************************************
common instructions codes
*************************************************************************************************/
#define MAX_PROMPT 256
#if USE_THREADED_CODE
/*************************************************************************************************
reverse lookup of instructions
*************************************************************************************************/
typedef struct opcode_tab_entry
{
OPCODE opc;
op_numbers opnum;
} opentry;
#endif
/*************************************************************************************************
Prolog may be in several modes
*************************************************************************************************/
typedef enum
{
BootMode = 0x1, /* if booting or restoring */
UserMode = 0x2, /* Normal mode */
CritMode = 0x4, /* If we are meddling with the heap */
AbortMode = 0x8, /* expecting to abort */
InterruptMode = 0x10, /* under an interrupt */
InErrorMode = 0x20, /* under an interrupt */
ConsoleGetcMode = 0x40, /* blocked reading from console */
ExtendStackMode = 0x80, /* trying to extend stack */
GrowHeapMode = 0x100, /* extending Heap */
GrowStackMode = 0x200, /* extending Stack */
GCMode = 0x400, /* doing Garbage Collecting */
ErrorHandlingMode = 0x800, /* doing error handling */
CCallMode = 0x1000, /* In c Call */
UnifyMode = 0x2000, /* In Unify Code */
UserCCallMode = 0x4000, /* In User C-call Code */
MallocMode = 0x8000, /* Doing malloc, realloc, free */
SystemMode = 0x10000, /* in system mode */
AsyncIntMode = 0x20000, /* YAP has just been interrupted from the outside */
InReadlineMode = 0x40000 /* YAP has just been interrupted from the outside */
} prolog_exec_mode;
/*************************************************************************************************
number of modules
*************************************************************************************************/
#define DefaultMaxModules 256
/*************************************************************************************************
Critical sections
*************************************************************************************************/
#ifdef YAPOR
#define YAPEnterCriticalSection() \
{ \
if (worker_id != GLOBAL_locks_who_locked_heap) { \
LOCK(GLOBAL_locks_heap_access); \
GLOBAL_locks_who_locked_heap = worker_id; \
} \
LOCAL_PrologMode |= CritMode; \
LOCAL_CritLocks++; \
}
#define YAPLeaveCriticalSection() \
{ \
LOCAL_CritLocks--; \
if (!LOCAL_CritLocks) { \
LOCAL_PrologMode &= ~CritMode; \
if (LOCAL_PrologMode & InterruptMode) { \
LOCAL_PrologMode &= ~InterruptMode; \
Yap_ProcessSIGINT(); \
} \
if (LOCAL_PrologMode & AbortMode) { \
LOCAL_PrologMode &= ~AbortMode; \
Yap_Error(PURE_ABORT, 0, ""); \
} \
GLOBAL_locks_who_locked_heap = MAX_WORKERS; \
UNLOCK(GLOBAL_locks_heap_access); \
} \
}
#elif defined(THREADS)
#define YAPEnterCriticalSection() \
{ \
/* LOCK(BGL); */ \
LOCAL_PrologMode |= CritMode; \
}
#define YAPLeaveCriticalSection() \
{ \
LOCAL_PrologMode &= ~CritMode; \
if (LOCAL_PrologMode & InterruptMode) { \
LOCAL_PrologMode &= ~InterruptMode; \
Yap_ProcessSIGINT(); \
} \
if (LOCAL_PrologMode & AbortMode) { \
LOCAL_PrologMode &= ~AbortMode; \
Yap_Error(PURE_ABORT, 0, ""); \
} \
/* UNLOCK(BGL); */ \
}
#else
#define YAPEnterCriticalSection() \
{ \
LOCAL_PrologMode |= CritMode; \
LOCAL_CritLocks++; \
}
#define YAPLeaveCriticalSection() \
{ \
LOCAL_CritLocks--; \
if (!LOCAL_CritLocks) { \
LOCAL_PrologMode &= ~CritMode; \
if (LOCAL_PrologMode & InterruptMode) { \
LOCAL_PrologMode &= ~InterruptMode; \
Yap_ProcessSIGINT(); \
} \
if (LOCAL_PrologMode & AbortMode) { \
LOCAL_PrologMode &= ~AbortMode; \
Yap_Error(PURE_ABORT, 0, ""); \
} \
} \
}
#endif /* YAPOR */
/* when we are calling the InitStaff procedures */
#define AT_BOOT 0
#define AT_RESTORE 1
/*************************************************************************************************
mutable variables
*************************************************************************************************/
/* I assume that the size of this structure is a multiple of the size
of CELL!!! */
typedef struct TIMED_MAVAR
{
CELL value;
CELL clock;
} timed_var;
/*************************************************************************************************
execution mode
*************************************************************************************************/
typedef enum
{
INTERPRETED, /* interpreted */
MIXED_MODE_USER, /* mixed mode only for user predicates */
MIXED_MODE_ALL, /* mixed mode for all predicates */
COMPILE_USER, /* compile all user predicates*/
COMPILE_ALL /* compile all predicates */
} yap_exec_mode;
/*************************************************************************************************
slots
*************************************************************************************************/
static inline void
Yap_StartSlots( USES_REGS1 ) {
*--ASP = MkIntegerTerm(CurSlot);
*--ASP = MkIntTerm(0);
CurSlot = LCL0-ASP;
}
static inline void
Yap_CloseSlots( USES_REGS1 ) {
Int old_slots;
old_slots = IntOfTerm(ASP[0]);
ASP += (old_slots+1);
CurSlot = IntOfTerm(*ASP);
ASP++;
}
static inline Int
Yap_CurrentSlot( USES_REGS1 ) {
return IntOfTerm(ASP[0]);
}
/************************/
#ifdef THREADS
typedef struct thandle {
int in_use;
int zombie;
UInt ssize;
UInt tsize;
UInt sysize;
void *stack_address;
Term tdetach;
Term cmod, texit_mod;
struct DB_TERM *tgoal, *texit;
int id;
int ret;
REGSTORE *default_yaam_regs;
REGSTORE *current_yaam_regs;
struct pred_entry *local_preds;
pthread_t pthread_handle;
int ref_count;
#ifdef LOW_LEVEL_TRACER
long long int thread_inst_count;
int been_here1;
int been_here2;
#endif
#ifdef DEBUG
int been_here;
#endif
pthread_mutex_t tlock;
pthread_mutex_t tlock_status;
#if HAVE_GETRUSAGE||defined(_WIN32)
struct timeval *start_of_timesp;
struct timeval *last_timep;
#endif
} yap_thandle;
#endif /* THREADS */
#define GC_MAVARS_HASH_SIZE 512
typedef struct gc_ma_hash_entry_struct {
UInt timestmp;
#ifdef TABLING
tr_fr_ptr loc;
struct gc_ma_hash_entry_struct *more;
#endif
CELL* addr;
struct gc_ma_hash_entry_struct *next;
} gc_ma_hash_entry;
typedef int (*Agc_hook)(Atom);
typedef struct scratch_block_struct {
char *ptr;
UInt sz, msz;
} scratch_block;
/* scanner types */
#include "ScannerTypes.h"
/*************************************************************************************************
OPTYAP includes
*************************************************************************************************/
#if defined(YAPOR) || defined(TABLING)
#include "opt.structs.h"
#include "opt.proto.h"
#include "opt.macros.h"
#endif /* YAPOR || TABLING */
/*************************************************************************************************
GLOBAL and LOCAL variables
*************************************************************************************************/
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
extern struct global_data *Yap_global;
extern long Yap_worker_area_size;
#else
extern struct global_data Yap_Global;
#define Yap_global (&Yap_Global)
#endif
#if defined(THREADS)
extern struct worker_local *Yap_local[MAX_THREADS];
#define REMOTE(wid) (Yap_local[wid])
#elif defined(YAPOR)
extern struct worker_local *Yap_local;
#define REMOTE(wid) (Yap_local + wid)
#else /* !THREADS && !YAPOR */
extern struct worker_local Yap_local;
#define REMOTE(wid) (&Yap_local)
#endif
#define YP_FILE FILE
#include "hglobals.h"
#include "dglobals.h"
#include "hlocals.h"
#include "dlocals.h"
/*************************************************************************************************
unification routines
*************************************************************************************************/
#ifdef YAPOR_SBA
#include "or.sba_amiops.h"
#include "or.sba_unify.h"
#else
#include "amiops.h"
#endif
#endif /* YAPOR_SBA */
/*************** High level macros to access arguments ******************/
/*************************************************************************************************
High level macros to access arguments
*************************************************************************************************/
inline EXTERN Term ArgOfTerm (int i, Term t);
inline EXTERN Term
@ -1129,214 +1383,4 @@ TailOfTermCell (Term t)
return (Term) ((CELL) (RepPair (t) + 1));
}
/*************** variables concerned with atoms table *******************/
#define MaxHash 3333
#define MaxWideHash (MaxHash/10+1)
#define FAIL_RESTORE 0
#define DO_EVERYTHING 1
#define DO_ONLY_CODE 2
#ifdef EMACS
/******************** using Emacs mode ********************************/
extern int emacs_mode;
#endif
/********* common instructions codes*************************/
#define MAX_PROMPT 256
#if USE_THREADED_CODE
/************ reverse lookup of instructions *****************/
typedef struct opcode_tab_entry
{
OPCODE opc;
op_numbers opnum;
} opentry;
#endif
/********* Prolog may be in several modes *******************************/
typedef enum
{
BootMode = 0x1, /* if booting or restoring */
UserMode = 0x2, /* Normal mode */
CritMode = 0x4, /* If we are meddling with the heap */
AbortMode = 0x8, /* expecting to abort */
InterruptMode = 0x10, /* under an interrupt */
InErrorMode = 0x20, /* under an interrupt */
ConsoleGetcMode = 0x40, /* blocked reading from console */
ExtendStackMode = 0x80, /* trying to extend stack */
GrowHeapMode = 0x100, /* extending Heap */
GrowStackMode = 0x200, /* extending Stack */
GCMode = 0x400, /* doing Garbage Collecting */
ErrorHandlingMode = 0x800, /* doing error handling */
CCallMode = 0x1000, /* In c Call */
UnifyMode = 0x2000, /* In Unify Code */
UserCCallMode = 0x4000, /* In User C-call Code */
MallocMode = 0x8000, /* Doing malloc, realloc, free */
SystemMode = 0x10000, /* in system mode */
AsyncIntMode = 0x20000, /* YAP has just been interrupted from the outside */
InReadlineMode = 0x40000 /* YAP has just been interrupted from the outside */
} prolog_exec_mode;
extern Int Yap_PrologMode;
extern int Yap_CritLocks;
/************** Access to yap initial arguments ***************************/
extern char **Yap_argv;
extern int Yap_argc;
/******** whether Yap is responsible for signal handling ******************/
extern int Yap_PrologShouldHandleInterrupts;
/******************* number of modules ****************************/
#define DefaultMaxModules 256
#ifdef YAPOR
#define YAPEnterCriticalSection() \
{ \
if (worker_id != Yap_locks_who_locked_heap) { \
LOCK(Yap_locks_heap_access); \
Yap_locks_who_locked_heap = worker_id; \
} \
Yap_PrologMode |= CritMode; \
Yap_CritLocks++; \
}
#define YAPLeaveCriticalSection() \
{ \
Yap_CritLocks--; \
if (!Yap_CritLocks) { \
Yap_PrologMode &= ~CritMode; \
if (Yap_PrologMode & InterruptMode) { \
Yap_PrologMode &= ~InterruptMode; \
Yap_ProcessSIGINT(); \
} \
if (Yap_PrologMode & AbortMode) { \
Yap_PrologMode &= ~AbortMode; \
Yap_Error(PURE_ABORT, 0, ""); \
} \
Yap_locks_who_locked_heap = MAX_WORKERS; \
UNLOCK(Yap_locks_heap_access); \
} \
}
#elif defined(THREADS)
#define YAPEnterCriticalSection() \
{ \
/* LOCK(BGL); */ \
Yap_PrologMode |= CritMode; \
}
#define YAPLeaveCriticalSection() \
{ \
Yap_PrologMode &= ~CritMode; \
if (Yap_PrologMode & InterruptMode) { \
Yap_PrologMode &= ~InterruptMode; \
Yap_ProcessSIGINT(); \
} \
if (Yap_PrologMode & AbortMode) { \
Yap_PrologMode &= ~AbortMode; \
Yap_Error(PURE_ABORT, 0, ""); \
} \
/* UNLOCK(BGL); */ \
}
#else
#define YAPEnterCriticalSection() \
{ \
Yap_PrologMode |= CritMode; \
Yap_CritLocks++; \
}
#define YAPLeaveCriticalSection() \
{ \
Yap_CritLocks--; \
if (!Yap_CritLocks) { \
Yap_PrologMode &= ~CritMode; \
if (Yap_PrologMode & InterruptMode) { \
Yap_PrologMode &= ~InterruptMode; \
Yap_ProcessSIGINT(); \
} \
if (Yap_PrologMode & AbortMode) { \
Yap_PrologMode &= ~AbortMode; \
Yap_Error(PURE_ABORT, 0, ""); \
} \
} \
}
#endif /* YAPOR */
/* when we are calling the InitStaff procedures */
#define AT_BOOT 0
#define AT_RESTORE 1
/********* mutable variables ******************/
/* I assume that the size of this structure is a multiple of the size
of CELL!!! */
typedef struct TIMED_MAVAR
{
CELL value;
CELL clock;
} timed_var;
/********* while debugging you may need some info ***********************/
#ifdef EMACS
extern char emacs_tmp[], emacs_tmp2[];
#endif
#if defined(YAPOR) || defined(TABLING)
#include "opt.structs.h"
#include "opt.proto.h"
#include "opt.macros.h"
#endif /* YAPOR || TABLING */
#ifdef YAPOR_SBA
#include "or.sba_unify.h"
#endif
/********* execution mode ***********************/
typedef enum
{
INTERPRETED, /* interpreted */
MIXED_MODE_USER, /* mixed mode only for user predicates */
MIXED_MODE_ALL, /* mixed mode for all predicates */
COMPILE_USER, /* compile all user predicates*/
COMPILE_ALL /* compile all predicates */
} yap_exec_mode;
/********* slots ***********************/
static inline void
Yap_StartSlots( USES_REGS1 ) {
*--ASP = MkIntegerTerm(CurSlot);
*--ASP = MkIntTerm(0);
CurSlot = LCL0-ASP;
}
static inline void
Yap_CloseSlots( USES_REGS1 ) {
Int old_slots;
old_slots = IntOfTerm(ASP[0]);
ASP += (old_slots+1);
CurSlot = IntOfTerm(*ASP);
ASP++;
}
static inline Int
Yap_CurrentSlot( USES_REGS1 ) {
return IntOfTerm(ASP[0]);
}
#endif /* YAP_H */

View File

@ -52,17 +52,17 @@ typedef struct swi_reverse_hash {
Int pos;
} swi_rev_hash;
#define GC_MAVARS_HASH_SIZE 512
typedef struct gc_ma_hash_entry_struct {
UInt timestmp;
#ifdef TABLING
tr_fr_ptr loc;
struct gc_ma_hash_entry_struct *more;
#endif
CELL* addr;
struct gc_ma_hash_entry_struct *next;
} gc_ma_hash_entry;
//#define GC_MAVARS_HASH_SIZE 512
//
//typedef struct gc_ma_hash_entry_struct {
// UInt timestmp;
//#ifdef TABLING
// tr_fr_ptr loc;
// struct gc_ma_hash_entry_struct *more;
//#endif
// CELL* addr;
// struct gc_ma_hash_entry_struct *next;
//} gc_ma_hash_entry;
typedef void (*HaltHookFunc)(int, void *);
@ -81,19 +81,10 @@ typedef struct atom_hash_entry {
Atom Entry;
} AtomHashEntry;
typedef struct reduction_counters {
YAP_ULONG_LONG reductions;
YAP_ULONG_LONG reductions_retries;
YAP_ULONG_LONG retries;
int reductions_on;
int reductions_retries_on;
int retries_on;
} red_counters;
typedef struct scratch_block_struct {
char *ptr;
UInt sz, msz;
} scratch_block;
//typedef struct scratch_block_struct {
// char *ptr;
// UInt sz, msz;
//} scratch_block;
typedef struct record_list {
/* a list of dbterms associated with a clause */
@ -101,34 +92,12 @@ typedef struct record_list {
struct record_list *next_rec, *prev_rec;
} DBRecordList;
typedef struct restore_info {
Int base_diff;
Int cl_diff;
Int g_diff;
Int g_diff0;
Int h_diff;
Int l_diff;
Int tr_diff;
Int x_diff;
Int delay_diff;
CELL *old_ASP;
CELL *old_LCL0;
CELL *g_split;
tr_fr_ptr old_TR;
CELL *old_GlobalBase;
CELL *old_H;
CELL *old_H0;
ADDR old_TrailBase;
ADDR old_TrailTop;
ADDR old_HeapBase;
ADDR old_HeapTop;
} restoreinfo;
/* SWI Emulation */
#define SWI_BUF_SIZE 512
#define SWI_TMP_BUF_SIZE 2*SWI_BUF_SIZE
#define SWI_BUF_RINGS 16
/* ricardo
#ifdef THREADS
typedef struct thandle {
int in_use;
@ -162,9 +131,9 @@ typedef struct thandle {
struct timeval *last_timep;
#endif
} yap_thandle;
#endif
#endif */
typedef int (*Agc_hook)(Atom);
//typedef int (*Agc_hook)(Atom);
/*******************
this is the data base: everything here should be possible to restore
@ -177,9 +146,10 @@ typedef struct various_codes {
} all_heap_codes;
#include "hglobals.h"
#include "hlocals.h"
//#include "hglobals.h"
//#include "hlocals.h"
/* ricardo
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
extern struct global_data *Yap_global;
extern long Yap_worker_area_size;
@ -189,19 +159,16 @@ extern struct global_data Yap_Global;
#endif
#if defined(THREADS)
extern struct worker_local *Yap_WLocal[MAX_THREADS];
#define WL (Yap_WLocal[worker_id])
#define FOREIGN(wid) (Yap_WLocal[(wid)])
extern struct worker_local *Yap_local[MAX_THREADS];
#define REMOTE(wid) (Yap_local[wid])
#elif defined(YAPOR)
extern struct worker_local *Yap_WLocal;
#define WL (Yap_WLocal+worker_id)
#define FOREIGN(wid) (Yap_WLocal+wid)
#else /* !THREADS && !YAPOR */
extern struct worker_local Yap_WLocal;
#define WL (&Yap_WLocal)
#define FOREIGN(wid) (&Yap_WLocal)
extern struct worker_local *Yap_local;
#define REMOTE(wid) (Yap_local + wid)
#else
extern struct worker_local Yap_local;
#define REMOTE(wid) (&Yap_local)
#endif
*/
#ifdef USE_SYSTEM_MALLOC
extern struct various_codes *Yap_heap_regs;
@ -210,8 +177,8 @@ extern struct various_codes *Yap_heap_regs;
#endif
#include "dhstruct.h"
#include "dglobals.h"
#include "dlocals.h"
//#include "dglobals.h"
//#include "dlocals.h"
/*******************
these are the global variables: they need not be restored...

View File

@ -132,9 +132,6 @@ Term STD_PROTO(Yap_all_calls,(void));
Atom STD_PROTO(Yap_ConsultingFile,(void));
struct pred_entry *STD_PROTO(Yap_PredForChoicePt,(choiceptr));
void STD_PROTO(Yap_InitCdMgr,(void));
#ifdef EMACS
int STD_PROTO(where_new_clause, (Prop, int));
#endif
void STD_PROTO(Yap_init_consult,(int, char *));
void STD_PROTO(Yap_end_consult,(void));
void STD_PROTO(Yap_Abolish,(struct pred_entry *));
@ -239,6 +236,9 @@ void STD_PROTO(Yap_InitCPredBack_,(char *, unsigned long int, unsigned int, C
#endif
void STD_PROTO(Yap_InitWorkspace,(UInt,UInt,UInt,UInt,UInt,int,int,int));
#ifdef YAPOR
void STD_PROTO(Yap_init_yapor_workers, (void));
#endif /* YAPOR */
#if defined(YAPOR) || defined(THREADS)
void STD_PROTO(Yap_KillStacks,(int));
#else
@ -328,6 +328,7 @@ void STD_PROTO(Yap_undo_signal,(yap_signals));
int STD_PROTO(Yap_IsOpMaxPrio,(Atom));
/* sysbits.c */
void STD_PROTO(Yap_InitPageSize, (void));
void STD_PROTO(Yap_set_fpu_exceptions,(int));
UInt STD_PROTO(Yap_cputime,(void));
Int STD_PROTO(Yap_walltime,(void));
@ -391,6 +392,11 @@ void STD_PROTO(Yap_InitUtilCPreds,(void));
Int STD_PROTO(Yap_TermHash,(Term, Int, Int, int));
/* yap.c */
/* write.c */
void STD_PROTO(Yap_plwrite,(Term,int (*)(int, wchar_t), int, int));
/* MYDDAS */
#if defined MYDDAS_MYSQL || defined MYDDAS_ODBC

View File

@ -1493,7 +1493,7 @@ Yap_GetThreadPred(struct pred_entry *ap USES_REGS)
{
Functor f = ap->FunctorOfPred;
Term mod = ap->ModuleOfPred;
Prop p0 = AbsPredProp(MY_ThreadHandle.local_preds);
Prop p0 = AbsPredProp(LOCAL_ThreadHandle.local_preds);
while(p0) {
PredEntry *ap = RepPredProp(p0);

View File

@ -192,7 +192,7 @@ restore_absmi_regs(REGSTORE * old_regs)
memcpy(old_regs, Yap_regp, sizeof(REGSTORE));
#ifdef THREADS
pthread_setspecific(Yap_yaamregs_key, (void *)old_regs);
MY_ThreadHandle.current_yaam_regs = old_regs;
LOCAL_ThreadHandle.current_yaam_regs = old_regs;
#else
Yap_regp = old_regs;
#endif
@ -682,10 +682,10 @@ Macros to check the limits of stacks
#else
#define check_trail(x) if (Unsigned(Yap_TrailTop) - Unsigned(x) < MinTrailGap) \
#define check_trail(x) if (Unsigned(LOCAL_TrailTop) - Unsigned(x) < MinTrailGap) \
goto notrailleft
#define check_trail_in_indexing(x) if (Unsigned(Yap_TrailTop) - Unsigned(x) < MinTrailGap) \
#define check_trail_in_indexing(x) if (Unsigned(LOCAL_TrailTop) - Unsigned(x) < MinTrailGap) \
goto notrailleft_from_index
#endif
@ -734,7 +734,7 @@ Macros to check the limits of stacks
ENDP(pt0)
#if LOW_LEVEL_TRACER
#define COUNT_CPS() Yap_total_choicepoints++
#define COUNT_CPS() LOCAL_total_choicepoints++
#else
#define COUNT_CPS()
#endif

View File

@ -1095,12 +1095,8 @@ extern void **Yap_ABSMI_OPCODES;
#define absmadr(i) ((OPCODE)(i))
#endif
/* used to find out how many instructions of each kind are executed */
#ifdef ANALYST
extern YAP_ULONG_LONG Yap_opcount[_std_top + 1];
extern YAP_ULONG_LONG Yap_2opcount[_std_top + 1][_std_top + 1];
#endif /* ANALYST */
#if DEPTH_LIMIT
/*

View File

@ -15,6 +15,7 @@
* dereferencing, binding, trailing, and unification. *
* *
*************************************************************************/
#ifdef SCCS
static char SccsId[] = "%W% %G%";
#endif /* SCCS */
@ -276,7 +277,7 @@ Binding Macros for Multiple Assignment Variables.
#define TRAIL_CLREF(REF) TrailTerm(TR++) = CLREF_TO_TRENTRY(REF)
#define TRAIL_LINK(REF) TrailTerm(TR++) = AbsPair((CELL *)(REF))
#endif
#define TRAIL_FRAME(FR) DO_TRAIL(AbsPair((CELL *)(Yap_TrailBase)), FR)
#define TRAIL_FRAME(FR) DO_TRAIL(AbsPair((CELL *)(LOCAL_TrailBase)), FR)
extern void Yap_WakeUp(CELL *v);

View File

@ -32,7 +32,7 @@ struct cut_c_str{
#define POP_CHOICE_POINT(cp) \
(((CELL *)Yap_REGS.CUT_C_TOP != (CELL *)Yap_LocalBase) && ((CELL *)(cp) > (CELL *)Yap_REGS.CUT_C_TOP))
(((CELL *)Yap_REGS.CUT_C_TOP != (CELL *)LOCAL_LocalBase) && ((CELL *)(cp) > (CELL *)Yap_REGS.CUT_C_TOP))
#define POP_EXECUTE() \

View File

@ -1,5 +1,5 @@
/* This file, dglobals.h, was generated automatically by "yap -L misc/buildheap"
/* This file, dglobals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/GLOBALS instead */
@ -20,45 +20,91 @@
#define GLOBAL_Initialised Yap_global->Initialised_
#define GLOBAL_InitialisedFromPL Yap_global->InitialisedFromPL_
#define GLOBAL_PL_Argc Yap_global->PL_Argc_
#define GLOBAL_PL_Argv Yap_global->PL_Argv_
#define GLOBAL_HaltHooks Yap_global->HaltHooks_
#define GLOBAL_AllowLocalExpansion Yap_global->AllowLocalExpansion_
#define GLOBAL_AllowGlobalExpansion Yap_global->AllowGlobalExpansion_
#define GLOBAL_AllowTrailExpansion Yap_global->AllowTrailExpansion_
#define GLOBAL_SizeOfOverflow Yap_global->SizeOfOverflow_
#define GLOBAL_AGcThreshold Yap_global->AGcThreshold_
#define GLOBAL_AGCHook Yap_global->AGCHook_
#if THREADS
#define Yap_NOfThreads Yap_global->n_of_threads
#define GLOBAL_NOfThreads Yap_global->NOfThreads_
#define Yap_NOfThreadsCreated Yap_global->n_of_threads_created
#define GLOBAL_NOfThreadsCreated Yap_global->NOfThreadsCreated_
#define Yap_ThreadsTotalTime Yap_global->threads_total_time
#endif
#define GLOBAL_ThreadsTotalTime Yap_global->ThreadsTotalTime_
#define GLOBAL_ThreadHandlesLock Yap_global->ThreadHandlesLock_
#endif
#if defined(YAPOR) || defined(THREADS)
#define Yap_BGL Yap_global->bgl
#define GLOBAL_BGL Yap_global->BGL_
#endif
#define Yap_AllowLocalExpansion Yap_global->allow_local_expansion
#define Yap_AllowGlobalExpansion Yap_global->allow_global_expansion
#define Yap_AllowTrailExpansion Yap_global->allow_trail_expansion
#define Yap_SizeOfOverflow Yap_global->size_of_overflow
#define Yap_AGcLastCall Yap_global->agc_last_call
#define Yap_AGcThreshold Yap_global->agc_threshold
#define Yap_AGCHook Yap_global->agc_hook
#ifdef THREADS
#define Yap_ThreadHandlesLock Yap_global->thread_handles_lock
#endif
#if defined(YAPOR) || defined(TABLING)
#define Yap_optyap_data Yap_global->optyap_data
#define REMOTE Yap_global->remote
#define GLOBAL_optyap_data Yap_global->optyap_data_
#endif /* YAPOR || TABLING */
#define GLOBAL_PrologShouldHandleInterrupts Yap_global->PrologShouldHandleInterrupts_
#if defined(THREADS)
#define GLOBAL_master_thread Yap_global->master_thread_
#endif /* THREADS */
#define GLOBAL_stdout Yap_global->stdout_
#define GLOBAL_stderr Yap_global->stderr_
#define GLOBAL_argv Yap_global->argv_
#define GLOBAL_argc Yap_global->argc_
#ifdef COROUTINING
#define GLOBAL_attas Yap_global->attas_
#endif
#define GLOBAL_agc_calls Yap_global->agc_calls_
#define GLOBAL_agc_collected Yap_global->agc_collected_
#define GLOBAL_tot_agc_time Yap_global->tot_agc_time_
#define GLOBAL_tot_agc_recovered Yap_global->tot_agc_recovered_
#if HAVE_MMAP
#define GLOBAL_mmap_arrays Yap_global->mmap_arrays_
#endif
#ifdef DEBUG
#define GLOBAL_Option Yap_global->Option_
#define GLOBAL_logfile Yap_global->logfile_
#define GLOBAL_output_msg Yap_global->output_msg_
#endif
#define GLOBAL_ProfCalls Yap_global->ProfCalls_
#define GLOBAL_ProfGCs Yap_global->ProfGCs_
#define GLOBAL_ProfHGrows Yap_global->ProfHGrows_
#define GLOBAL_ProfSGrows Yap_global->ProfSGrows_
#define GLOBAL_ProfMallocs Yap_global->ProfMallocs_
#define GLOBAL_ProfOn Yap_global->ProfOn_
#define GLOBAL_ProfOns Yap_global->ProfOns_
#define GLOBAL_ProfilerRoot Yap_global->ProfilerRoot_
#define GLOBAL_ProfilerNil Yap_global->ProfilerNil_
#define GLOBAL_DIRNAME Yap_global->DIRNAME_
#if defined(COFF) || defined(A_OUT)
#define GLOBAL_Executable Yap_global->Executable_
#endif
#if __simplescalar__
#define GLOBAL_pwd Yap_global->pwd_
#endif
#define Yap_Initialised Yap_global->initialised
#define Yap_InitialisedFromPL Yap_global->initialised_from_pl
#define Yap_PL_Argc Yap_global->pl_argc
#define Yap_PL_Argv Yap_global->pl_argv
#define Yap_HaltHooks Yap_global->yap_halt_hook

View File

@ -1,143 +1,319 @@
/* This file, dlocals.h, was generated automatically by "yap -L misc/buildheap"
/* This file, dlocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/LOCALS instead */
#define Yap_c_input_stream WL->c_input_stream
#define Yap_c_output_stream WL->c_output_stream
#define Yap_c_error_stream WL->c_error_stream
#define LOCAL_c_input_stream LOCAL->c_input_stream_
#define REMOTE_c_input_stream(wid) REMOTE(wid)->c_input_stream_
#define LOCAL_c_output_stream LOCAL->c_output_stream_
#define REMOTE_c_output_stream(wid) REMOTE(wid)->c_output_stream_
#define LOCAL_c_error_stream LOCAL->c_error_stream_
#define REMOTE_c_error_stream(wid) REMOTE(wid)->c_error_stream_
#define OldASP WL->rinfo.old_ASP
#define OldLCL0 WL->rinfo.old_LCL0
#define OldTR WL->rinfo.old_TR
#define OldGlobalBase WL->rinfo.old_GlobalBase
#define OldH WL->rinfo.old_H
#define OldH0 WL->rinfo.old_H0
#define OldTrailBase WL->rinfo.old_TrailBase
#define OldTrailTop WL->rinfo.old_TrailTop
#define OldHeapBase WL->rinfo.old_HeapBase
#define OldHeapTop WL->rinfo.old_HeapTop
#define ClDiff WL->rinfo.cl_diff
#define GDiff WL->rinfo.g_diff
#define HDiff WL->rinfo.h_diff
#define GDiff0 WL->rinfo.g_diff0
#define GSplit WL->rinfo.g_split
#define LDiff WL->rinfo.l_diff
#define TrDiff WL->rinfo.tr_diff
#define XDiff WL->rinfo.x_diff
#define DelayDiff WL->rinfo.delay_diff
#define BaseDiff WL->rinfo.base_diff
#define ReductionsCounter WL->call_counters.reductions
#define PredEntriesCounter WL->call_counters.reductions_retries
#define RetriesCounter WL->call_counters.retries
#define ReductionsCounterOn WL->call_counters.reductions_on
#define PredEntriesCounterOn WL->call_counters.reductions_retries_on
#define RetriesCounterOn WL->call_counters.retries_on
#define Yap_InterruptsDisabled WL->interrupts_disabled
#define LOCAL_OldASP LOCAL->OldASP_
#define REMOTE_OldASP(wid) REMOTE(wid)->OldASP_
#define LOCAL_OldLCL0 LOCAL->OldLCL0_
#define REMOTE_OldLCL0(wid) REMOTE(wid)->OldLCL0_
#define LOCAL_OldTR LOCAL->OldTR_
#define REMOTE_OldTR(wid) REMOTE(wid)->OldTR_
#define LOCAL_OldGlobalBase LOCAL->OldGlobalBase_
#define REMOTE_OldGlobalBase(wid) REMOTE(wid)->OldGlobalBase_
#define LOCAL_OldH LOCAL->OldH_
#define REMOTE_OldH(wid) REMOTE(wid)->OldH_
#define LOCAL_OldH0 LOCAL->OldH0_
#define REMOTE_OldH0(wid) REMOTE(wid)->OldH0_
#define LOCAL_OldTrailBase LOCAL->OldTrailBase_
#define REMOTE_OldTrailBase(wid) REMOTE(wid)->OldTrailBase_
#define LOCAL_OldTrailTop LOCAL->OldTrailTop_
#define REMOTE_OldTrailTop(wid) REMOTE(wid)->OldTrailTop_
#define LOCAL_OldHeapBase LOCAL->OldHeapBase_
#define REMOTE_OldHeapBase(wid) REMOTE(wid)->OldHeapBase_
#define LOCAL_OldHeapTop LOCAL->OldHeapTop_
#define REMOTE_OldHeapTop(wid) REMOTE(wid)->OldHeapTop_
#define LOCAL_ClDiff LOCAL->ClDiff_
#define REMOTE_ClDiff(wid) REMOTE(wid)->ClDiff_
#define LOCAL_GDiff LOCAL->GDiff_
#define REMOTE_GDiff(wid) REMOTE(wid)->GDiff_
#define LOCAL_HDiff LOCAL->HDiff_
#define REMOTE_HDiff(wid) REMOTE(wid)->HDiff_
#define LOCAL_GDiff0 LOCAL->GDiff0_
#define REMOTE_GDiff0(wid) REMOTE(wid)->GDiff0_
#define LOCAL_GSplit LOCAL->GSplit_
#define REMOTE_GSplit(wid) REMOTE(wid)->GSplit_
#define LOCAL_LDiff LOCAL->LDiff_
#define REMOTE_LDiff(wid) REMOTE(wid)->LDiff_
#define LOCAL_TrDiff LOCAL->TrDiff_
#define REMOTE_TrDiff(wid) REMOTE(wid)->TrDiff_
#define LOCAL_XDiff LOCAL->XDiff_
#define REMOTE_XDiff(wid) REMOTE(wid)->XDiff_
#define LOCAL_DelayDiff LOCAL->DelayDiff_
#define REMOTE_DelayDiff(wid) REMOTE(wid)->DelayDiff_
#define LOCAL_BaseDiff LOCAL->BaseDiff_
#define REMOTE_BaseDiff(wid) REMOTE(wid)->BaseDiff_
#define LOCAL_ReductionsCounter LOCAL->ReductionsCounter_
#define REMOTE_ReductionsCounter(wid) REMOTE(wid)->ReductionsCounter_
#define LOCAL_PredEntriesCounter LOCAL->PredEntriesCounter_
#define REMOTE_PredEntriesCounter(wid) REMOTE(wid)->PredEntriesCounter_
#define LOCAL_RetriesCounter LOCAL->RetriesCounter_
#define REMOTE_RetriesCounter(wid) REMOTE(wid)->RetriesCounter_
#define LOCAL_ReductionsCounterOn LOCAL->ReductionsCounterOn_
#define REMOTE_ReductionsCounterOn(wid) REMOTE(wid)->ReductionsCounterOn_
#define LOCAL_PredEntriesCounterOn LOCAL->PredEntriesCounterOn_
#define REMOTE_PredEntriesCounterOn(wid) REMOTE(wid)->PredEntriesCounterOn_
#define LOCAL_RetriesCounterOn LOCAL->RetriesCounterOn_
#define REMOTE_RetriesCounterOn(wid) REMOTE(wid)->RetriesCounterOn_
#define ConsultSp WL->consultsp
#define LOCAL_ConsultSp LOCAL->ConsultSp_
#define REMOTE_ConsultSp(wid) REMOTE(wid)->ConsultSp_
#define ConsultCapacity WL->consultcapacity
#define LOCAL_ConsultCapacity LOCAL->ConsultCapacity_
#define REMOTE_ConsultCapacity(wid) REMOTE(wid)->ConsultCapacity_
#define ConsultBase WL->consultbase
#define LOCAL_ConsultBase LOCAL->ConsultBase_
#define REMOTE_ConsultBase(wid) REMOTE(wid)->ConsultBase_
#define ConsultLow WL->consultlow
#define LOCAL_ConsultLow LOCAL->ConsultLow_
#define REMOTE_ConsultLow(wid) REMOTE(wid)->ConsultLow_
#define GlobalArena WL->global_arena
#define GlobalArenaOverflows WL->global_arena_overflows
#define DelayArenaOverflows WL->delay_arena_overflows
#define ArenaOverflows WL->arena_overflows
#define DepthArenas WL->depth_arenas
#define ArithError WL->arith_error
#define LastAssertedPred WL->last_asserted_pred
#define DebugOn WL->debug_on
#define FormatInfo WL->f_info
#define ScannerStack WL->scanner_stack
#define ScannerExtraBlocks WL->scanner_extra_blocks
#define BallTerm WL->ball_term
#define ActiveSignals WL->active_signals
#define IPredArity WL->i_pred_arity
#define ProfEnd WL->prof_end
#define UncaughtThrow WL->uncaught_throw
#define DoingUndefp WL->doing_undefp
#define StartLine WL->start_line
#define ScratchPad WL->scratchpad
#define LOCAL_GlobalArena LOCAL->GlobalArena_
#define REMOTE_GlobalArena(wid) REMOTE(wid)->GlobalArena_
#define LOCAL_GlobalArenaOverflows LOCAL->GlobalArenaOverflows_
#define REMOTE_GlobalArenaOverflows(wid) REMOTE(wid)->GlobalArenaOverflows_
#define LOCAL_ArenaOverflows LOCAL->ArenaOverflows_
#define REMOTE_ArenaOverflows(wid) REMOTE(wid)->ArenaOverflows_
#define LOCAL_DepthArenas LOCAL->DepthArenas_
#define REMOTE_DepthArenas(wid) REMOTE(wid)->DepthArenas_
#define LOCAL_ArithError LOCAL->ArithError_
#define REMOTE_ArithError(wid) REMOTE(wid)->ArithError_
#define LOCAL_LastAssertedPred LOCAL->LastAssertedPred_
#define REMOTE_LastAssertedPred(wid) REMOTE(wid)->LastAssertedPred_
#define LOCAL_DebugOn LOCAL->DebugOn_
#define REMOTE_DebugOn(wid) REMOTE(wid)->DebugOn_
#define LOCAL_ScannerStack LOCAL->ScannerStack_
#define REMOTE_ScannerStack(wid) REMOTE(wid)->ScannerStack_
#define LOCAL_ScannerExtraBlocks LOCAL->ScannerExtraBlocks_
#define REMOTE_ScannerExtraBlocks(wid) REMOTE(wid)->ScannerExtraBlocks_
#define LOCAL_BallTerm LOCAL->BallTerm_
#define REMOTE_BallTerm(wid) REMOTE(wid)->BallTerm_
#define LOCAL_ActiveSignals LOCAL->ActiveSignals_
#define REMOTE_ActiveSignals(wid) REMOTE(wid)->ActiveSignals_
#define LOCAL_IPredArity LOCAL->IPredArity_
#define REMOTE_IPredArity(wid) REMOTE(wid)->IPredArity_
#define LOCAL_ProfEnd LOCAL->ProfEnd_
#define REMOTE_ProfEnd(wid) REMOTE(wid)->ProfEnd_
#define LOCAL_UncaughtThrow LOCAL->UncaughtThrow_
#define REMOTE_UncaughtThrow(wid) REMOTE(wid)->UncaughtThrow_
#define LOCAL_DoingUndefp LOCAL->DoingUndefp_
#define REMOTE_DoingUndefp(wid) REMOTE(wid)->DoingUndefp_
#define LOCAL_StartLine LOCAL->StartLine_
#define REMOTE_StartLine(wid) REMOTE(wid)->StartLine_
#define LOCAL_ScratchPad LOCAL->ScratchPad_
#define REMOTE_ScratchPad(wid) REMOTE(wid)->ScratchPad_
#ifdef COROUTINING
#define WokenGoals WL->woken_goals
#define AttsMutableList WL->atts_mutable_list
#define LOCAL_WokenGoals LOCAL->WokenGoals_
#define REMOTE_WokenGoals(wid) REMOTE(wid)->WokenGoals_
#define LOCAL_AttsMutableList LOCAL->AttsMutableList_
#define REMOTE_AttsMutableList(wid) REMOTE(wid)->AttsMutableList_
#endif
#define GcGeneration WL->gc_generation
#define GcPhase WL->gc_phase
#define GcCurrentPhase WL->gc_current_phase
#define GcCalls WL->gc_calls
#define TotGcTime WL->tot_gc_time
#define TotGcRecovered WL->tot_gc_recovered
#define LastGcTime WL->last_gc_time
#define LastSSTime WL->last_ss_time
#if LOW_LEVEL_TRACER
#define Yap_total_choicepoints WL->total_cps
#define LOCAL_GcGeneration LOCAL->GcGeneration_
#define REMOTE_GcGeneration(wid) REMOTE(wid)->GcGeneration_
#define LOCAL_GcPhase LOCAL->GcPhase_
#define REMOTE_GcPhase(wid) REMOTE(wid)->GcPhase_
#define LOCAL_GcCurrentPhase LOCAL->GcCurrentPhase_
#define REMOTE_GcCurrentPhase(wid) REMOTE(wid)->GcCurrentPhase_
#define LOCAL_GcCalls LOCAL->GcCalls_
#define REMOTE_GcCalls(wid) REMOTE(wid)->GcCalls_
#define LOCAL_TotGcTime LOCAL->TotGcTime_
#define REMOTE_TotGcTime(wid) REMOTE(wid)->TotGcTime_
#define LOCAL_TotGcRecovered LOCAL->TotGcRecovered_
#define REMOTE_TotGcRecovered(wid) REMOTE(wid)->TotGcRecovered_
#define LOCAL_LastGcTime LOCAL->LastGcTime_
#define REMOTE_LastGcTime(wid) REMOTE(wid)->LastGcTime_
#define LOCAL_LastSSTime LOCAL->LastSSTime_
#define REMOTE_LastSSTime(wid) REMOTE(wid)->LastSSTime_
#define LOCAL_total_marked LOCAL->total_marked_
#define REMOTE_total_marked(wid) REMOTE(wid)->total_marked_
#define LOCAL_total_oldies LOCAL->total_oldies_
#define REMOTE_total_oldies(wid) REMOTE(wid)->total_oldies_
#define LOCAL_current_B LOCAL->current_B_
#define REMOTE_current_B(wid) REMOTE(wid)->current_B_
#define LOCAL_prev_HB LOCAL->prev_HB_
#define REMOTE_prev_HB(wid) REMOTE(wid)->prev_HB_
#define LOCAL_HGEN LOCAL->HGEN_
#define REMOTE_HGEN(wid) REMOTE(wid)->HGEN_
#define LOCAL_iptop LOCAL->iptop_
#define REMOTE_iptop(wid) REMOTE(wid)->iptop_
#if defined(GC_NO_TAGS)
#define LOCAL_bp LOCAL->bp_
#define REMOTE_bp(wid) REMOTE(wid)->bp_
#endif
#define consult_level WL->consult_level_
#define LOCAL_sTR LOCAL->sTR_
#define REMOTE_sTR(wid) REMOTE(wid)->sTR_
#define LOCAL_sTR0 LOCAL->sTR0_
#define REMOTE_sTR0(wid) REMOTE(wid)->sTR0_
#define LOCAL_new_TR LOCAL->new_TR_
#define REMOTE_new_TR(wid) REMOTE(wid)->new_TR_
#define LOCAL_cont_top0 LOCAL->cont_top0_
#define REMOTE_cont_top0(wid) REMOTE(wid)->cont_top0_
#define LOCAL_cont_top LOCAL->cont_top_
#define REMOTE_cont_top(wid) REMOTE(wid)->cont_top_
#define LOCAL_discard_trail_entries LOCAL->discard_trail_entries_
#define REMOTE_discard_trail_entries(wid) REMOTE(wid)->discard_trail_entries_
#define LOCAL_gc_ma_hash_table LOCAL->gc_ma_hash_table_
#define REMOTE_gc_ma_hash_table(wid) REMOTE(wid)->gc_ma_hash_table_
#define LOCAL_gc_ma_h_top LOCAL->gc_ma_h_top_
#define REMOTE_gc_ma_h_top(wid) REMOTE(wid)->gc_ma_h_top_
#define LOCAL_gc_ma_h_list LOCAL->gc_ma_h_list_
#define REMOTE_gc_ma_h_list(wid) REMOTE(wid)->gc_ma_h_list_
#define LOCAL_gc_timestamp LOCAL->gc_timestamp_
#define REMOTE_gc_timestamp(wid) REMOTE(wid)->gc_timestamp_
#define LOCAL_db_vec LOCAL->db_vec_
#define REMOTE_db_vec(wid) REMOTE(wid)->db_vec_
#define LOCAL_db_vec0 LOCAL->db_vec0_
#define REMOTE_db_vec0(wid) REMOTE(wid)->db_vec0_
#define LOCAL_db_root LOCAL->db_root_
#define REMOTE_db_root(wid) REMOTE(wid)->db_root_
#define LOCAL_db_nil LOCAL->db_nil_
#define REMOTE_db_nil(wid) REMOTE(wid)->db_nil_
#define LOCAL_gc_restore LOCAL->gc_restore_
#define REMOTE_gc_restore(wid) REMOTE(wid)->gc_restore_
#define LOCAL_DynamicArrays LOCAL->DynamicArrays_
#define REMOTE_DynamicArrays(wid) REMOTE(wid)->DynamicArrays_
#define LOCAL_StaticArrays LOCAL->StaticArrays_
#define REMOTE_StaticArrays(wid) REMOTE(wid)->StaticArrays_
#define LOCAL_GlobalVariables LOCAL->GlobalVariables_
#define REMOTE_GlobalVariables(wid) REMOTE(wid)->GlobalVariables_
#define LOCAL_AllowRestart LOCAL->AllowRestart_
#define REMOTE_AllowRestart(wid) REMOTE(wid)->AllowRestart_
#if defined(YAPOR) || defined(THREADS)
#define SignalLock WL->signal_lock
#define WPP WL->wpp
#define LOCAL_CMemFirstBlock LOCAL->CMemFirstBlock_
#define REMOTE_CMemFirstBlock(wid) REMOTE(wid)->CMemFirstBlock_
#define LOCAL_CMemFirstBlockSz LOCAL->CMemFirstBlockSz_
#define REMOTE_CMemFirstBlockSz(wid) REMOTE(wid)->CMemFirstBlockSz_
#define total_marked WL->tot_marked
#define total_oldies WL->tot_oldies
#if DEBUG && COROUTINING
#define total_smarked WL->tot_smarked
#endif
#define current_B WL->wl_current_B
#define prev_HB WL->wl_prev_HB
#define HGEN WL->hgen
#define iptop WL->ip_top
#if GC_NO_TAGS
#define Yap_bp WL->b_p
#endif
#if defined(TABLING) || defined(YAPOR_SBA)
#define sTR WL->wl_sTR
#define sTR0 WL->wl_sTR0
#define new_TR WL->new_tr
#else
#define sTR WL->wl_sTR
#define sTR0 WL->wl_sTR0
#define new_TR WL->new_tr
#endif
#define cont_top0 WL->conttop0
#define cont_top WL->conttop
#define discard_trail_entries WL->disc_trail_entries
#define gc_ma_hash_table WL->Gc_ma_hash_table
#define gc_ma_h_top WL->Gc_ma_h_top
#define gc_ma_h_list WL->Gc_ma_h_list
#define gc_timestamp WL->Gc_timestamp
#define db_vec WL->DB_vec
#define db_vec0 WL->DB_vec0
#define db_root WL->DB_root
#define db_nil WL->DB_nil
#endif /* defined(YAPOR) || defined(THREADS) */
#define Yap_gc_restore WL->gc_restore
#define DynamicArrays WL->dynamic_arrays
#define StaticArrays WL->static_arrays
#define GlobalVariables WL->global_variables
#define Yap_AllowRestart WL->allow_restart
#define LOCAL_LabelFirstArray LOCAL->LabelFirstArray_
#define REMOTE_LabelFirstArray(wid) REMOTE(wid)->LabelFirstArray_
#define LOCAL_LabelFirstArraySz LOCAL->LabelFirstArraySz_
#define REMOTE_LabelFirstArraySz(wid) REMOTE(wid)->LabelFirstArraySz_
#define Yap_CMemFirstBlock WL->cmem_first_block
#define Yap_CMemFirstBlockSz WL->cmem_first_block_sz
#define Yap_LabelFirstArray WL->label_first_array
#define Yap_LabelFirstArraySz WL->label_first_array_sz
#define PL_local_data_p WL->Yap_ld_
#define execution WL->_execution
#define LOCAL_PL_local_data_p LOCAL->PL_local_data_p_
#define REMOTE_PL_local_data_p(wid) REMOTE(wid)->PL_local_data_p_
#ifdef THREADS
#define ThreadHandle WL->thread_handle
#define FOREIGN_ThreadHandle(wid) (Yap_WLocal[(wid)]->thread_handle)
#define MY_ThreadHandle (Yap_WLocal[worker_id]->thread_handle)
#define LOCAL_ThreadHandle LOCAL->ThreadHandle_
#define REMOTE_ThreadHandle(wid) REMOTE(wid)->ThreadHandle_
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
#define LOCAL_optyap_data LOCAL->optyap_data_
#define REMOTE_optyap_data(wid) REMOTE(wid)->optyap_data_
#endif /* YAPOR || TABLING */
#define LOCAL_InterruptsDisabled LOCAL->InterruptsDisabled_
#define REMOTE_InterruptsDisabled(wid) REMOTE(wid)->InterruptsDisabled_
#define LOCAL_execution LOCAL->execution_
#define REMOTE_execution(wid) REMOTE(wid)->execution_
#if LOW_LEVEL_TRACER
#define LOCAL_total_choicepoints LOCAL->total_choicepoints_
#define REMOTE_total_choicepoints(wid) REMOTE(wid)->total_choicepoints_
#endif
#define LOCAL_consult_level LOCAL->consult_level_
#define REMOTE_consult_level(wid) REMOTE(wid)->consult_level_
#if defined(YAPOR) || defined(THREADS)
#define LOCAL_SignalLock LOCAL->SignalLock_
#define REMOTE_SignalLock(wid) REMOTE(wid)->SignalLock_
#endif
#define LOCAL_LocalBase LOCAL->LocalBase_
#define REMOTE_LocalBase(wid) REMOTE(wid)->LocalBase_
#define LOCAL_GlobalBase LOCAL->GlobalBase_
#define REMOTE_GlobalBase(wid) REMOTE(wid)->GlobalBase_
#define LOCAL_TrailBase LOCAL->TrailBase_
#define REMOTE_TrailBase(wid) REMOTE(wid)->TrailBase_
#define LOCAL_TrailTop LOCAL->TrailTop_
#define REMOTE_TrailTop(wid) REMOTE(wid)->TrailTop_
#define LOCAL_ErrorMessage LOCAL->ErrorMessage_
#define REMOTE_ErrorMessage(wid) REMOTE(wid)->ErrorMessage_
#define LOCAL_Error_Term LOCAL->Error_Term_
#define REMOTE_Error_Term(wid) REMOTE(wid)->Error_Term_
#ifdef THREADS
#define LOCAL_Error_TYPE LOCAL->Error_TYPE_
#define REMOTE_Error_TYPE(wid) REMOTE(wid)->Error_TYPE_
#else
#define LOCAL_Error_TYPE LOCAL->Error_TYPE_
#define REMOTE_Error_TYPE(wid) REMOTE(wid)->Error_TYPE_
#endif
#define LOCAL_Error_Size LOCAL->Error_Size_
#define REMOTE_Error_Size(wid) REMOTE(wid)->Error_Size_
#define LOCAL_ErrorSay LOCAL->ErrorSay_
#define REMOTE_ErrorSay(wid) REMOTE(wid)->ErrorSay_
#define LOCAL_IOBotch LOCAL->IOBotch_
#define REMOTE_IOBotch(wid) REMOTE(wid)->IOBotch_
#define LOCAL_tokptr LOCAL->tokptr_
#define REMOTE_tokptr(wid) REMOTE(wid)->tokptr_
#define LOCAL_toktide LOCAL->toktide_
#define REMOTE_toktide(wid) REMOTE(wid)->toktide_
#define LOCAL_VarTable LOCAL->VarTable_
#define REMOTE_VarTable(wid) REMOTE(wid)->VarTable_
#define LOCAL_AnonVarTable LOCAL->AnonVarTable_
#define REMOTE_AnonVarTable(wid) REMOTE(wid)->AnonVarTable_
#define LOCAL_RestartEnv LOCAL->RestartEnv_
#define REMOTE_RestartEnv(wid) REMOTE(wid)->RestartEnv_
#define LOCAL_FileNameBuf LOCAL->FileNameBuf_
#define REMOTE_FileNameBuf(wid) REMOTE(wid)->FileNameBuf_
#define LOCAL_FileNameBuf2 LOCAL->FileNameBuf2_
#define REMOTE_FileNameBuf2(wid) REMOTE(wid)->FileNameBuf2_
#define LOCAL_PrologMode LOCAL->PrologMode_
#define REMOTE_PrologMode(wid) REMOTE(wid)->PrologMode_
#define LOCAL_CritLocks LOCAL->CritLocks_
#define REMOTE_CritLocks(wid) REMOTE(wid)->CritLocks_
#ifdef ANALYST
#define LOCAL_opcount LOCAL->opcount_
#define REMOTE_opcount(wid) REMOTE(wid)->opcount_
#define LOCAL_2opcount LOCAL->2opcount_
#define REMOTE_2opcount(wid) REMOTE(wid)->2opcount_
#endif /* ANALYST */
#define LOCAL_s_dbg LOCAL->s_dbg_
#define REMOTE_s_dbg(wid) REMOTE(wid)->s_dbg_
#define LOCAL_matherror LOCAL->matherror_
#define REMOTE_matherror(wid) REMOTE(wid)->matherror_
#define LOCAL_heap_overflows LOCAL->heap_overflows_
#define REMOTE_heap_overflows(wid) REMOTE(wid)->heap_overflows_
#define LOCAL_total_heap_overflow_time LOCAL->total_heap_overflow_time_
#define REMOTE_total_heap_overflow_time(wid) REMOTE(wid)->total_heap_overflow_time_
#define LOCAL_stack_overflows LOCAL->stack_overflows_
#define REMOTE_stack_overflows(wid) REMOTE(wid)->stack_overflows_
#define LOCAL_total_stack_overflow_time LOCAL->total_stack_overflow_time_
#define REMOTE_total_stack_overflow_time(wid) REMOTE(wid)->total_stack_overflow_time_
#define LOCAL_delay_overflows LOCAL->delay_overflows_
#define REMOTE_delay_overflows(wid) REMOTE(wid)->delay_overflows_
#define LOCAL_total_delay_overflow_time LOCAL->total_delay_overflow_time_
#define REMOTE_total_delay_overflow_time(wid) REMOTE(wid)->total_delay_overflow_time_
#define LOCAL_trail_overflows LOCAL->trail_overflows_
#define REMOTE_trail_overflows(wid) REMOTE(wid)->trail_overflows_
#define LOCAL_total_trail_overflow_time LOCAL->total_trail_overflow_time_
#define REMOTE_total_trail_overflow_time(wid) REMOTE(wid)->total_trail_overflow_time_
#define LOCAL_atom_table_overflows LOCAL->atom_table_overflows_
#define REMOTE_atom_table_overflows(wid) REMOTE(wid)->atom_table_overflows_
#define LOCAL_total_atom_table_overflow_time LOCAL->total_atom_table_overflow_time_
#define REMOTE_total_atom_table_overflow_time(wid) REMOTE(wid)->total_atom_table_overflow_time_
#ifdef LOAD_DYLD
#define LOCAL_dl_errno LOCAL->dl_errno_
#define REMOTE_dl_errno(wid) REMOTE(wid)->dl_errno_
#endif
#ifdef LOW_LEVEL_TRACER
#define LOCAL_do_trace_primitives LOCAL->do_trace_primitives_
#define REMOTE_do_trace_primitives(wid) REMOTE(wid)->do_trace_primitives_
#endif

View File

@ -161,8 +161,6 @@ Functor STD_PROTO(EvalArg,(Term));
#define FL(X) ((double)(X))
#endif
extern yap_error_number Yap_matherror;
void STD_PROTO(Yap_InitConstExps,(void));
void STD_PROTO(Yap_InitUnaryExps,(void));
void STD_PROTO(Yap_InitBinaryExps,(void));
@ -190,8 +188,8 @@ inline static Term
Yap_FoundArithError(Term t, Term inp)
{
CACHE_REGS
if (Yap_Error_TYPE) {
Yap_Error(Yap_Error_TYPE, (inp ? inp : Yap_Error_Term), Yap_ErrorMessage);
if (LOCAL_Error_TYPE) {
Yap_Error(LOCAL_Error_TYPE, (inp ? inp : LOCAL_Error_Term), LOCAL_ErrorMessage);
P = FAILCODE;
return 0L;
}

View File

@ -49,7 +49,7 @@
/* is ptr a pointer to code space? */
#if USE_SYSTEM_MALLOC
#define ONCODE(ptr) (Addr(ptr) < Yap_GlobalBase || Addr(ptr) > Yap_TrailTop)
#define ONCODE(ptr) (Addr(ptr) < LOCAL_GlobalBase || Addr(ptr) > LOCAL_TrailTop)
#else
#define ONCODE(ptr) (Addr(ptr) < HeapTop && Addr(ptr) >= Yap_HeapBase)
#endif
@ -77,14 +77,10 @@
(CellPtr(B) < CellPtr(val) && CellPtr(val) <= \
LCL0 && HEAP_PTR(val))))
#if !defined(YAPOR) && !defined(THREADS)
extern char *Yap_bp;
#endif
#define MARK_BIT ((char)1)
#define RMARK_BIT ((char)2)
#define mcell(X) Yap_bp[(X)-(CELL *)Yap_GlobalBase]
#define mcell(X) LOCAL_bp[(X)-(CELL *)LOCAL_GlobalBase]
#define MARKED_PTR(P) MARKED_PTR__(P PASS_REGS)
#define UNMARKED_MARK(P, BP) UNMARKED_MARK__(P, BP PASS_REGS)
@ -103,7 +99,7 @@ MARKED_PTR__(CELL* ptr USES_REGS)
static inline Int
UNMARKED_MARK__(CELL* ptr, char *bp USES_REGS)
{
Int pos = ptr - (CELL *)Yap_GlobalBase;
Int pos = ptr - (CELL *)LOCAL_GlobalBase;
char t = bp[pos];
if (t & MARK_BIT) {
return TRUE;

View File

@ -1,5 +1,5 @@
/* This file, hglobals.h, was generated automatically by "yap -L misc/buildheap"
/* This file, hglobals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/GLOBALS instead */
@ -18,47 +18,93 @@
typedef struct global_data {
int Initialised_;
int InitialisedFromPL_;
int PL_Argc_;
char** PL_Argv_;
struct halt_hook* HaltHooks_;
int AllowLocalExpansion_;
int AllowGlobalExpansion_;
int AllowTrailExpansion_;
UInt SizeOfOverflow_;
UInt AGcThreshold_;
Agc_hook AGCHook_;
#if THREADS
UInt n_of_threads;
UInt NOfThreads_;
UInt n_of_threads_created;
UInt NOfThreadsCreated_;
UInt threads_total_time;
#endif
UInt ThreadsTotalTime_;
lockvar ThreadHandlesLock_;
#endif
#if defined(YAPOR) || defined(THREADS)
lockvar bgl;
lockvar BGL_;
#endif
int allow_local_expansion;
int allow_global_expansion;
int allow_trail_expansion;
UInt size_of_overflow;
UInt agc_last_call;
UInt agc_threshold;
Agc_hook agc_hook;
#ifdef THREADS
lockvar thread_handles_lock;
#endif
#if defined(YAPOR) || defined(TABLING)
struct global_optyap_data optyap_data;
struct local_data remote[MAX_WORKERS];
struct global_optyap_data optyap_data_;
#endif /* YAPOR || TABLING */
int PrologShouldHandleInterrupts_;
#if defined(THREADS)
pthread_t master_thread_;
#endif /* THREADS */
YP_FILE* stdout_;
YP_FILE* stderr_;
char** argv_;
int argc_;
#ifdef COROUTINING
ext_op attas_[attvars_ext+1];
#endif
int agc_calls_;
YAP_ULONG_LONG agc_collected_;
Int tot_agc_time_;
Int tot_agc_recovered_;
#if HAVE_MMAP
struct MMAP_ARRAY_BLOCK* mmap_arrays_;
#endif
#ifdef DEBUG
char Option_[20];
YP_FILE* logfile_;
int output_msg_;
#endif
Int ProfCalls_;
Int ProfGCs_;
Int ProfHGrows_;
Int ProfSGrows_;
Int ProfMallocs_;
Int ProfOn_;
Int ProfOns_;
struct RB_red_blk_node* ProfilerRoot_;
struct RB_red_blk_node* ProfilerNil_;
char* DIRNAME_;
#if defined(COFF) || defined(A_OUT)
char Executable_[YAP_FILENAME_MAX];
#endif
#if __simplescalar__
char pwd_[YAP_FILENAME_MAX];
#endif
int initialised;
int initialised_from_pl;
int pl_argc;
char **pl_argv;
struct halt_hook *yap_halt_hook;
} w_shared;

View File

@ -1,145 +1,185 @@
/* This file, hlocals.h, was generated automatically by "yap -L misc/buildheap"
/* This file, hlocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/LOCALS instead */
typedef struct worker_local {
int c_input_stream;
int c_output_stream;
int c_error_stream;
int c_input_stream_;
int c_output_stream_;
int c_error_stream_;
restoreinfo rinfo;
CELL* OldASP_;
CELL* OldLCL0_;
tr_fr_ptr OldTR_;
CELL* OldGlobalBase_;
CELL* OldH_;
CELL* OldH0_;
ADDR OldTrailBase_;
ADDR OldTrailTop_;
ADDR OldHeapBase_;
ADDR OldHeapTop_;
Int ClDiff_;
Int GDiff_;
Int HDiff_;
Int GDiff0_;
CELL* GSplit_;
Int LDiff_;
Int TrDiff_;
Int XDiff_;
Int DelayDiff_;
Int BaseDiff_;
YAP_ULONG_LONG ReductionsCounter_;
YAP_ULONG_LONG PredEntriesCounter_;
YAP_ULONG_LONG RetriesCounter_;
int ReductionsCounterOn_;
int PredEntriesCounterOn_;
int RetriesCounterOn_;
union CONSULT_OBJ* ConsultSp_;
UInt ConsultCapacity_;
union CONSULT_OBJ* ConsultBase_;
union CONSULT_OBJ* ConsultLow_;
struct reduction_counters call_counters;
int interrupts_disabled;
union CONSULT_OBJ* consultsp;
UInt consultcapacity;
union CONSULT_OBJ* consultbase;
union CONSULT_OBJ* consultlow;
Term global_arena;
UInt global_arena_overflows;
Int delay_arena_overflows;
Int arena_overflows;
Int depth_arenas;
int arith_error;
struct pred_entry* last_asserted_pred;
int debug_on;
struct format_status* f_info;
char* scanner_stack;
struct scanner_extra_alloc* scanner_extra_blocks;
struct DB_TERM *ball_term;
UInt active_signals;
UInt i_pred_arity;
yamop* prof_end;
int uncaught_throw;
int doing_undefp;
Int start_line;
scratch_block scratchpad;
Term GlobalArena_;
UInt GlobalArenaOverflows_;
Int ArenaOverflows_;
Int DepthArenas_;
int ArithError_;
struct pred_entry* LastAssertedPred_;
int DebugOn_;
char* ScannerStack_;
struct scanner_extra_alloc* ScannerExtraBlocks_;
struct DB_TERM* BallTerm_;
UInt ActiveSignals_;
UInt IPredArity_;
yamop* ProfEnd_;
int UncaughtThrow_;
int DoingUndefp_;
Int StartLine_;
scratch_block ScratchPad_;
#ifdef COROUTINING
Term woken_goals;
Term atts_mutable_list;
Term WokenGoals_;
Term AttsMutableList_;
#endif
Term gc_generation;
Term gc_phase;
UInt gc_current_phase;
UInt gc_calls;
Int tot_gc_time;
YAP_ULONG_LONG tot_gc_recovered;
Int last_gc_time;
Int last_ss_time;
Term GcGeneration_;
Term GcPhase_;
UInt GcCurrentPhase_;
UInt GcCalls_;
Int TotGcTime_;
YAP_ULONG_LONG TotGcRecovered_;
Int LastGcTime_;
Int LastSSTime_;
Int total_marked_;
Int total_oldies_;
struct choicept* current_B_;
CELL* prev_HB_;
CELL* HGEN_;
CELL** iptop_;
#if defined(GC_NO_TAGS)
char* bp_;
#endif
tr_fr_ptr sTR_;
tr_fr_ptr sTR0_;
tr_fr_ptr new_TR_;
struct gc_mark_continuation* cont_top0_;
struct gc_mark_continuation* cont_top_;
int discard_trail_entries_;
gc_ma_hash_entry gc_ma_hash_table_[GC_MAVARS_HASH_SIZE];
gc_ma_hash_entry* gc_ma_h_top_;
gc_ma_hash_entry* gc_ma_h_list_;
UInt gc_timestamp_;
ADDR db_vec_;
ADDR db_vec0_;
struct RB_red_blk_node* db_root_;
struct RB_red_blk_node* db_nil_;
sigjmp_buf gc_restore_;
struct array_entry* DynamicArrays_;
struct static_array_entry* StaticArrays_;
struct global_entry* GlobalVariables_;
int AllowRestart_;
struct mem_blk* CMemFirstBlock_;
UInt CMemFirstBlockSz_;
Int* LabelFirstArray_;
UInt LabelFirstArraySz_;
struct PL_local_data* PL_local_data_p_;
#ifdef THREADS
struct thandle ThreadHandle_;
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
struct local_optyap_data optyap_data_;
#endif /* YAPOR || TABLING */
int InterruptsDisabled_;
struct open_query_struct* execution_;
#if LOW_LEVEL_TRACER
Int total_cps;
Int total_choicepoints_;
#endif
int consult_level_;
#if defined(YAPOR) || defined(THREADS)
lockvar signal_lock;
struct pred_entry* wpp;
Int tot_marked;
Int tot_oldies;
#if DEBUG && COROUTINING
UInt tot_smarked;
lockvar SignalLock_;
#endif
struct choicept *wl_current_B;
CELL* wl_prev_HB;
CELL* hgen;
CELL** ip_top;
#if GC_NO_TAGS
char* b_p;
#endif
#if defined(TABLING) || defined(YAPOR_SBA)
struct trail_frame* wl_sTR;
struct trail_frame* wl_sTR0;
struct trail_frame* new_tr;
#else
Term *wl_sTR;
Term *wl_sTR0;
Term *new_tr;
#endif
struct gc_mark_continuation* conttop0;
struct gc_mark_continuation* conttop;
int disc_trail_entries;
gc_ma_hash_entry Gc_ma_hash_table[GC_MAVARS_HASH_SIZE];
gc_ma_hash_entry* Gc_ma_h_top;
gc_ma_hash_entry* Gc_ma_h_list;
UInt Gc_timestamp;
ADDR DB_vec;
ADDR DB_vec0;
struct RB_red_blk_node* DB_root;
struct RB_red_blk_node* DB_nil;
#endif /* defined(YAPOR) || defined(THREADS) */
sigjmp_buf gc_restore;
struct array_entry* dynamic_arrays;
struct static_array_entry* static_arrays;
struct global_entry* global_variables;
int allow_restart;
struct mem_blk* cmem_first_block;
UInt cmem_first_block_sz;
Int* label_first_array;
UInt label_first_array_sz;
struct PL_local_data *Yap_ld_;
struct open_query_struct* _execution;
ADDR LocalBase_;
ADDR GlobalBase_;
ADDR TrailBase_;
ADDR TrailTop_;
char* ErrorMessage_;
Term Error_Term_;
#ifdef THREADS
struct thandle thread_handle;
#define FOREIGN_ThreadHandle(wid) (Yap_WLocal[(wid)]->thread_handle)
#define MY_ThreadHandle (Yap_WLocal[worker_id]->thread_handle)
Term Error_TYPE_;
#else
yap_error_number Error_TYPE_;
#endif
UInt Error_Size_;
char ErrorSay_[MAX_ERROR_MSG_SIZE];
jmp_buf IOBotch_;
TokEntry* tokptr_;
TokEntry* toktide_;
VarEntry* VarTable_;
VarEntry* AnonVarTable_;
sigjmp_buf RestartEnv_;
char FileNameBuf_[YAP_FILENAME_MAX];
char FileNameBuf2_[YAP_FILENAME_MAX];
Int PrologMode_;
int CritLocks_;
#ifdef ANALYST
YAP_ULONG_LONG opcount_[_std_top+1];
YAP_ULONG_LONG 2opcount[_std_top+1][_std_top+1]_;
#endif /* ANALYST */
struct db_globs* s_dbg_;
yap_error_number matherror_;
int heap_overflows_;
Int total_heap_overflow_time_;
int stack_overflows_;
Int total_stack_overflow_time_;
int delay_overflows_;
Int total_delay_overflow_time_;
int trail_overflows_;
Int total_trail_overflow_time_;
int atom_table_overflows_;
Int total_atom_table_overflow_time_;
#ifdef LOAD_DYLD
static dl_errno_;
#endif
#ifdef LOW_LEVEL_TRACER
int do_trace_primitives_;
#endif
} w_local;

View File

@ -1,5 +1,5 @@
/* This file, iglobals.h, was generated automatically by "yap -L misc/buildheap"
/* This file, iglobals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/GLOBALS instead */
@ -18,47 +18,93 @@
static void InitGlobal(void) {
GLOBAL_Initialised = FALSE;
GLOBAL_InitialisedFromPL = FALSE;
GLOBAL_PL_Argc = 0;
GLOBAL_PL_Argv = NULL;
GLOBAL_HaltHooks = NULL;
GLOBAL_AllowLocalExpansion = TRUE;
GLOBAL_AllowGlobalExpansion = TRUE;
GLOBAL_AllowTrailExpansion = TRUE;
GLOBAL_SizeOfOverflow = 0;
GLOBAL_AGcThreshold = 10000;
GLOBAL_AGCHook = NULL;
#if THREADS
Yap_global->n_of_threads = 1;
GLOBAL_NOfThreads = 1;
Yap_global->n_of_threads_created = 1;
GLOBAL_NOfThreadsCreated = 1;
Yap_global->threads_total_time = 0L;
#endif
GLOBAL_ThreadsTotalTime = 0L;
INIT_LOCK(GLOBAL_ThreadHandlesLock);
#endif
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_global->bgl);
INIT_LOCK(GLOBAL_BGL);
#endif
Yap_global->allow_local_expansion = TRUE;
Yap_global->allow_global_expansion = TRUE;
Yap_global->allow_trail_expansion = TRUE;
Yap_global->size_of_overflow = 0;
Yap_global->agc_last_call = 0;
Yap_global->agc_threshold = 10000;
Yap_global->agc_hook = NULL;
#ifdef THREADS
INIT_LOCK(Yap_global->thread_handles_lock);
#endif
#if defined(YAPOR) || defined(TABLING)
#endif /* YAPOR || TABLING */
#if defined(THREADS)
#endif /* THREADS */
GLOBAL_stdout = stdout;
GLOBAL_stderr = stderr;
#ifdef COROUTINING
#endif
GLOBAL_tot_agc_time = 0;
GLOBAL_tot_agc_recovered = 0;
#if HAVE_MMAP
GLOBAL_mmap_arrays = NULL;
#endif
#ifdef DEBUG
GLOBAL_output_msg = FALSE;
#endif
GLOBAL_DIRNAME = NULL;
#if defined(COFF) || defined(A_OUT)
#endif
#if __simplescalar__
#endif
Yap_global->initialised = FALSE;
Yap_global->initialised_from_pl = FALSE;
Yap_global->pl_argc = 0;
Yap_global->pl_argv = NULL;
Yap_global->yap_halt_hook = NULL;
}

View File

@ -35,7 +35,7 @@
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_heap_regs->dlmalloc_lock);
INIT_LOCK(DLMallocLock);
#endif
#endif
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
@ -51,10 +51,10 @@
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_heap_regs->free_blocks_lock);
INIT_LOCK(Yap_heap_regs->heap_used_lock);
INIT_LOCK(Yap_heap_regs->heap_top_lock);
Yap_heap_regs->heap_top_owner = -1;
INIT_LOCK(FreeBlocksLock);
INIT_LOCK(HeapUsedLock);
INIT_LOCK(HeapTopLock);
HeapTopOwner = -1;
#endif
@ -62,13 +62,13 @@
#endif
Yap_heap_regs->execute_cpred_op_code = Yap_opcode(_execute_cpred);
Yap_heap_regs->expand_op_code = Yap_opcode(_expand_index);
Yap_heap_regs->fail_op = Yap_opcode(_op_fail);
Yap_heap_regs->index_op = Yap_opcode(_index_pred);
Yap_heap_regs->lockpred_op = Yap_opcode(_lock_pred);
Yap_heap_regs->orlast_op = Yap_opcode(_or_last);
Yap_heap_regs->undef_op = Yap_opcode(_undef_p);
EXECUTE_CPRED_OP_CODE = Yap_opcode(_execute_cpred);
EXPAND_OP_CODE = Yap_opcode(_expand_index);
FAIL_OPCODE = Yap_opcode(_op_fail);
INDEX_OPCODE = Yap_opcode(_index_pred);
LOCKPRED_OPCODE = Yap_opcode(_lock_pred);
ORLAST_OPCODE = Yap_opcode(_or_last);
UNDEF_OPCODE = Yap_opcode(_undef_p);
@ -80,100 +80,100 @@
#include "iatoms.h"
#ifdef EUROTRA
Yap_heap_regs->term_dollar_u = MkAtomTerm(AtomDollarU);
TermDollarU = MkAtomTerm(AtomDollarU);
#endif
Yap_heap_regs->term_prolog = MkAtomTerm(AtomProlog);
Yap_heap_regs->term_refound_var = MkAtomTerm(AtomRefoundVar);
Yap_heap_regs->user_module = MkAtomTerm(AtomUser);
Yap_heap_regs->idb_module = MkAtomTerm(AtomIDB);
Yap_heap_regs->attributes_module = MkAtomTerm(AtomAttributes);
Yap_heap_regs->charsio_module = MkAtomTerm(AtomCharsio);
Yap_heap_regs->terms_module = MkAtomTerm(AtomTerms);
Yap_heap_regs->system_module = MkAtomTerm(AtomSystem);
Yap_heap_regs->operating_system_module = MkAtomTerm(AtomOperatingSystemSupport);
Yap_heap_regs->readutil_module = MkAtomTerm(AtomReadutil);
Yap_heap_regs->hacks_module = MkAtomTerm(AtomYapHacks);
Yap_heap_regs->arg_module = MkAtomTerm(AtomArg);
Yap_heap_regs->globals_module = MkAtomTerm(AtomNb);
Yap_heap_regs->swi_module = MkAtomTerm(AtomSwi);
Yap_heap_regs->dbload_module = MkAtomTerm(AtomDBLoad);
TermProlog = MkAtomTerm(AtomProlog);
TermReFoundVar = MkAtomTerm(AtomRefoundVar);
USER_MODULE = MkAtomTerm(AtomUser);
IDB_MODULE = MkAtomTerm(AtomIDB);
ATTRIBUTES_MODULE = MkAtomTerm(AtomAttributes);
CHARSIO_MODULE = MkAtomTerm(AtomCharsio);
TERMS_MODULE = MkAtomTerm(AtomTerms);
SYSTEM_MODULE = MkAtomTerm(AtomSystem);
OPERATING_SYSTEM_MODULE = MkAtomTerm(AtomOperatingSystemSupport);
READUTIL_MODULE = MkAtomTerm(AtomReadutil);
HACKS_MODULE = MkAtomTerm(AtomYapHacks);
ARG_MODULE = MkAtomTerm(AtomArg);
GLOBALS_MODULE = MkAtomTerm(AtomNb);
SWI_MODULE = MkAtomTerm(AtomSwi);
DBLOAD_MODULE = MkAtomTerm(AtomDBLoad);
Yap_heap_regs->current_modules = NULL;
CurrentModules = NULL;
Yap_InitModules();
Yap_heap_regs->execution_mode = INTERPRETED;
Yap_ExecutionMode = INTERPRETED;
InitPredHash();
#if defined(YAPOR) || defined(THREADS)
#endif
Yap_heap_regs->preds_in_hash_table = 0;
PredsInHashTable = 0;
Yap_heap_regs->creep_code = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomCreep,1),PROLOG_MODULE));
Yap_heap_regs->undef_code = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomUndefp,1),PROLOG_MODULE));
Yap_heap_regs->spy_code = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomSpy,1),PROLOG_MODULE));
Yap_heap_regs->pred_fail = RepPredProp(PredPropByAtom(AtomFail,PROLOG_MODULE));
Yap_heap_regs->pred_true = RepPredProp(PredPropByAtom(AtomTrue,PROLOG_MODULE));
CreepCode = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomCreep,1),PROLOG_MODULE));
UndefCode = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomUndefp,1),PROLOG_MODULE));
SpyCode = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomSpy,1),PROLOG_MODULE));
PredFail = RepPredProp(PredPropByAtom(AtomFail,PROLOG_MODULE));
PredTrue = RepPredProp(PredPropByAtom(AtomTrue,PROLOG_MODULE));
#ifdef COROUTINING
Yap_heap_regs->wake_up_code = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomWakeUpGoal,2),PROLOG_MODULE));
WakeUpCode = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomWakeUpGoal,2),PROLOG_MODULE));
#endif
Yap_heap_regs->pred_goal_expansion = RepPredProp(PredPropByFunc(FunctorGoalExpansion,USER_MODULE));
Yap_heap_regs->pred_meta_call = RepPredProp(PredPropByFunc(FunctorMetaCall,PROLOG_MODULE));
Yap_heap_regs->pred_dollar_catch = RepPredProp(PredPropByFunc(FunctorCatch,PROLOG_MODULE));
Yap_heap_regs->pred_recorded_with_key = RepPredProp(PredPropByFunc(FunctorRecordedWithKey,PROLOG_MODULE));
Yap_heap_regs->pred_log_upd_clause = RepPredProp(PredPropByFunc(FunctorDoLogUpdClause,PROLOG_MODULE));
Yap_heap_regs->pred_log_upd_clause_erase = RepPredProp(PredPropByFunc(FunctorDoLogUpdClauseErase,PROLOG_MODULE));
Yap_heap_regs->pred_log_upd_clause0 = RepPredProp(PredPropByFunc(FunctorDoLogUpdClause,PROLOG_MODULE));
Yap_heap_regs->pred_static_clause = RepPredProp(PredPropByFunc(FunctorDoStaticClause,PROLOG_MODULE));
Yap_heap_regs->pred_throw = RepPredProp(PredPropByFunc(FunctorThrow,PROLOG_MODULE));
Yap_heap_regs->pred_handle_throw = RepPredProp(PredPropByFunc(FunctorHandleThrow,PROLOG_MODULE));
Yap_heap_regs->pred_is = RepPredProp(PredPropByFunc(FunctorIs,PROLOG_MODULE));
Yap_heap_regs->pred_safe_call_cleanup = RepPredProp(PredPropByFunc(FunctorSafeCallCleanup,PROLOG_MODULE));
Yap_heap_regs->pred_restore_regs = RepPredProp(PredPropByFunc(FunctorRestoreRegs,PROLOG_MODULE));
PredGoalExpansion = RepPredProp(PredPropByFunc(FunctorGoalExpansion,USER_MODULE));
PredMetaCall = RepPredProp(PredPropByFunc(FunctorMetaCall,PROLOG_MODULE));
PredDollarCatch = RepPredProp(PredPropByFunc(FunctorCatch,PROLOG_MODULE));
PredRecordedWithKey = RepPredProp(PredPropByFunc(FunctorRecordedWithKey,PROLOG_MODULE));
PredLogUpdClause = RepPredProp(PredPropByFunc(FunctorDoLogUpdClause,PROLOG_MODULE));
PredLogUpdClauseErase = RepPredProp(PredPropByFunc(FunctorDoLogUpdClauseErase,PROLOG_MODULE));
PredLogUpdClause0 = RepPredProp(PredPropByFunc(FunctorDoLogUpdClause,PROLOG_MODULE));
PredStaticClause = RepPredProp(PredPropByFunc(FunctorDoStaticClause,PROLOG_MODULE));
PredThrow = RepPredProp(PredPropByFunc(FunctorThrow,PROLOG_MODULE));
PredHandleThrow = RepPredProp(PredPropByFunc(FunctorHandleThrow,PROLOG_MODULE));
PredIs = RepPredProp(PredPropByFunc(FunctorIs,PROLOG_MODULE));
PredSafeCallCleanup = RepPredProp(PredPropByFunc(FunctorSafeCallCleanup,PROLOG_MODULE));
PredRestoreRegs = RepPredProp(PredPropByFunc(FunctorRestoreRegs,PROLOG_MODULE));
#ifdef YAPOR
Yap_heap_regs->pred_getwork = RepPredProp(PredPropByAtom(AtomGetwork,PROLOG_MODULE));
Yap_heap_regs->pred_getwork_seq = RepPredProp(PredPropByAtom(AtomGetworkSeq,PROLOG_MODULE));
PredGetwork = RepPredProp(PredPropByAtom(AtomGetwork,PROLOG_MODULE));
PredGetworkSeq = RepPredProp(PredPropByAtom(AtomGetworkSeq,PROLOG_MODULE));
#endif /* YAPOR */
#ifdef LOW_LEVEL_TRACER
Yap_heap_regs->yap_do_low_level_trace = FALSE;
Yap_do_low_level_trace = FALSE;
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_heap_regs->low_level_trace_lock);
INIT_LOCK(Yap_low_level_trace_lock);
#endif
#endif
Yap_heap_regs->clause_space = 0;
Yap_heap_regs->index_space_Tree = 0;
Yap_heap_regs->index_space_EXT = 0;
Yap_heap_regs->index_space_SW = 0;
Yap_heap_regs->lu_clause_space = 0;
Yap_heap_regs->lu_index_space_Tree = 0;
Yap_heap_regs->lu_index_space_CP = 0;
Yap_heap_regs->lu_index_space_EXT = 0;
Yap_heap_regs->lu_index_space_SW = 0;
Yap_ClauseSpace = 0;
Yap_IndexSpace_Tree = 0;
Yap_IndexSpace_EXT = 0;
Yap_IndexSpace_SW = 0;
Yap_LUClauseSpace = 0;
Yap_LUIndexSpace_Tree = 0;
Yap_LUIndexSpace_CP = 0;
Yap_LUIndexSpace_EXT = 0;
Yap_LUIndexSpace_SW = 0;
Yap_heap_regs->dummycode->opc = Yap_opcode(_op_fail);
Yap_heap_regs->failcode->opc = Yap_opcode(_op_fail);
Yap_heap_regs->nocode->opc = Yap_opcode(_Nstop);
DUMMYCODE->opc = Yap_opcode(_op_fail);
FAILCODE->opc = Yap_opcode(_op_fail);
NOCODE->opc = Yap_opcode(_Nstop);
InitEnvInst(ENV_FOR_TRUSTFAIL,&TRUSTFAILCODE,_trust_fail,PredFail);
InitEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail);
InitOtaplInst(RTRYCODE,_retry_and_mark,PredFail);
#ifdef BEAM
Yap_heap_regs->beam_retry_code->opc = Yap_opcode(_beam_retry_code);
BEAM_RETRY_CODE->opc = Yap_opcode(_beam_retry_code);
#endif /* BEAM */
#ifdef YAPOR
Yap_heap_regs->seq_def = FALSE;
SEQUENTIAL_IS_DEFAULT = FALSE;
InitOtaplInst(GETWORK,_getwork,PredGetwork);
InitOtaplInst(GETWORK_SEQ,_getwork_seq,PredGetworkSeq);
Yap_heap_regs->getwork_first_time->opc = Yap_opcode(_getwork_first_time);
GETWORK_FIRST_TIME->opc = Yap_opcode(_getwork_first_time);
#endif /* YAPOR */
#ifdef TABLING
InitOtaplInst(LOAD_ANSWER,_table_load_answer,PredFail);
@ -185,121 +185,121 @@
Yap_heap_regs->debugger_p_before_spy = NULL;
P_before_spy = NULL;
Yap_heap_regs->retry_recordedp_code = NULL;
Yap_heap_regs->retry_recorded_k_code = NULL;
RETRY_C_RECORDEDP_CODE = NULL;
RETRY_C_RECORDED_K_CODE = NULL;
Yap_heap_regs->system_profiling = FALSE;
Yap_heap_regs->system_call_counting = FALSE;
Yap_heap_regs->system_pred_goal_expansion_all = FALSE;
Yap_heap_regs->system_pred_goal_expansion_func = FALSE;
Yap_heap_regs->system_pred_goal_expansion_on = FALSE;
Yap_heap_regs->compiler_optimizer_on = TRUE;
Yap_heap_regs->compiler_compile_mode = 0;
Yap_heap_regs->compiler_profiling = FALSE;
Yap_heap_regs->compiler_call_counting = FALSE;
PROFILING = FALSE;
CALL_COUNTING = FALSE;
PRED_GOAL_EXPANSION_ALL = FALSE;
PRED_GOAL_EXPANSION_FUNC = FALSE;
PRED_GOAL_EXPANSION_ON = FALSE;
optimizer_on = TRUE;
compile_mode = 0;
profiling = FALSE;
call_counting = FALSE;
Yap_heap_regs->compiler_compile_arrays = FALSE;
compile_arrays = FALSE;
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_heap_regs->dbterms_list_lock);
INIT_LOCK(DBTermsListLock);
#endif
Yap_heap_regs->dbterms_list = NULL;
DBTermsList = NULL;
Yap_heap_regs->expand_clauses_first = NULL;
Yap_heap_regs->expand_clauses_last = NULL;
Yap_heap_regs->expand_clauses = 0;
ExpandClausesFirst = NULL;
ExpandClausesLast = NULL;
Yap_ExpandClauses = 0;
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_heap_regs->expand_clauses_list_lock);
INIT_LOCK(Yap_heap_regs->op_list_lock);
INIT_LOCK(ExpandClausesListLock);
INIT_LOCK(OpListLock);
#endif
#ifdef DEBUG
Yap_heap_regs->new_cps = 0L;
Yap_heap_regs->live_cps = 0L;
Yap_heap_regs->dirty_cps = 0L;
Yap_heap_regs->freed_cps = 0L;
Yap_NewCps = 0L;
Yap_LiveCps = 0L;
Yap_DirtyCps = 0L;
Yap_FreedCps = 0L;
#endif
Yap_heap_regs->expand_clauses_sz = 0L;
Yap_expand_clauses_sz = 0L;
Yap_heap_regs->udi_control_blocks = NULL;
UdiControlBlocks = NULL;
Yap_heap_regs->static_predicates_marked = FALSE;
STATIC_PREDICATES_MARKED = FALSE;
Yap_heap_regs->IntKeys = NULL;
Yap_heap_regs->IntLUKeys = NULL;
Yap_heap_regs->IntBBKeys = NULL;
INT_KEYS = NULL;
INT_LU_KEYS = NULL;
INT_BB_KEYS = NULL;
Yap_heap_regs->int_keys_size = INT_KEYS_DEFAULT_SIZE;
Yap_heap_regs->int_keys_timestamp = 0L;
Yap_heap_regs->int_bb_keys_size = INT_KEYS_DEFAULT_SIZE;
INT_KEYS_SIZE = INT_KEYS_DEFAULT_SIZE;
INT_KEYS_TIMESTAMP = 0L;
INT_BB_KEYS_SIZE = INT_KEYS_DEFAULT_SIZE;
Yap_heap_regs->update_mode = UPDATE_MODE_LOGICAL;
UPDATE_MODE = UPDATE_MODE_LOGICAL;
InitDBErasedMarker();
InitLogDBErasedMarker();
Yap_heap_regs->dead_static_clauses = NULL;
Yap_heap_regs->dead_mega_clauses = NULL;
Yap_heap_regs->dead_static_indices = NULL;
Yap_heap_regs->db_erased_list = NULL;
Yap_heap_regs->db_erased_ilist = NULL;
DeadStaticClauses = NULL;
DeadMegaClauses = NULL;
DeadStaticIndices = NULL;
DBErasedList = NULL;
DBErasedIList = NULL;
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_heap_regs->dead_static_clauses_lock);
INIT_LOCK(Yap_heap_regs->dead_mega_clauses_lock);
INIT_LOCK(Yap_heap_regs->dead_static_indices_lock);
INIT_LOCK(DeadStaticClausesLock);
INIT_LOCK(DeadMegaClausesLock);
INIT_LOCK(DeadStaticIndicesLock);
#endif
#ifdef COROUTINING
Yap_heap_regs->num_of_atts = 1;
NUM_OF_ATTS = 1;
#endif
InitFlags();
Yap_heap_regs->op_list = NULL;
OpList = NULL;
Yap_heap_regs->yap_streams = NULL;
Stream = NULL;
Yap_heap_regs->n_of_file_aliases = 0;
Yap_heap_regs->sz_of_file_aliases = 0;
Yap_heap_regs->file_aliases = NULL;
NOfFileAliases = 0;
SzOfFileAliases = 0;
FileAliases = NULL;
Yap_heap_regs->atprompt = AtomNil;
AtPrompt = AtomNil;
Yap_heap_regs->char_conversion_table = NULL;
Yap_heap_regs->char_conversion_table2 = NULL;
CharConversionTable = NULL;
CharConversionTable2 = NULL;
Yap_heap_regs->parser_error_style = EXCEPTION_ON_PARSER_ERROR;
ParserErrorStyle = EXCEPTION_ON_PARSER_ERROR;
Yap_heap_regs->yap_lib_dir = NULL;
Yap_LibDir = NULL;
Yap_heap_regs->last_wtime = NULL;
LastWtimePtr = NULL;
Yap_heap_regs->debugger_output_msg = 0L;
output_msg = 0L;
#if LOW_PROF
Yap_heap_regs->profiler_on = FALSE;
Yap_heap_regs->offline_profiler = FALSE;
Yap_heap_regs->f_prof = NULL;
Yap_heap_regs->f_preds = NULL;
Yap_heap_regs->prof_preds = 0L;
ProfilerOn = FALSE;
Yap_OffLineProfiler = FALSE;
FProf = NULL;
FPreds = NULL;
ProfPreds = 0L;
#endif /* LOW_PROF */
Yap_heap_regs->foreign_code_loaded = NULL;
Yap_heap_regs->foreign_code_base = NULL;
Yap_heap_regs->foreign_code_top = NULL;
Yap_heap_regs->foreign_code_max = NULL;
ForeignCodeLoaded = NULL;
ForeignCodeBase = NULL;
ForeignCodeTop = NULL;
ForeignCodeMax = NULL;
Yap_heap_regs->yap_records = NULL;
Yap_Records = NULL;
InitSWIAtoms();
Yap_heap_regs->swi_blob_types = NULL;
Yap_heap_regs->swi_blobs = NULL;
SWI_BlobTypes = NULL;
SWI_Blobs = NULL;

View File

@ -1,143 +1,185 @@
/* This file, ilocals.h, was generated automatically by "yap -L misc/buildheap"
/* This file, ilocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/LOCALS instead */
static void InitWorker(int wid) {
FOREIGN(wid)->c_input_stream = 0;
FOREIGN(wid)->c_output_stream = 1;
FOREIGN(wid)->c_error_stream = 2;
REMOTE_c_input_stream(wid) = 0;
REMOTE_c_output_stream(wid) = 1;
REMOTE_c_error_stream(wid) = 2;
FOREIGN(wid)->rinfo.old_ASP = NULL;
FOREIGN(wid)->rinfo.old_LCL0 = NULL;
FOREIGN(wid)->rinfo.old_TR = NULL;
FOREIGN(wid)->rinfo.old_GlobalBase = NULL;
FOREIGN(wid)->rinfo.old_H = NULL;
FOREIGN(wid)->rinfo.old_H0 = NULL;
FOREIGN(wid)->rinfo.old_TrailBase = NULL;
FOREIGN(wid)->rinfo.old_TrailTop = NULL;
FOREIGN(wid)->rinfo.old_HeapBase = NULL;
FOREIGN(wid)->rinfo.old_HeapTop = NULL;
FOREIGN(wid)->rinfo.cl_diff = 0L;
FOREIGN(wid)->rinfo.g_diff = 0L;
FOREIGN(wid)->rinfo.h_diff = 0L;
FOREIGN(wid)->rinfo.g_diff0 = 0L;
FOREIGN(wid)->rinfo.g_split = NULL;
FOREIGN(wid)->rinfo.l_diff = 0L;
FOREIGN(wid)->rinfo.tr_diff = 0L;
FOREIGN(wid)->rinfo.x_diff = 0L;
FOREIGN(wid)->rinfo.delay_diff = 0L;
FOREIGN(wid)->rinfo.base_diff = 0L;
FOREIGN(wid)->call_counters.reductions = 0L;
FOREIGN(wid)->call_counters.reductions_retries = 0L;
FOREIGN(wid)->call_counters.retries = 0L;
FOREIGN(wid)->call_counters.reductions_on = 0L;
FOREIGN(wid)->call_counters.reductions_retries_on = 0L;
FOREIGN(wid)->call_counters.retries_on = 0L;
FOREIGN(wid)->interrupts_disabled = FALSE;
REMOTE_OldASP(wid) = NULL;
REMOTE_OldLCL0(wid) = NULL;
REMOTE_OldTR(wid) = NULL;
REMOTE_OldGlobalBase(wid) = NULL;
REMOTE_OldH(wid) = NULL;
REMOTE_OldH0(wid) = NULL;
REMOTE_OldTrailBase(wid) = NULL;
REMOTE_OldTrailTop(wid) = NULL;
REMOTE_OldHeapBase(wid) = NULL;
REMOTE_OldHeapTop(wid) = NULL;
REMOTE_ClDiff(wid) = 0L;
REMOTE_GDiff(wid) = 0L;
REMOTE_HDiff(wid) = 0L;
REMOTE_GDiff0(wid) = 0L;
REMOTE_GSplit(wid) = NULL;
REMOTE_LDiff(wid) = 0L;
REMOTE_TrDiff(wid) = 0L;
REMOTE_XDiff(wid) = 0L;
REMOTE_DelayDiff(wid) = 0L;
REMOTE_BaseDiff(wid) = 0L;
REMOTE_ReductionsCounter(wid) = 0L;
REMOTE_PredEntriesCounter(wid) = 0L;
REMOTE_RetriesCounter(wid) = 0L;
REMOTE_ReductionsCounterOn(wid) = 0L;
REMOTE_PredEntriesCounterOn(wid) = 0L;
REMOTE_RetriesCounterOn(wid) = 0L;
FOREIGN(wid)->consultsp = NULL;
REMOTE_ConsultSp(wid) = NULL;
FOREIGN(wid)->consultbase = NULL;
REMOTE_ConsultBase(wid) = NULL;
FOREIGN(wid)->consultlow = NULL;
REMOTE_ConsultLow(wid) = NULL;
FOREIGN(wid)->global_arena = 0L;
FOREIGN(wid)->global_arena_overflows = 0L;
FOREIGN(wid)->delay_arena_overflows = 0L;
FOREIGN(wid)->arena_overflows = 0L;
FOREIGN(wid)->depth_arenas = 0;
FOREIGN(wid)->arith_error = FALSE;
FOREIGN(wid)->last_asserted_pred = NULL;
FOREIGN(wid)->debug_on = FALSE;
FOREIGN(wid)->f_info = NULL;
FOREIGN(wid)->scanner_stack = NULL;
FOREIGN(wid)->scanner_extra_blocks = NULL;
FOREIGN(wid)->ball_term = NULL;
FOREIGN(wid)->active_signals = 0L;
FOREIGN(wid)->i_pred_arity = 0L;
FOREIGN(wid)->prof_end = NULL;
FOREIGN(wid)->uncaught_throw = FALSE;
FOREIGN(wid)->doing_undefp = FALSE;
FOREIGN(wid)->start_line = 0L;
REMOTE_GlobalArena(wid) = 0L;
REMOTE_GlobalArenaOverflows(wid) = 0L;
REMOTE_ArenaOverflows(wid) = 0L;
REMOTE_DepthArenas(wid) = 0;
REMOTE_ArithError(wid) = FALSE;
REMOTE_LastAssertedPred(wid) = NULL;
REMOTE_DebugOn(wid) = FALSE;
REMOTE_ScannerStack(wid) = NULL;
REMOTE_ScannerExtraBlocks(wid) = NULL;
REMOTE_BallTerm(wid) = NULL;
REMOTE_ActiveSignals(wid) = 0L;
REMOTE_IPredArity(wid) = 0L;
REMOTE_ProfEnd(wid) = NULL;
REMOTE_UncaughtThrow(wid) = FALSE;
REMOTE_DoingUndefp(wid) = FALSE;
REMOTE_StartLine(wid) = 0L;
InitScratchPad(wid);
#ifdef COROUTINING
FOREIGN(wid)->woken_goals = 0L;
FOREIGN(wid)->atts_mutable_list = 0L;
REMOTE_WokenGoals(wid) = 0L;
REMOTE_AttsMutableList(wid) = 0L;
#endif
FOREIGN(wid)->gc_generation = 0L;
FOREIGN(wid)->gc_phase = 0L;
FOREIGN(wid)->gc_current_phase = 0L;
FOREIGN(wid)->gc_calls = 0L;
FOREIGN(wid)->tot_gc_time = 0L;
FOREIGN(wid)->tot_gc_recovered = 0L;
FOREIGN(wid)->last_gc_time = 0L;
FOREIGN(wid)->last_ss_time = 0L;
#if LOW_LEVEL_TRACER
FOREIGN(wid)->total_cps = 0;
REMOTE_GcGeneration(wid) = 0L;
REMOTE_GcPhase(wid) = 0L;
REMOTE_GcCurrentPhase(wid) = 0L;
REMOTE_GcCalls(wid) = 0L;
REMOTE_TotGcTime(wid) = 0L;
REMOTE_TotGcRecovered(wid) = 0L;
REMOTE_LastGcTime(wid) = 0L;
REMOTE_LastSSTime(wid) = 0L;
REMOTE_total_marked(wid) = 0L;
REMOTE_total_oldies(wid) = 0L;
REMOTE_current_B(wid) = NULL;
REMOTE_prev_HB(wid) = NULL;
REMOTE_HGEN(wid) = NULL;
REMOTE_iptop(wid) = NULL;
#if defined(GC_NO_TAGS)
REMOTE_bp(wid) = NULL;
#endif
FOREIGN(wid)->consult_level_ = 0;
REMOTE_sTR(wid) = NULL;
REMOTE_sTR0(wid) = NULL;
REMOTE_new_TR(wid) = NULL;
REMOTE_cont_top0(wid) = NULL;
REMOTE_cont_top(wid) = NULL;
REMOTE_discard_trail_entries(wid) = 0;
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(FOREIGN(wid)->signal_lock);
FOREIGN(wid)->wpp = NULL;
REMOTE_gc_ma_h_top(wid) = NULL;
REMOTE_gc_ma_h_list(wid) = NULL;
REMOTE_gc_timestamp(wid) = 0L;
REMOTE_db_vec(wid) = NULL;
REMOTE_db_vec0(wid) = NULL;
REMOTE_db_root(wid) = NULL;
REMOTE_db_nil(wid) = NULL;
FOREIGN(wid)->tot_marked = 0L;
FOREIGN(wid)->tot_oldies = 0L;
#if DEBUG && COROUTINING
FOREIGN(wid)->tot_smarked = 0L;
#endif
FOREIGN(wid)->wl_current_B = NULL;
FOREIGN(wid)->wl_prev_HB = NULL;
FOREIGN(wid)->hgen = NULL;
FOREIGN(wid)->ip_top = NULL;
#if GC_NO_TAGS
FOREIGN(wid)->b_p = NULL;
#endif
#if defined(TABLING) || defined(YAPOR_SBA)
FOREIGN(wid)->wl_sTR = NULL;
FOREIGN(wid)->wl_sTR0 = NULL;
FOREIGN(wid)->new_tr = NULL;
#else
FOREIGN(wid)->wl_sTR = NULL;
FOREIGN(wid)->wl_sTR0 = NULL;
FOREIGN(wid)->new_tr = NULL;
#endif
FOREIGN(wid)->conttop0 = NULL;
FOREIGN(wid)->conttop = NULL;
FOREIGN(wid)->disc_trail_entries = 0;
REMOTE_DynamicArrays(wid) = NULL;
REMOTE_StaticArrays(wid) = NULL;
REMOTE_GlobalVariables(wid) = NULL;
REMOTE_AllowRestart(wid) = FALSE;
FOREIGN(wid)->Gc_ma_h_top = NULL;
FOREIGN(wid)->Gc_ma_h_list = NULL;
FOREIGN(wid)->Gc_timestamp = 0L;
FOREIGN(wid)->DB_vec = NULL;
FOREIGN(wid)->DB_vec0 = NULL;
FOREIGN(wid)->DB_root = NULL;
FOREIGN(wid)->DB_nil = NULL;
#endif /* defined(YAPOR) || defined(THREADS) */
REMOTE_CMemFirstBlock(wid) = NULL;
REMOTE_CMemFirstBlockSz(wid) = 0L;
FOREIGN(wid)->dynamic_arrays = NULL;
FOREIGN(wid)->static_arrays = NULL;
FOREIGN(wid)->global_variables = NULL;
FOREIGN(wid)->allow_restart = FALSE;
REMOTE_LabelFirstArray(wid) = NULL;
REMOTE_LabelFirstArraySz(wid) = 0L;
FOREIGN(wid)->cmem_first_block = NULL;
FOREIGN(wid)->cmem_first_block_sz = 0L;
FOREIGN(wid)->label_first_array = NULL;
FOREIGN(wid)->label_first_array_sz = 0L;
FOREIGN(wid)->Yap_ld_ = Yap_InitThreadIO(wid);
FOREIGN(wid)->_execution = NULL;
REMOTE_PL_local_data_p(wid) = Yap_InitThreadIO(wid);
#ifdef THREADS
InitThreadHandle(wid);
#define FOREIGN_ThreadHandle(wid) (Yap_WLocal[(wid)]->thread_handle)
#define MY_ThreadHandle (Yap_WLocal[worker_id]->thread_handle)
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
Yap_init_local_optyap_data(wid);
#endif /* YAPOR || TABLING */
REMOTE_InterruptsDisabled(wid) = FALSE;
REMOTE_execution(wid) = NULL;
#if LOW_LEVEL_TRACER
REMOTE_total_choicepoints(wid) = 0;
#endif
REMOTE_consult_level(wid) = 0;
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(REMOTE_SignalLock(wid));
#endif
#ifdef THREADS
#else
#endif
REMOTE_PrologMode(wid) = BootMode;
REMOTE_CritLocks(wid) = 0;
#ifdef ANALYST
#endif /* ANALYST */
REMOTE_matherror(wid) = YAP_NO_ERROR;
REMOTE_heap_overflows(wid) = 0;
REMOTE_total_heap_overflow_time(wid) = 0;
REMOTE_stack_overflows(wid) = 0;
REMOTE_total_stack_overflow_time(wid) = 0;
REMOTE_delay_overflows(wid) = 0;
REMOTE_total_delay_overflow_time(wid) = 0;
REMOTE_trail_overflows(wid) = 0;
REMOTE_total_trail_overflow_time(wid) = 0;
REMOTE_atom_table_overflows(wid) = 0;
REMOTE_total_atom_table_overflow_time(wid) = 0;
#ifdef LOAD_DYLD
REMOTE_dl_errno(wid) = 0;
#endif
#ifdef LOW_LEVEL_TRACER
REMOTE_do_trace_primitives(wid) = TRUE;
#endif
}

View File

@ -115,4 +115,5 @@ StreamDesc;
void STD_PROTO (Yap_InitStdStreams, (void));
Term STD_PROTO (Yap_StreamPosition, (struct io_stream *));
void STD_PROTO (Yap_InitPlIO, (void));

View File

@ -1,5 +1,5 @@
/* This file, rglobals.h, was generated automatically by "yap -L misc/buildheap"
/* This file, rglobals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/GLOBALS instead */
@ -18,10 +18,23 @@
static void RestoreGlobal(void) {
#if THREADS
@ -29,29 +42,31 @@ static void RestoreGlobal(void) {
#endif
REINIT_LOCK(GLOBAL_ThreadHandlesLock);
#endif
#if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_global->bgl);
REINIT_LOCK(GLOBAL_BGL);
#endif
#ifdef THREADS
REINIT_LOCK(Yap_global->thread_handles_lock);
#endif
#if defined(YAPOR) || defined(TABLING)
#endif /* YAPOR || TABLING */
#if defined(THREADS)
#endif /* THREADS */
#ifdef COROUTINING
#endif
@ -61,4 +76,35 @@ static void RestoreGlobal(void) {
#if HAVE_MMAP
#endif
#ifdef DEBUG
#endif
#if defined(COFF) || defined(A_OUT)
#endif
#if __simplescalar__
#endif
}

View File

@ -1016,9 +1016,9 @@ static void
RestoreBallTerm(int wid)
{
CACHE_REGS
if (BallTerm) {
BallTerm = DBTermAdjust(BallTerm);
RestoreDBTerm(BallTerm, TRUE PASS_REGS);
if (LOCAL_BallTerm) {
LOCAL_BallTerm = DBTermAdjust(LOCAL_BallTerm);
RestoreDBTerm(LOCAL_BallTerm, TRUE PASS_REGS);
}
}
@ -1030,7 +1030,7 @@ static void
restore_codes(void)
{
CACHE_REGS
Yap_heap_regs->heap_top = AddrAdjust(OldHeapTop);
Yap_heap_regs->heap_top = AddrAdjust(LOCAL_OldHeapTop);
#include "rhstruct.h"
RestoreGlobal();
#ifndef worker_id

View File

@ -35,7 +35,7 @@
#if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_heap_regs->dlmalloc_lock);
REINIT_LOCK(DLMallocLock);
#endif
#endif
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
@ -51,24 +51,24 @@
#if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_heap_regs->free_blocks_lock);
REINIT_LOCK(Yap_heap_regs->heap_used_lock);
REINIT_LOCK(Yap_heap_regs->heap_top_lock);
REINIT_LOCK(FreeBlocksLock);
REINIT_LOCK(HeapUsedLock);
REINIT_LOCK(HeapTopLock);
#endif
#if USE_THREADED_CODE
Yap_heap_regs->op_rtable = OpRTableAdjust(Yap_heap_regs->op_rtable);
OP_RTABLE = OpRTableAdjust(OP_RTABLE);
#endif
Yap_heap_regs->execute_cpred_op_code = Yap_opcode(_execute_cpred);
Yap_heap_regs->expand_op_code = Yap_opcode(_expand_index);
Yap_heap_regs->fail_op = Yap_opcode(_op_fail);
Yap_heap_regs->index_op = Yap_opcode(_index_pred);
Yap_heap_regs->lockpred_op = Yap_opcode(_lock_pred);
Yap_heap_regs->orlast_op = Yap_opcode(_or_last);
Yap_heap_regs->undef_op = Yap_opcode(_undef_p);
EXECUTE_CPRED_OP_CODE = Yap_opcode(_execute_cpred);
EXPAND_OP_CODE = Yap_opcode(_expand_index);
FAIL_OPCODE = Yap_opcode(_op_fail);
INDEX_OPCODE = Yap_opcode(_index_pred);
LOCKPRED_OPCODE = Yap_opcode(_lock_pred);
ORLAST_OPCODE = Yap_opcode(_or_last);
UNDEF_OPCODE = Yap_opcode(_undef_p);
@ -80,27 +80,27 @@
#include "ratoms.h"
#ifdef EUROTRA
Yap_heap_regs->term_dollar_u = AtomTermAdjust(Yap_heap_regs->term_dollar_u);
TermDollarU = AtomTermAdjust(TermDollarU);
#endif
Yap_heap_regs->term_prolog = AtomTermAdjust(Yap_heap_regs->term_prolog);
Yap_heap_regs->term_refound_var = AtomTermAdjust(Yap_heap_regs->term_refound_var);
Yap_heap_regs->user_module = AtomTermAdjust(Yap_heap_regs->user_module);
Yap_heap_regs->idb_module = AtomTermAdjust(Yap_heap_regs->idb_module);
Yap_heap_regs->attributes_module = AtomTermAdjust(Yap_heap_regs->attributes_module);
Yap_heap_regs->charsio_module = AtomTermAdjust(Yap_heap_regs->charsio_module);
Yap_heap_regs->terms_module = AtomTermAdjust(Yap_heap_regs->terms_module);
Yap_heap_regs->system_module = AtomTermAdjust(Yap_heap_regs->system_module);
Yap_heap_regs->operating_system_module = AtomTermAdjust(Yap_heap_regs->operating_system_module);
Yap_heap_regs->readutil_module = AtomTermAdjust(Yap_heap_regs->readutil_module);
Yap_heap_regs->hacks_module = AtomTermAdjust(Yap_heap_regs->hacks_module);
Yap_heap_regs->arg_module = AtomTermAdjust(Yap_heap_regs->arg_module);
Yap_heap_regs->globals_module = AtomTermAdjust(Yap_heap_regs->globals_module);
Yap_heap_regs->swi_module = AtomTermAdjust(Yap_heap_regs->swi_module);
Yap_heap_regs->dbload_module = AtomTermAdjust(Yap_heap_regs->dbload_module);
TermProlog = AtomTermAdjust(TermProlog);
TermReFoundVar = AtomTermAdjust(TermReFoundVar);
USER_MODULE = AtomTermAdjust(USER_MODULE);
IDB_MODULE = AtomTermAdjust(IDB_MODULE);
ATTRIBUTES_MODULE = AtomTermAdjust(ATTRIBUTES_MODULE);
CHARSIO_MODULE = AtomTermAdjust(CHARSIO_MODULE);
TERMS_MODULE = AtomTermAdjust(TERMS_MODULE);
SYSTEM_MODULE = AtomTermAdjust(SYSTEM_MODULE);
OPERATING_SYSTEM_MODULE = AtomTermAdjust(OPERATING_SYSTEM_MODULE);
READUTIL_MODULE = AtomTermAdjust(READUTIL_MODULE);
HACKS_MODULE = AtomTermAdjust(HACKS_MODULE);
ARG_MODULE = AtomTermAdjust(ARG_MODULE);
GLOBALS_MODULE = AtomTermAdjust(GLOBALS_MODULE);
SWI_MODULE = AtomTermAdjust(SWI_MODULE);
DBLOAD_MODULE = AtomTermAdjust(DBLOAD_MODULE);
Yap_heap_regs->current_modules = ModEntryPtrAdjust(Yap_heap_regs->current_modules);
CurrentModules = ModEntryPtrAdjust(CurrentModules);
@ -114,36 +114,36 @@
Yap_heap_regs->creep_code = PtoPredAdjust(Yap_heap_regs->creep_code);
Yap_heap_regs->undef_code = PtoPredAdjust(Yap_heap_regs->undef_code);
Yap_heap_regs->spy_code = PtoPredAdjust(Yap_heap_regs->spy_code);
Yap_heap_regs->pred_fail = PtoPredAdjust(Yap_heap_regs->pred_fail);
Yap_heap_regs->pred_true = PtoPredAdjust(Yap_heap_regs->pred_true);
CreepCode = PtoPredAdjust(CreepCode);
UndefCode = PtoPredAdjust(UndefCode);
SpyCode = PtoPredAdjust(SpyCode);
PredFail = PtoPredAdjust(PredFail);
PredTrue = PtoPredAdjust(PredTrue);
#ifdef COROUTINING
Yap_heap_regs->wake_up_code = PtoPredAdjust(Yap_heap_regs->wake_up_code);
WakeUpCode = PtoPredAdjust(WakeUpCode);
#endif
Yap_heap_regs->pred_goal_expansion = PtoPredAdjust(Yap_heap_regs->pred_goal_expansion);
Yap_heap_regs->pred_meta_call = PtoPredAdjust(Yap_heap_regs->pred_meta_call);
Yap_heap_regs->pred_dollar_catch = PtoPredAdjust(Yap_heap_regs->pred_dollar_catch);
Yap_heap_regs->pred_recorded_with_key = PtoPredAdjust(Yap_heap_regs->pred_recorded_with_key);
Yap_heap_regs->pred_log_upd_clause = PtoPredAdjust(Yap_heap_regs->pred_log_upd_clause);
Yap_heap_regs->pred_log_upd_clause_erase = PtoPredAdjust(Yap_heap_regs->pred_log_upd_clause_erase);
Yap_heap_regs->pred_log_upd_clause0 = PtoPredAdjust(Yap_heap_regs->pred_log_upd_clause0);
Yap_heap_regs->pred_static_clause = PtoPredAdjust(Yap_heap_regs->pred_static_clause);
Yap_heap_regs->pred_throw = PtoPredAdjust(Yap_heap_regs->pred_throw);
Yap_heap_regs->pred_handle_throw = PtoPredAdjust(Yap_heap_regs->pred_handle_throw);
Yap_heap_regs->pred_is = PtoPredAdjust(Yap_heap_regs->pred_is);
Yap_heap_regs->pred_safe_call_cleanup = PtoPredAdjust(Yap_heap_regs->pred_safe_call_cleanup);
Yap_heap_regs->pred_restore_regs = PtoPredAdjust(Yap_heap_regs->pred_restore_regs);
PredGoalExpansion = PtoPredAdjust(PredGoalExpansion);
PredMetaCall = PtoPredAdjust(PredMetaCall);
PredDollarCatch = PtoPredAdjust(PredDollarCatch);
PredRecordedWithKey = PtoPredAdjust(PredRecordedWithKey);
PredLogUpdClause = PtoPredAdjust(PredLogUpdClause);
PredLogUpdClauseErase = PtoPredAdjust(PredLogUpdClauseErase);
PredLogUpdClause0 = PtoPredAdjust(PredLogUpdClause0);
PredStaticClause = PtoPredAdjust(PredStaticClause);
PredThrow = PtoPredAdjust(PredThrow);
PredHandleThrow = PtoPredAdjust(PredHandleThrow);
PredIs = PtoPredAdjust(PredIs);
PredSafeCallCleanup = PtoPredAdjust(PredSafeCallCleanup);
PredRestoreRegs = PtoPredAdjust(PredRestoreRegs);
#ifdef YAPOR
Yap_heap_regs->pred_getwork = PtoPredAdjust(Yap_heap_regs->pred_getwork);
Yap_heap_regs->pred_getwork_seq = PtoPredAdjust(Yap_heap_regs->pred_getwork_seq);
PredGetwork = PtoPredAdjust(PredGetwork);
PredGetworkSeq = PtoPredAdjust(PredGetworkSeq);
#endif /* YAPOR */
#ifdef LOW_LEVEL_TRACER
#if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_heap_regs->low_level_trace_lock);
REINIT_LOCK(Yap_low_level_trace_lock);
#endif
#endif
@ -158,22 +158,22 @@
Yap_heap_regs->dummycode->opc = Yap_opcode(_op_fail);
Yap_heap_regs->failcode->opc = Yap_opcode(_op_fail);
Yap_heap_regs->nocode->opc = Yap_opcode(_Nstop);
DUMMYCODE->opc = Yap_opcode(_op_fail);
FAILCODE->opc = Yap_opcode(_op_fail);
NOCODE->opc = Yap_opcode(_Nstop);
RestoreEnvInst(ENV_FOR_TRUSTFAIL,&TRUSTFAILCODE,_trust_fail,PredFail);
RestoreEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail);
RestoreOtaplInst(RTRYCODE,_retry_and_mark,PredFail);
#ifdef BEAM
Yap_heap_regs->beam_retry_code->opc = Yap_opcode(_beam_retry_code);
BEAM_RETRY_CODE->opc = Yap_opcode(_beam_retry_code);
#endif /* BEAM */
#ifdef YAPOR
RestoreOtaplInst(GETWORK,_getwork,PredGetwork);
RestoreOtaplInst(GETWORK_SEQ,_getwork_seq,PredGetworkSeq);
Yap_heap_regs->getwork_first_time->opc = Yap_opcode(_getwork_first_time);
GETWORK_FIRST_TIME->opc = Yap_opcode(_getwork_first_time);
#endif /* YAPOR */
#ifdef TABLING
RestoreOtaplInst(LOAD_ANSWER,_table_load_answer,PredFail);
@ -185,10 +185,10 @@
Yap_heap_regs->debugger_p_before_spy = PtoOpAdjust(Yap_heap_regs->debugger_p_before_spy);
P_before_spy = PtoOpAdjust(P_before_spy);
Yap_heap_regs->retry_recordedp_code = PtoOpAdjust(Yap_heap_regs->retry_recordedp_code);
Yap_heap_regs->retry_recorded_k_code = PtoOpAdjust(Yap_heap_regs->retry_recorded_k_code);
RETRY_C_RECORDEDP_CODE = PtoOpAdjust(RETRY_C_RECORDEDP_CODE);
RETRY_C_RECORDED_K_CODE = PtoOpAdjust(RETRY_C_RECORDED_K_CODE);
@ -203,7 +203,7 @@
#if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_heap_regs->dbterms_list_lock);
REINIT_LOCK(DBTermsListLock);
#endif
RestoreDBTermsList();
@ -211,8 +211,8 @@
RestoreExpandList();
#if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_heap_regs->expand_clauses_list_lock);
REINIT_LOCK(Yap_heap_regs->op_list_lock);
REINIT_LOCK(ExpandClausesListLock);
REINIT_LOCK(OpListLock);
#endif
#ifdef DEBUG
@ -247,9 +247,9 @@
RestoreDBErasedList();
RestoreDBErasedIList();
#if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_heap_regs->dead_static_clauses_lock);
REINIT_LOCK(Yap_heap_regs->dead_mega_clauses_lock);
REINIT_LOCK(Yap_heap_regs->dead_static_indices_lock);
REINIT_LOCK(DeadStaticClausesLock);
REINIT_LOCK(DeadMegaClausesLock);
REINIT_LOCK(DeadStaticIndicesLock);
#endif
#ifdef COROUTINING
@ -260,7 +260,7 @@
Yap_heap_regs->op_list = OpListAdjust(Yap_heap_regs->op_list);
OpList = OpListAdjust(OpList);
RestoreStreams();
@ -269,17 +269,17 @@
RestoreAliases();
Yap_heap_regs->atprompt = AtomAdjust(Yap_heap_regs->atprompt);
AtPrompt = AtomAdjust(AtPrompt);
Yap_heap_regs->char_conversion_table = CodeCharPAdjust(Yap_heap_regs->char_conversion_table);
Yap_heap_regs->char_conversion_table2 = CodeCharPAdjust(Yap_heap_regs->char_conversion_table2);
CharConversionTable = CodeCharPAdjust(CharConversionTable);
CharConversionTable2 = CodeCharPAdjust(CharConversionTable2);
Yap_heap_regs->yap_lib_dir = CodeCharPAdjust(Yap_heap_regs->yap_lib_dir);
Yap_LibDir = CodeCharPAdjust(Yap_LibDir);
Yap_heap_regs->last_wtime = CodeVoidPAdjust(Yap_heap_regs->last_wtime);
LastWtimePtr = CodeVoidPAdjust(LastWtimePtr);
#if LOW_PROF

View File

@ -1,5 +1,5 @@
/* This file, rlocals.h, was generated automatically by "yap -L misc/buildheap"
/* This file, rlocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update misc/LOCALS instead */
@ -46,9 +46,7 @@ static void RestoreWorker(int wid USES_REGS) {
FOREIGN(wid)->global_arena = TermToGlobalOrAtomAdjust(FOREIGN(wid)->global_arena);
REMOTE_GlobalArena(wid) = TermToGlobalOrAtomAdjust(REMOTE_GlobalArena(wid));
@ -66,46 +64,26 @@ static void RestoreWorker(int wid USES_REGS) {
#ifdef COROUTINING
FOREIGN(wid)->woken_goals = TermToGlobalAdjust(FOREIGN(wid)->woken_goals);
FOREIGN(wid)->atts_mutable_list = TermToGlobalAdjust(FOREIGN(wid)->atts_mutable_list);
REMOTE_WokenGoals(wid) = TermToGlobalAdjust(REMOTE_WokenGoals(wid));
REMOTE_AttsMutableList(wid) = TermToGlobalAdjust(REMOTE_AttsMutableList(wid));
#endif
FOREIGN(wid)->gc_generation = TermToGlobalAdjust(FOREIGN(wid)->gc_generation);
FOREIGN(wid)->gc_phase = TermToGlobalAdjust(FOREIGN(wid)->gc_phase);
REMOTE_GcGeneration(wid) = TermToGlobalAdjust(REMOTE_GcGeneration(wid));
REMOTE_GcPhase(wid) = TermToGlobalAdjust(REMOTE_GcPhase(wid));
#if LOW_LEVEL_TRACER
#endif
#if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(FOREIGN(wid)->signal_lock);
#if DEBUG && COROUTINING
#endif
#if GC_NO_TAGS
#endif
#if defined(TABLING) || defined(YAPOR_SBA)
#else
#if defined(GC_NO_TAGS)
#endif
@ -119,14 +97,15 @@ static void RestoreWorker(int wid USES_REGS) {
#endif /* defined(YAPOR) || defined(THREADS) */
FOREIGN(wid)->dynamic_arrays = PtoArrayEAdjust(FOREIGN(wid)->dynamic_arrays);
FOREIGN(wid)->static_arrays = PtoArraySAdjust(FOREIGN(wid)->static_arrays);
FOREIGN(wid)->global_variables = PtoGlobalEAdjust(FOREIGN(wid)->global_variables);
REMOTE_DynamicArrays(wid) = PtoArrayEAdjust(REMOTE_DynamicArrays(wid));
REMOTE_StaticArrays(wid) = PtoArraySAdjust(REMOTE_StaticArrays(wid));
REMOTE_GlobalVariables(wid) = PtoGlobalEAdjust(REMOTE_GlobalVariables(wid));
@ -136,8 +115,71 @@ static void RestoreWorker(int wid USES_REGS) {
#ifdef THREADS
#define FOREIGN_ThreadHandle(wid) (Yap_WLocal[(wid)]->thread_handle)
#define MY_ThreadHandle (Yap_WLocal[worker_id]->thread_handle)
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
#endif /* YAPOR || TABLING */
#if LOW_LEVEL_TRACER
#endif
#if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(REMOTE_SignalLock(wid));
#endif
#ifdef THREADS
#else
#endif
#ifdef ANALYST
#endif /* ANALYST */
#ifdef LOAD_DYLD
#endif
#ifdef LOW_LEVEL_TRACER
#endif
}

View File

@ -124,7 +124,7 @@ inline EXTERN int
IsHeapP__ (CELL * ptr USES_REGS)
{
#if USE_SYSTEM_MALLOC
return (int) ((ptr < (CELL *) Yap_GlobalBase || ptr > (CELL *) Yap_TrailTop));
return (int) ((ptr < (CELL *) LOCAL_GlobalBase || ptr > (CELL *) LOCAL_TrailTop));
#else
return (int) ((ptr >= (CELL *) Yap_HeapBase && ptr <= (CELL *) HeapTop));
#endif
@ -140,13 +140,13 @@ inline EXTERN CELL *PtoGloAdjust__ (CELL * CACHE_TYPE);
inline EXTERN CELL *
PtoGloAdjust__ (CELL * ptr USES_REGS)
{
if (ptr < GSplit) {
if (ptr < LOCAL_GSplit) {
if (ptr < H0)
return (CELL *) (((CELL *) (CharP (ptr) + DelayDiff)));
return (CELL *) (((CELL *) (CharP (ptr) + LOCAL_DelayDiff)));
else
return (CELL *) (((CELL *) (CharP (ptr) + GDiff0)));
return (CELL *) (((CELL *) (CharP (ptr) + LOCAL_GDiff0)));
} else {
return (CELL *) (((CELL *) (CharP (ptr) + GDiff)));
return (CELL *) (((CELL *) (CharP (ptr) + LOCAL_GDiff)));
}
}
@ -157,10 +157,10 @@ inline EXTERN CELL *PtoDelayAdjust__ (CELL * CACHE_TYPE);
inline EXTERN CELL *
PtoDelayAdjust__ (CELL * ptr USES_REGS)
{
if (!GSplit || ptr < GSplit)
return (CELL *) (((CELL *) (CharP (ptr) + DelayDiff)));
if (!LOCAL_GSplit || ptr < LOCAL_GSplit)
return (CELL *) (((CELL *) (CharP (ptr) + LOCAL_DelayDiff)));
else
return (CELL *) (((CELL *) (CharP (ptr) + GDiff0)));
return (CELL *) (((CELL *) (CharP (ptr) + LOCAL_GDiff0)));
}
inline EXTERN CELL *PtoBaseAdjust__ (CELL * CACHE_TYPE);
@ -168,7 +168,7 @@ inline EXTERN CELL *PtoBaseAdjust__ (CELL * CACHE_TYPE);
inline EXTERN CELL *
PtoBaseAdjust__ (CELL * ptr USES_REGS)
{
return (CELL *) (((CELL *) (CharP (ptr) + BaseDiff)));
return (CELL *) (((CELL *) (CharP (ptr) + LOCAL_BaseDiff)));
}
@ -178,7 +178,7 @@ inline EXTERN tr_fr_ptr PtoTRAdjust__ (tr_fr_ptr CACHE_TYPE);
inline EXTERN tr_fr_ptr
PtoTRAdjust__ (tr_fr_ptr ptr USES_REGS)
{
return (tr_fr_ptr) (((tr_fr_ptr) (CharP (ptr) + TrDiff)));
return (tr_fr_ptr) (((tr_fr_ptr) (CharP (ptr) + LOCAL_TrDiff)));
}
@ -188,7 +188,7 @@ inline EXTERN CELL *CellPtoTRAdjust__ (CELL * CACHE_TYPE);
inline EXTERN CELL *
CellPtoTRAdjust__ (CELL * ptr USES_REGS)
{
return (CELL *) (((CELL *) (CharP (ptr) + TrDiff)));
return (CELL *) (((CELL *) (CharP (ptr) + LOCAL_TrDiff)));
}
@ -198,7 +198,7 @@ inline EXTERN CELL *PtoLocAdjust__ (CELL * CACHE_TYPE);
inline EXTERN CELL *
PtoLocAdjust__ (CELL * ptr USES_REGS)
{
return (CELL *) (((CELL *) (CharP (ptr) + LDiff)));
return (CELL *) (((CELL *) (CharP (ptr) + LOCAL_LDiff)));
}
@ -207,7 +207,7 @@ inline EXTERN struct cut_c_str *CutCAdjust__ (struct cut_c_str * CACHE_TYPE);
inline EXTERN struct cut_c_str *
CutCAdjust__ (struct cut_c_str * ptr USES_REGS)
{
return (struct cut_c_str *) (CharP (ptr) + LDiff);
return (struct cut_c_str *) (CharP (ptr) + LOCAL_LDiff);
}
@ -217,7 +217,7 @@ inline EXTERN choiceptr ChoicePtrAdjust__ (choiceptr CACHE_TYPE);
inline EXTERN choiceptr
ChoicePtrAdjust__ (choiceptr ptr USES_REGS)
{
return (choiceptr) (((choiceptr) (CharP (ptr) + LDiff)));
return (choiceptr) (((choiceptr) (CharP (ptr) + LOCAL_LDiff)));
}
@ -228,7 +228,7 @@ inline EXTERN choiceptr ConsumerChoicePtrAdjust__ (choiceptr CACHE_TYPE);
inline EXTERN choiceptr
ConsumerChoicePtrAdjust__ (choiceptr ptr USES_REGS)
{
return (choiceptr) (((choiceptr) (CharP (ptr) + LDiff)));
return (choiceptr) (((choiceptr) (CharP (ptr) + LOCAL_LDiff)));
}
@ -238,7 +238,7 @@ inline EXTERN choiceptr GeneratorChoicePtrAdjust__ (choiceptr CACHE_TYPE);
inline EXTERN choiceptr
GeneratorChoicePtrAdjust__ (choiceptr ptr USES_REGS)
{
return (choiceptr) (((choiceptr) (CharP (ptr) + LDiff)));
return (choiceptr) (((choiceptr) (CharP (ptr) + LOCAL_LDiff)));
}
@ -250,13 +250,13 @@ inline EXTERN CELL GlobalAdjust__ (CELL CACHE_TYPE);
inline EXTERN CELL
GlobalAdjust__ (CELL val USES_REGS)
{
if ((CELL *)val < GSplit) {
if ((CELL *)val < LOCAL_GSplit) {
if ((CELL *)val < H0)
return (CELL) (val + DelayDiff);
return (CELL) (val + LOCAL_DelayDiff);
else
return (CELL) (val + GDiff0);
return (CELL) (val + LOCAL_GDiff0);
} else {
return (CELL) (val + GDiff);
return (CELL) (val + LOCAL_GDiff);
}
}
@ -267,10 +267,10 @@ inline EXTERN CELL DelayAdjust__ (CELL CACHE_TYPE);
inline EXTERN CELL
DelayAdjust__ (CELL val USES_REGS)
{
if (!GSplit || (CELL *)val < GSplit)
return (CELL) (val + DelayDiff);
if (!LOCAL_GSplit || (CELL *)val < LOCAL_GSplit)
return (CELL) (val + LOCAL_DelayDiff);
else
return (CELL) (val + GDiff0);
return (CELL) (val + LOCAL_GDiff0);
}
@ -279,13 +279,13 @@ inline EXTERN ADDR GlobalAddrAdjust__ (ADDR CACHE_TYPE);
inline EXTERN ADDR
GlobalAddrAdjust__ (ADDR ptr USES_REGS)
{
if ((CELL *)ptr < GSplit) {
if ((CELL *)ptr < LOCAL_GSplit) {
if ((CELL *)ptr < H0)
return (ADDR) (ptr + DelayDiff);
return (ADDR) (ptr + LOCAL_DelayDiff);
else
return (ADDR) ((ptr + GDiff0));
return (ADDR) ((ptr + LOCAL_GDiff0));
} else {
return (ADDR) ((ptr + GDiff));
return (ADDR) ((ptr + LOCAL_GDiff));
}
}
@ -297,10 +297,10 @@ inline EXTERN ADDR DelayAddrAdjust__ (ADDR CACHE_TYPE);
inline EXTERN ADDR
DelayAddrAdjust__ (ADDR ptr USES_REGS)
{
if (!GSplit || (CELL *)ptr < GSplit)
return (ADDR) ((ptr + DelayDiff));
if (!LOCAL_GSplit || (CELL *)ptr < LOCAL_GSplit)
return (ADDR) ((ptr + LOCAL_DelayDiff));
else
return (ADDR) ((ptr + GDiff0));
return (ADDR) ((ptr + LOCAL_GDiff0));
}
@ -309,7 +309,7 @@ inline EXTERN ADDR BaseAddrAdjust__ (ADDR CACHE_TYPE);
inline EXTERN ADDR
BaseAddrAdjust__ (ADDR ptr USES_REGS)
{
return (ADDR) ((ptr + BaseDiff));
return (ADDR) ((ptr + LOCAL_BaseDiff));
}
@ -319,7 +319,7 @@ inline EXTERN CELL LocalAdjust__ (CELL CACHE_TYPE);
inline EXTERN CELL
LocalAdjust__ (CELL val USES_REGS)
{
return (CELL) ((val + LDiff));
return (CELL) ((val + LOCAL_LDiff));
}
@ -329,7 +329,7 @@ inline EXTERN ADDR LocalAddrAdjust__ (ADDR CACHE_TYPE);
inline EXTERN ADDR
LocalAddrAdjust__ (ADDR ptr USES_REGS)
{
return (ADDR) ((ptr + LDiff));
return (ADDR) ((ptr + LOCAL_LDiff));
}
@ -339,7 +339,7 @@ inline EXTERN CELL TrailAdjust__ (CELL CACHE_TYPE);
inline EXTERN CELL
TrailAdjust__ (CELL val USES_REGS)
{
return (CELL) ((val + TrDiff));
return (CELL) ((val + LOCAL_TrDiff));
}
@ -349,7 +349,7 @@ inline EXTERN ADDR TrailAddrAdjust__ (ADDR CACHE_TYPE);
inline EXTERN ADDR
TrailAddrAdjust__ (ADDR ptr USES_REGS)
{
return (ADDR) ((ptr + TrDiff));
return (ADDR) ((ptr + LOCAL_TrDiff));
}
@ -359,7 +359,7 @@ inline EXTERN TokEntry *TokEntryAdjust__ (TokEntry * CACHE_TYPE);
inline EXTERN TokEntry *
TokEntryAdjust__ (TokEntry * ptr USES_REGS)
{
return (TokEntry *) (((CELL) ptr + TrDiff));
return (TokEntry *) (((CELL) ptr + LOCAL_TrDiff));
}
@ -369,7 +369,7 @@ inline EXTERN VarEntry *VarEntryAdjust__ (VarEntry * CACHE_TYPE);
inline EXTERN VarEntry *
VarEntryAdjust__ (VarEntry * ptr USES_REGS)
{
return (VarEntry *) (((CELL) ptr + TrDiff));
return (VarEntry *) (((CELL) ptr + LOCAL_TrDiff));
}
@ -381,7 +381,7 @@ inline EXTERN Functor
FuncAdjust__ (Functor f USES_REGS)
{
if (!IsExtensionFunctor(f))
return (Functor) ((CharP (f) + HDiff));
return (Functor) ((CharP (f) + LOCAL_HDiff));
return f;
}
@ -392,7 +392,7 @@ CellPtoHeapAdjust__ (CELL * ptr USES_REGS)
{
if (!ptr)
return ptr;
return (CELL *) (((CELL *) (CharP (ptr) + HDiff)));
return (CELL *) (((CELL *) (CharP (ptr) + LOCAL_HDiff)));
}
inline EXTERN HoldEntry *HoldEntryAdjust__ (HoldEntry * CACHE_TYPE);
@ -400,7 +400,7 @@ inline EXTERN HoldEntry *HoldEntryAdjust__ (HoldEntry * CACHE_TYPE);
inline EXTERN HoldEntry *
HoldEntryAdjust__ (HoldEntry * ptr USES_REGS)
{
return (HoldEntry *) (((HoldEntry *) (CharP (ptr) + HDiff)));
return (HoldEntry *) (((HoldEntry *) (CharP (ptr) + LOCAL_HDiff)));
}
inline EXTERN struct record_list *DBRecordAdjust__ (struct record_list * CACHE_TYPE);
@ -410,7 +410,7 @@ DBRecordAdjust__ (struct record_list * ptr USES_REGS)
{
if (!ptr)
return ptr;
return (struct record_list *) (CharP (ptr) + HDiff);
return (struct record_list *) (CharP (ptr) + LOCAL_HDiff);
}
@ -449,7 +449,7 @@ inline EXTERN Atom AtomAdjust__ (Atom CACHE_TYPE);
inline EXTERN Atom
AtomAdjust__ (Atom at USES_REGS)
{
return (Atom) ((at == NULL ? (at) : (Atom) (CharP (at) + HDiff)));
return (Atom) ((at == NULL ? (at) : (Atom) (CharP (at) + LOCAL_HDiff)));
}
inline EXTERN Atom NoAGCAtomAdjust__ (Atom CACHE_TYPE);
@ -457,7 +457,7 @@ inline EXTERN Atom NoAGCAtomAdjust__ (Atom CACHE_TYPE);
inline EXTERN Atom
NoAGCAtomAdjust__ (Atom at USES_REGS)
{
return (Atom) ((at == NULL ? (at) : (Atom) (CharP (at) + HDiff)));
return (Atom) ((at == NULL ? (at) : (Atom) (CharP (at) + LOCAL_HDiff)));
}
@ -467,7 +467,7 @@ inline EXTERN Prop PropAdjust__ (Prop CACHE_TYPE);
inline EXTERN Prop
PropAdjust__ (Prop p USES_REGS)
{
return (Prop) ((p == NULL ? (p) : (Prop) (CharP (p) + HDiff)));
return (Prop) ((p == NULL ? (p) : (Prop) (CharP (p) + LOCAL_HDiff)));
}
@ -478,7 +478,7 @@ inline EXTERN struct PL_blob_t *BlobTypeAdjust__ (struct PL_blob_t *CACHE_TYPE);
inline EXTERN struct PL_blob_t *
BlobTypeAdjust__ (struct PL_blob_t *at USES_REGS)
{
return (struct PL_blob_t *) ((at == NULL ? (at) : (struct PL_blob_t *) (CharP (at) + HDiff)));
return (struct PL_blob_t *) ((at == NULL ? (at) : (struct PL_blob_t *) (CharP (at) + LOCAL_HDiff)));
}
inline EXTERN PredEntry *PredEntryAdjust__ (PredEntry * CACHE_TYPE);
@ -486,7 +486,7 @@ inline EXTERN PredEntry *PredEntryAdjust__ (PredEntry * CACHE_TYPE);
inline EXTERN PredEntry *
PredEntryAdjust__ (PredEntry *p USES_REGS)
{
return (PredEntry *) ((p == NULL ? (p) : (PredEntry *) (CharP (p) + HDiff)));
return (PredEntry *) ((p == NULL ? (p) : (PredEntry *) (CharP (p) + LOCAL_HDiff)));
}
inline EXTERN struct mod_entry *ModEntryPtrAdjust__ (struct mod_entry * CACHE_TYPE);
@ -494,7 +494,7 @@ inline EXTERN struct mod_entry *ModEntryPtrAdjust__ (struct mod_entry * CACHE_TY
inline EXTERN struct mod_entry *
ModEntryPtrAdjust__ (struct mod_entry *p USES_REGS)
{
return (struct mod_entry *) ((p == NULL ? (p) : (struct mod_entry *) (CharP (p) + HDiff)));
return (struct mod_entry *) ((p == NULL ? (p) : (struct mod_entry *) (CharP (p) + LOCAL_HDiff)));
}
inline EXTERN COUNT ConstantAdjust__ (COUNT CACHE_TYPE);
@ -536,7 +536,7 @@ AtomTermAdjust__ (Term at USES_REGS)
{
if (at == 0L)
return at;
return (Term)(CharP(at) + HDiff);
return (Term)(CharP(at) + LOCAL_HDiff);
}
inline EXTERN Term ModuleAdjust__ (Term CACHE_TYPE);
@ -554,7 +554,7 @@ CodeVarAdjust__ (Term var USES_REGS)
{
if (var == 0L)
return var;
return (Term)(CharP(var) + HDiff);
return (Term)(CharP(var) + LOCAL_HDiff);
}
@ -565,7 +565,7 @@ inline EXTERN Term BlobTermInCodeAdjust__ (Term CACHE_TYPE);
inline EXTERN Term
BlobTermInCodeAdjust__ (Term t USES_REGS)
{
return (Term) (CharP(t) - HDiff);
return (Term) (CharP(t) - LOCAL_HDiff);
}
@ -574,7 +574,7 @@ inline EXTERN Term CodeComposedTermAdjust__ (Term CACHE_TYPE);
inline EXTERN Term
CodeComposedTermAdjust__ (Term t USES_REGS)
{
return (Term) (CharP(t) - HDiff);
return (Term) (CharP(t) - LOCAL_HDiff);
}
@ -585,7 +585,7 @@ inline EXTERN Term BlobTermInCodeAdjust__ (Term CACHE_TYPE);
inline EXTERN Term
BlobTermInCodeAdjust__ (Term t USES_REGS)
{
return (Term) (CharP(t) + HDiff);
return (Term) (CharP(t) + LOCAL_HDiff);
}
inline EXTERN Term CodeComposedTermAdjust__ (Term CACHE_TYPE);
@ -593,7 +593,7 @@ inline EXTERN Term CodeComposedTermAdjust__ (Term CACHE_TYPE);
inline EXTERN Term
CodeComposedTermAdjust__ (Term t USES_REGS)
{
return (Term) (CharP(t) + HDiff);
return (Term) (CharP(t) + LOCAL_HDiff);
}
@ -604,7 +604,7 @@ inline EXTERN AtomEntry *AtomEntryAdjust__ (AtomEntry * CACHE_TYPE);
inline EXTERN AtomEntry *
AtomEntryAdjust__ (AtomEntry * at USES_REGS)
{
return (AtomEntry *) ((AtomEntry *) (CharP (at) + HDiff));
return (AtomEntry *) ((AtomEntry *) (CharP (at) + LOCAL_HDiff));
}
inline EXTERN struct mfile *MFileAdjust__ (struct mfile * CACHE_TYPE);
@ -612,7 +612,7 @@ inline EXTERN struct mfile *MFileAdjust__ (struct mfile * CACHE_TYPE);
inline EXTERN struct mfile *
MFileAdjust__ (struct mfile * at USES_REGS)
{
return (struct mfile *) (CharP (at) + HDiff);
return (struct mfile *) (CharP (at) + LOCAL_HDiff);
}
inline EXTERN GlobalEntry *GlobalEntryAdjust__ (GlobalEntry * CACHE_TYPE);
@ -620,7 +620,7 @@ inline EXTERN GlobalEntry *GlobalEntryAdjust__ (GlobalEntry * CACHE_TYPE);
inline EXTERN GlobalEntry *
GlobalEntryAdjust__ (GlobalEntry * at USES_REGS)
{
return (GlobalEntry *) ((GlobalEntry *) (CharP (at) + HDiff));
return (GlobalEntry *) ((GlobalEntry *) (CharP (at) + LOCAL_HDiff));
}
@ -630,7 +630,7 @@ inline EXTERN union CONSULT_OBJ *ConsultObjAdjust__ (union CONSULT_OBJ * CACHE_T
inline EXTERN union CONSULT_OBJ *
ConsultObjAdjust__ (union CONSULT_OBJ *co USES_REGS)
{
return (union CONSULT_OBJ *) ((union CONSULT_OBJ *) (CharP (co) + HDiff));
return (union CONSULT_OBJ *) ((union CONSULT_OBJ *) (CharP (co) + LOCAL_HDiff));
}
@ -640,7 +640,7 @@ inline EXTERN DBRef DBRefAdjust__ (DBRef CACHE_TYPE);
inline EXTERN DBRef
DBRefAdjust__ (DBRef dbr USES_REGS)
{
return (DBRef) ((DBRef) (CharP (dbr) + HDiff));
return (DBRef) ((DBRef) (CharP (dbr) + LOCAL_HDiff));
}
@ -650,7 +650,7 @@ inline EXTERN DBRef *DBRefPAdjust__ (DBRef * CACHE_TYPE);
inline EXTERN DBRef *
DBRefPAdjust__ (DBRef * dbrp USES_REGS)
{
return (DBRef *) ((DBRef *) (CharP (dbrp) + HDiff));
return (DBRef *) ((DBRef *) (CharP (dbrp) + LOCAL_HDiff));
}
@ -660,7 +660,7 @@ inline EXTERN DBTerm *DBTermAdjust__ (DBTerm * CACHE_TYPE);
inline EXTERN DBTerm *
DBTermAdjust__ (DBTerm * dbtp USES_REGS)
{
return (DBTerm *) ((DBTerm *) (CharP (dbtp) + HDiff));
return (DBTerm *) ((DBTerm *) (CharP (dbtp) + LOCAL_HDiff));
}
@ -671,7 +671,7 @@ inline EXTERN struct static_index *
SIndexAdjust__ (struct static_index *si USES_REGS)
{
return (struct static_index
*) ((struct static_index *) (CharP (si) + HDiff));
*) ((struct static_index *) (CharP (si) + LOCAL_HDiff));
}
@ -683,7 +683,7 @@ inline EXTERN struct logic_upd_index *
LUIndexAdjust__ (struct logic_upd_index *lui USES_REGS)
{
return (struct logic_upd_index
*) ((struct logic_upd_index *) (CharP (lui) + HDiff));
*) ((struct logic_upd_index *) (CharP (lui) + LOCAL_HDiff));
}
@ -693,7 +693,7 @@ inline EXTERN Term CodeAdjust__ (Term CACHE_TYPE);
inline EXTERN Term
CodeAdjust__ (Term dbr USES_REGS)
{
return (Term) (CharP(dbr) + HDiff);
return (Term) (CharP(dbr) + LOCAL_HDiff);
}
@ -703,7 +703,7 @@ inline EXTERN ADDR AddrAdjust__ (ADDR CACHE_TYPE);
inline EXTERN ADDR
AddrAdjust__ (ADDR addr USES_REGS)
{
return (ADDR) ((ADDR) (CharP (addr) + HDiff));
return (ADDR) ((ADDR) (CharP (addr) + LOCAL_HDiff));
}
@ -713,7 +713,7 @@ inline EXTERN CODEADDR CodeAddrAdjust__ (CODEADDR CACHE_TYPE);
inline EXTERN CODEADDR
CodeAddrAdjust__ (CODEADDR addr USES_REGS)
{
return (CODEADDR) ((CODEADDR) (CharP (addr) + HDiff));
return (CODEADDR) ((CODEADDR) (CharP (addr) + LOCAL_HDiff));
}
@ -724,7 +724,7 @@ CodeCharPAdjust__ (char * addr USES_REGS)
{
if (!addr)
return NULL;
return addr + HDiff;
return addr + LOCAL_HDiff;
}
inline EXTERN void * CodeVoidPAdjust__ (void * CACHE_TYPE);
@ -734,7 +734,7 @@ CodeVoidPAdjust__ (void * addr USES_REGS)
{
if (!addr)
return NULL;
return addr + HDiff;
return addr + LOCAL_HDiff;
}
inline EXTERN struct halt_hook *HaltHookAdjust__ (struct halt_hook * CACHE_TYPE);
@ -744,7 +744,7 @@ HaltHookAdjust__ (struct halt_hook * addr USES_REGS)
{
if (!addr)
return NULL;
return (struct halt_hook *) (CharP (addr) + HDiff);
return (struct halt_hook *) (CharP (addr) + LOCAL_HDiff);
}
inline EXTERN BlockHeader *BlockAdjust__ (BlockHeader * CACHE_TYPE);
@ -752,7 +752,7 @@ inline EXTERN BlockHeader *BlockAdjust__ (BlockHeader * CACHE_TYPE);
inline EXTERN BlockHeader *
BlockAdjust__ (BlockHeader * addr USES_REGS)
{
return (BlockHeader *) ((BlockHeader *) (CharP (addr) + HDiff));
return (BlockHeader *) ((BlockHeader *) (CharP (addr) + LOCAL_HDiff));
}
inline EXTERN yamop *PtoOpAdjust__ (yamop * CACHE_TYPE);
@ -761,7 +761,7 @@ inline EXTERN yamop *
PtoOpAdjust__ (yamop * ptr USES_REGS)
{
if (ptr)
return (yamop *) (CharP (ptr) + HDiff);
return (yamop *) (CharP (ptr) + LOCAL_HDiff);
return ptr;
}
@ -772,7 +772,7 @@ OpListAdjust__ (struct operator_entry * ptr USES_REGS)
{
if (!ptr)
return ptr;
return (struct operator_entry *) (CharP (ptr) + HDiff);
return (struct operator_entry *) (CharP (ptr) + LOCAL_HDiff);
}
@ -781,7 +781,7 @@ inline EXTERN struct logic_upd_clause *PtoLUClauseAdjust__ (struct logic_upd_cla
inline EXTERN struct logic_upd_clause *
PtoLUClauseAdjust__ (struct logic_upd_clause * ptr USES_REGS)
{
return (struct logic_upd_clause *) (CharP (ptr) + HDiff);
return (struct logic_upd_clause *) (CharP (ptr) + LOCAL_HDiff);
}
inline EXTERN struct logic_upd_index *PtoLUIndexAdjust__ (struct logic_upd_index * CACHE_TYPE);
@ -789,7 +789,7 @@ inline EXTERN struct logic_upd_index *PtoLUIndexAdjust__ (struct logic_upd_index
inline EXTERN struct logic_upd_index *
PtoLUIndexAdjust__ (struct logic_upd_index * ptr USES_REGS)
{
return (struct logic_upd_index *) (CharP (ptr) + HDiff);
return (struct logic_upd_index *) (CharP (ptr) + LOCAL_HDiff);
}
@ -799,7 +799,7 @@ inline EXTERN CELL *PtoHeapCellAdjust__ (CELL * CACHE_TYPE);
inline EXTERN CELL *
PtoHeapCellAdjust__ (CELL * ptr USES_REGS)
{
return (CELL *) (((CELL *) (CharP (ptr) + HDiff)));
return (CELL *) (((CELL *) (CharP (ptr) + LOCAL_HDiff)));
}
inline EXTERN AtomHashEntry *PtoAtomHashEntryAdjust__ (AtomHashEntry * CACHE_TYPE);
@ -807,7 +807,7 @@ inline EXTERN AtomHashEntry *PtoAtomHashEntryAdjust__ (AtomHashEntry * CACHE_TYP
inline EXTERN AtomHashEntry *
PtoAtomHashEntryAdjust__ (AtomHashEntry * ptr USES_REGS)
{
return (AtomHashEntry *) (((AtomHashEntry *) (CharP (ptr) + HDiff)));
return (AtomHashEntry *) (((AtomHashEntry *) (CharP (ptr) + LOCAL_HDiff)));
}
inline EXTERN Term TermToGlobalAdjust__ (Term CACHE_TYPE);
@ -841,7 +841,7 @@ inline EXTERN opentry *OpRTableAdjust__ (opentry * CACHE_TYPE);
inline EXTERN opentry *
OpRTableAdjust__ (opentry * ptr USES_REGS)
{
return (opentry *) (((opentry *) (CharP (ptr) + HDiff)));
return (opentry *) (((opentry *) (CharP (ptr) + LOCAL_HDiff)));
}
inline EXTERN OpEntry *OpEntryAdjust__ (OpEntry * CACHE_TYPE);
@ -849,7 +849,7 @@ inline EXTERN OpEntry *OpEntryAdjust__ (OpEntry * CACHE_TYPE);
inline EXTERN OpEntry *
OpEntryAdjust__ (OpEntry * ptr USES_REGS)
{
return (OpEntry *) (((OpEntry *) (CharP (ptr) + HDiff)));
return (OpEntry *) (((OpEntry *) (CharP (ptr) + LOCAL_HDiff)));
}
inline EXTERN PredEntry *PtoPredAdjust__ (PredEntry * CACHE_TYPE);
@ -857,7 +857,7 @@ inline EXTERN PredEntry *PtoPredAdjust__ (PredEntry * CACHE_TYPE);
inline EXTERN PredEntry *
PtoPredAdjust__ (PredEntry * ptr USES_REGS)
{
return (PredEntry *) (((PredEntry *) (CharP (ptr) + HDiff)));
return (PredEntry *) (((PredEntry *) (CharP (ptr) + LOCAL_HDiff)));
}
inline EXTERN PredEntry **PtoPtoPredAdjust__ (PredEntry ** CACHE_TYPE);
@ -867,7 +867,7 @@ PtoPtoPredAdjust__ (PredEntry **ptr USES_REGS)
{
if (!ptr)
return NULL;
return (PredEntry **) (((PredEntry **) (CharP (ptr) + HDiff)));
return (PredEntry **) (((PredEntry **) (CharP (ptr) + LOCAL_HDiff)));
}
@ -879,7 +879,7 @@ PtoArrayEAdjust__ (ArrayEntry * ptr USES_REGS)
{
if (!ptr)
return NULL;
return (ArrayEntry *) (((ArrayEntry *) (CharP (ptr) + HDiff)));
return (ArrayEntry *) (((ArrayEntry *) (CharP (ptr) + LOCAL_HDiff)));
}
@ -890,7 +890,7 @@ PtoGlobalEAdjust__ (GlobalEntry * ptr USES_REGS)
{
if (!ptr)
return NULL;
return (GlobalEntry *) (((GlobalEntry *) (CharP (ptr) + HDiff)));
return (GlobalEntry *) (((GlobalEntry *) (CharP (ptr) + LOCAL_HDiff)));
}
@ -901,7 +901,7 @@ PtoArraySAdjust__ (StaticArrayEntry * ptr USES_REGS)
{
if (!ptr)
return NULL;
return (StaticArrayEntry *) (((StaticArrayEntry *) (CharP (ptr) + HDiff)));
return (StaticArrayEntry *) (((StaticArrayEntry *) (CharP (ptr) + LOCAL_HDiff)));
}
@ -912,7 +912,7 @@ inline EXTERN struct logic_upd_clause *
PtoLUCAdjust__ (struct logic_upd_clause *ptr USES_REGS)
{
return (struct logic_upd_clause
*) (((struct logic_upd_clause *) (CharP (ptr) + HDiff)));
*) (((struct logic_upd_clause *) (CharP (ptr) + LOCAL_HDiff)));
}
@ -923,7 +923,7 @@ inline EXTERN struct static_clause *
PtoStCAdjust__ (struct static_clause *ptr USES_REGS)
{
return (struct static_clause
*) (((struct static_upd_clause *) (CharP (ptr) + HDiff)));
*) (((struct static_upd_clause *) (CharP (ptr) + LOCAL_HDiff)));
}
@ -932,7 +932,7 @@ inline EXTERN struct dbterm_list *PtoDBTLAdjust__ (struct dbterm_list * CACHE_TY
inline EXTERN struct dbterm_list *
PtoDBTLAdjust__ (struct dbterm_list * addr USES_REGS)
{
return (struct dbterm_list *) ((ADDR) (CharP (addr) + HDiff));
return (struct dbterm_list *) ((ADDR) (CharP (addr) + LOCAL_HDiff));
}
@ -943,7 +943,7 @@ inline EXTERN wamreg XAdjust__ (wamreg CACHE_TYPE);
inline EXTERN wamreg
XAdjust__ (wamreg reg USES_REGS)
{
return (wamreg) ((wamreg) ((reg) + XDiff));
return (wamreg) ((wamreg) ((reg) + LOCAL_XDiff));
}
@ -975,7 +975,7 @@ inline EXTERN int IsOldLocal__ (CELL CACHE_TYPE);
inline EXTERN int
IsOldLocal__ (CELL reg USES_REGS)
{
return (int) (IN_BETWEEN (OldASP, reg, OldLCL0));
return (int) (IN_BETWEEN (LOCAL_OldASP, reg, LOCAL_OldLCL0));
}
@ -985,7 +985,7 @@ inline EXTERN int IsOldLocalPtr__ (CELL * CACHE_TYPE);
inline EXTERN int
IsOldLocalPtr__ (CELL * ptr USES_REGS)
{
return (int) (IN_BETWEEN (OldASP, ptr, OldLCL0));
return (int) (IN_BETWEEN (LOCAL_OldASP, ptr, LOCAL_OldLCL0));
}
@ -997,7 +997,7 @@ inline EXTERN int IsOldLocalInTR__ (CELL CACHE_TYPE);
inline EXTERN int
IsOldLocalInTR__ (CELL reg USES_REGS)
{
return (int) (IN_BETWEEN (OldH, reg, OldLCL0));
return (int) (IN_BETWEEN (LOCAL_OldH, reg, LOCAL_OldLCL0));
}
@ -1007,7 +1007,7 @@ inline EXTERN int IsOldLocalInTRPtr__ (CELL * CACHE_TYPE);
inline EXTERN int
IsOldLocalInTRPtr__ (CELL * ptr USES_REGS)
{
return (int) (IN_BETWEEN (OldH, ptr, OldLCL0));
return (int) (IN_BETWEEN (LOCAL_OldH, ptr, LOCAL_OldLCL0));
}
@ -1018,7 +1018,7 @@ inline EXTERN int IsOldH__ (CELL CACHE_TYPE);
inline EXTERN int
IsOldH__ (CELL reg USES_REGS)
{
return (int) ((CharP (reg) == CharP (OldH)));
return (int) ((CharP (reg) == CharP (LOCAL_OldH)));
}
@ -1030,7 +1030,7 @@ inline EXTERN int IsOldGlobal__ (CELL CACHE_TYPE);
inline EXTERN int
IsOldGlobal__ (CELL reg USES_REGS)
{
return (int) (IN_BETWEEN (OldGlobalBase, reg, OldH));
return (int) (IN_BETWEEN (LOCAL_OldGlobalBase, reg, LOCAL_OldH));
}
@ -1039,7 +1039,7 @@ inline EXTERN int IsOldDelay__ (CELL CACHE_TYPE);
inline EXTERN int
IsOldDelay__ (CELL reg USES_REGS)
{
return (int) (IN_BETWEEN (OldGlobalBase, reg, OldH0));
return (int) (IN_BETWEEN (LOCAL_OldGlobalBase, reg, LOCAL_OldH0));
}
@ -1049,7 +1049,7 @@ inline EXTERN int IsOldGlobalPtr__ (CELL * CACHE_TYPE);
inline EXTERN int
IsOldGlobalPtr__ (CELL * ptr USES_REGS)
{
return (int) (IN_BETWEEN (OldGlobalBase, ptr, OldH));
return (int) (IN_BETWEEN (LOCAL_OldGlobalBase, ptr, LOCAL_OldH));
}
@ -1059,7 +1059,7 @@ inline EXTERN int IsOldTrail__ (CELL CACHE_TYPE);
inline EXTERN int
IsOldTrail__ (CELL reg USES_REGS)
{
return (int) (IN_BETWEEN (OldTrailBase, reg, OldTR));
return (int) (IN_BETWEEN (LOCAL_OldTrailBase, reg, LOCAL_OldTR));
}
@ -1069,7 +1069,7 @@ inline EXTERN int IsOldTrailPtr__ (CELL * CACHE_TYPE);
inline EXTERN int
IsOldTrailPtr__ (CELL * ptr USES_REGS)
{
return (int) (IN_BETWEEN (OldTrailBase, ptr, OldTR));
return (int) (IN_BETWEEN (LOCAL_OldTrailBase, ptr, LOCAL_OldTR));
}
@ -1079,7 +1079,7 @@ inline EXTERN int IsOldVarTableTrailPtr__ (struct VARSTRUCT * CACHE_TYPE);
inline EXTERN int
IsOldVarTableTrailPtr__ (struct VARSTRUCT *ptr USES_REGS)
{
return (int) (IN_BETWEEN (OldTrailBase, ptr, OldTR));
return (int) (IN_BETWEEN (LOCAL_OldTrailBase, ptr, LOCAL_OldTR));
}
@ -1089,7 +1089,7 @@ inline EXTERN int IsOldTokenTrailPtr__ (struct TOKEN * CACHE_TYPE);
inline EXTERN int
IsOldTokenTrailPtr__ (struct TOKEN *ptr USES_REGS)
{
return (int) (IN_BETWEEN (OldTrailBase, ptr, OldTR));
return (int) (IN_BETWEEN (LOCAL_OldTrailBase, ptr, LOCAL_OldTR));
}
@ -1100,9 +1100,9 @@ inline EXTERN int
IsOldCode__ (CELL reg USES_REGS)
{
#if USE_SYSTEM_MALLOC
return reg < (CELL)OldGlobalBase || reg > (CELL)OldTrailTop;
return reg < (CELL)LOCAL_OldGlobalBase || reg > (CELL)LOCAL_OldTrailTop;
#else
return (int) (IN_BETWEEN (OldHeapBase, reg, OldHeapTop));
return (int) (IN_BETWEEN (LOCAL_OldHeapBase, reg, LOCAL_OldHeapTop));
#endif
}
@ -1113,7 +1113,7 @@ inline EXTERN int IsOldCodeCellPtr__ (CELL * CACHE_TYPE);
inline EXTERN int
IsOldCodeCellPtr__ (CELL * ptr USES_REGS)
{
return (int) (IN_BETWEEN (OldHeapBase, ptr, OldHeapTop));
return (int) (IN_BETWEEN (LOCAL_OldHeapBase, ptr, LOCAL_OldHeapTop));
}
@ -1123,7 +1123,7 @@ inline EXTERN int IsGlobal__ (CELL CACHE_TYPE);
inline EXTERN int
IsGlobal__ (CELL reg USES_REGS)
{
return (int) (IN_BETWEEN (Yap_GlobalBase, reg, H));
return (int) (IN_BETWEEN (LOCAL_GlobalBase, reg, H));
}

View File

@ -17,13 +17,13 @@
} else if (IsPairTerm(d1)) {
CELL *pt = RepPair(d1);
#ifdef LIMIT_TABLING
if ((ADDR) pt == Yap_TrailBase) {
if ((ADDR) pt == LOCAL_TrailBase) {
sg_fr_ptr sg_fr = (sg_fr_ptr) TrailVal(pt1);
SgFr_state(sg_fr)--; /* complete_in_use --> complete : compiled_in_use --> compiled */
insert_into_global_sg_fr_list(sg_fr);
} else
#endif /* LIMIT_TABLING */
if (IN_BETWEEN(Yap_TrailBase, pt, Yap_TrailTop)) {
if (IN_BETWEEN(LOCAL_TrailBase, pt, LOCAL_TrailTop)) {
/* skip, this is a problem because we lose information,
namely active references */
pt1 = (tr_fr_ptr)pt;

View File

@ -65,9 +65,6 @@
#endif
#define YP_FILE FILE
extern YP_FILE *Yap_stdin;
extern YP_FILE *Yap_stdout;
extern YP_FILE *Yap_stderr;
int STD_PROTO(YP_putc,(int, int));
@ -167,6 +164,7 @@ extern YP_FILE yp_iob[YP_MAX_FILES];
typedef YP_FILE *YP_File;
/* ricardo
typedef enum TokenKinds {
Name_tok,
Number_tok,
@ -195,6 +193,7 @@ typedef struct VARSTRUCT {
struct VARSTRUCT *VarLeft, *VarRight;
char VarRep[1];
} VarEntry;
*/
/* Character types for tokenizer and write.c */
@ -265,7 +264,7 @@ chtype(Int ch)
/* parser stack, used to be AuxSp, now is ASP */
#define ParserAuxSp ScannerStack
#define ParserAuxSp LOCAL_ScannerStack
/* routines in parser.c */
VarEntry STD_PROTO(*Yap_LookupVar,(char *));
@ -325,8 +324,7 @@ Atom STD_PROTO(Yap_LookupWideAtom,(wchar_t *));
#define Unfold_cyclics_f 0x20
#define Use_SWI_Stream_f 0x40
/* write.c */
void STD_PROTO(Yap_plwrite,(Term,int (*)(int, wchar_t), int, int));
/* grow.c */
int STD_PROTO(Yap_growheap_in_parser, (tr_fr_ptr *, TokEntry **, VarEntry **));
@ -386,32 +384,4 @@ WideHashFunction(wchar_t *CHP)
#define CONTINUE_ON_PARSER_ERROR 2
#define EXCEPTION_ON_PARSER_ERROR 3
#ifdef THREADS
#define Yap_IOBotch Yap_thread_gl[worker_id].io_botch
#define Yap_tokptr Yap_thread_gl[worker_id].tokptr
#define Yap_toktide Yap_thread_gl[worker_id].toktide
#define Yap_VarTable Yap_thread_gl[worker_id].var_table
#define Yap_AnonVarTable Yap_thread_gl[worker_id].anon_var_table
#define Yap_eot_before_eof Yap_thread_gl[worker_id].eot_before_eof
#define Yap_FileNameBuf Yap_thread_gl[worker_id].file_name_buf
#define Yap_FileNameBuf2 Yap_thread_gl[worker_id].file_name_buf2
#else
extern jmp_buf Yap_IOBotch;
/*************** variables concerned with parsing *********************/
extern TokEntry *Yap_tokptr, *Yap_toktide;
extern VarEntry *Yap_VarTable, *Yap_AnonVarTable;
extern int Yap_eot_before_eof;
extern char Yap_FileNameBuf[YAP_FILENAME_MAX], Yap_FileNameBuf2[YAP_FILENAME_MAX];
#endif
#ifdef DEBUG
extern YP_FILE *Yap_logfile;
#endif
#if USE_SOCKET
extern int Yap_sockets_io;
#endif

View File

@ -45,18 +45,18 @@
static Int null_id = 0;
STATIC_PROTO(Int c_db_my_connect,(void));
STATIC_PROTO(Int c_db_my_disconnect,(void));
STATIC_PROTO(Int c_db_my_number_of_fields,(void));
STATIC_PROTO(Int c_db_my_get_attributes_types,(void));
STATIC_PROTO(Int c_db_my_query,(void));
STATIC_PROTO(Int c_db_my_table_write,(void));
STATIC_PROTO(Int c_db_my_row,(void));
STATIC_PROTO(Int c_db_my_row_cut,(void));
STATIC_PROTO(Int c_db_my_get_fields_properties,(void));
STATIC_PROTO(Int c_db_my_get_next_result_set,(void));
STATIC_PROTO(Int c_db_my_get_database,(void));
STATIC_PROTO(Int c_db_my_change_database,(void));
STATIC_PROTO(Int c_db_my_connect,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_disconnect,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_number_of_fields,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_get_attributes_types,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_query,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_table_write,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_row,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_row_cut,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_get_fields_properties,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_get_next_result_set,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_get_database,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_change_database,( USES_REGS1 ));
void Yap_InitMYDDAS_MySQLPreds(void)
{
@ -104,7 +104,7 @@ void Yap_InitBackMYDDAS_MySQLPreds(void)
}
static Int
c_db_my_connect(void) {
c_db_my_connect( USES_REGS1 ) {
Term arg_host = Deref(ARG1);
Term arg_user = Deref(ARG2);
Term arg_passwd = Deref(ARG3);
@ -163,7 +163,7 @@ c_db_my_connect(void) {
/* db_query: SQLQuery x ResultSet x Connection */
static Int
c_db_my_query(void) {
c_db_my_query( USES_REGS1 ) {
Term arg_sql_query = Deref(ARG1);
Term arg_result_set = Deref(ARG2);
Term arg_conn = Deref(ARG3);
@ -337,7 +337,7 @@ c_db_my_query(void) {
}
static Int
c_db_my_number_of_fields(void) {
c_db_my_number_of_fields( USES_REGS1 ) {
Term arg_relation = Deref(ARG1);
Term arg_conn = Deref(ARG2);
Term arg_fields = Deref(ARG3);
@ -381,7 +381,7 @@ c_db_my_number_of_fields(void) {
/* db_get_attributes_types: RelName x Connection -> TypesList */
static Int
c_db_my_get_attributes_types(void) {
c_db_my_get_attributes_types( USES_REGS1 ) {
Term arg_relation = Deref(ARG1);
Term arg_conn = Deref(ARG2);
Term arg_types_list = Deref(ARG3);
@ -442,7 +442,7 @@ c_db_my_get_attributes_types(void) {
/* db_disconnect */
static Int
c_db_my_disconnect(void) {
c_db_my_disconnect( USES_REGS1 ) {
Term arg_conn = Deref(ARG1);
MYSQL *conn = (MYSQL *) IntegerOfTerm(arg_conn);
@ -461,7 +461,7 @@ c_db_my_disconnect(void) {
/* db_table_write: Result Set */
static Int
c_db_my_table_write(void) {
c_db_my_table_write( USES_REGS1 ) {
Term arg_res_set = Deref(ARG1);
MYSQL_RES *res_set = (MYSQL_RES *) IntegerOfTerm(arg_res_set);
@ -473,7 +473,7 @@ c_db_my_table_write(void) {
}
static Int
c_db_my_row_cut(void) {
c_db_my_row_cut( USES_REGS1 ) {
MYSQL_RES *mysql_res=NULL;
mysql_res = (MYSQL_RES *) IntegerOfTerm(EXTRA_CBACK_CUT_ARG(Term,1));
@ -483,7 +483,7 @@ c_db_my_row_cut(void) {
/* db_row: ResultSet x Arity_ListOfArgs x ListOfArgs -> */
static Int
c_db_my_row(void) {
c_db_my_row( USES_REGS1 ) {
#ifdef MYDDAS_STATS
/* Measure time used by the */
/* c_db_my_row function */
@ -598,7 +598,7 @@ c_db_my_row(void) {
}
static Int
c_db_my_get_fields_properties(void) {
c_db_my_get_fields_properties( USES_REGS1 ) {
Term nome_relacao = Deref(ARG1);
Term arg_conn = Deref(ARG2);
Term fields_properties_list = Deref(ARG3);
@ -680,7 +680,7 @@ c_db_my_get_fields_properties(void) {
/* c_db_my_get_next_result_set: Connection * NextResSet */
static Int
c_db_my_get_next_result_set(void) {
c_db_my_get_next_result_set( USES_REGS1 ) {
Term arg_conn = Deref(ARG1);
Term arg_next_res_set = Deref(ARG2);
@ -695,7 +695,7 @@ c_db_my_get_next_result_set(void) {
}
static Int
c_db_my_get_database(void) {
c_db_my_get_database( USES_REGS1 ) {
Term arg_con = Deref(ARG1);
Term arg_database = Deref(ARG2);
@ -709,7 +709,7 @@ c_db_my_get_database(void) {
}
static Int
c_db_my_change_database(void) {
c_db_my_change_database( USES_REGS1 ) {
Term arg_con = Deref(ARG1);
Term arg_database = Deref(ARG2);

View File

@ -173,6 +173,8 @@ static Term get_point(char *func){
}
static Term get_linestring(char *func){
CACHE_REGS
Term *c_list;
Term list;
Functor functor;
@ -203,6 +205,8 @@ static Term get_linestring(char *func){
}
static Term get_polygon(char *func){
CACHE_REGS
uint32 r;
int i;
Functor functor;
@ -233,6 +237,8 @@ static Term get_polygon(char *func){
}
static Term get_geometry(uint32 type){
CACHE_REGS
switch(type) {
case WKBPOINT:
return get_point("point");

View File

@ -260,7 +260,7 @@ C_SOURCES= \
$(srcdir)/BEAM/eam_am.c $(srcdir)/BEAM/eam_showcode.c \
$(srcdir)/BEAM/eamindex.c $(srcdir)/BEAM/eamamasm.c \
$(srcdir)/BEAM/eam_gc.c $(srcdir)/BEAM/eam_split.c \
$(srcdir)/OPTYap/opt.memory.c $(srcdir)/OPTYap/opt.init.c \
$(srcdir)/OPTYap/or.memory.c $(srcdir)/OPTYap/opt.init.c \
$(srcdir)/OPTYap/opt.preds.c $(srcdir)/OPTYap/or.copy_engine.c \
$(srcdir)/OPTYap/or.cow_engine.c $(srcdir)/OPTYap/or.sba_engine.c \
$(srcdir)/OPTYap/or.thread_engine.c \
@ -378,7 +378,7 @@ C_INTERFACE_OBJECTS = \
c_interface.o clause_list.o
OR_OBJECTS = \
opt.memory.o opt.init.o opt.preds.o \
or.memory.o opt.init.o opt.preds.o \
or.copy_engine.o or.cow_engine.o or.sba_engine.o or.thread_engine.o \
or.scheduler.o or.cut.o \
tab.tries.o tab.completion.o
@ -489,8 +489,8 @@ myddas_wkb2prolog.o: $(srcdir)/MYDDAS/myddas_wkb2prolog.c config.h
myddas_statistics.o: $(srcdir)/MYDDAS/myddas_statistics.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_statistics.c -o $@
opt.memory.o: $(srcdir)/OPTYap/opt.memory.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/opt.memory.c -o $@
or.memory.o: $(srcdir)/OPTYap/or.memory.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.memory.c -o $@
opt.init.o: $(srcdir)/OPTYap/opt.init.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/opt.init.c -o $@

View File

@ -17,9 +17,9 @@
** General Configuration Parameters **
************************************************************************/
/****************************************************************
** use shared pages memory alloc scheme ? (optional) **
****************************************************************/
/******************************************************************************************
** use shared pages memory alloc scheme for OPTYap data structures? (optional) **
******************************************************************************************/
/* #define USE_PAGES_MALLOC 1 */
@ -92,7 +92,7 @@
** memory mapping scheme (mandatory, define one) **
************************************************************/
#define MMAP_MEMORY_MAPPING_SCHEME 1
/* #define SHM_MEMORY_MAPPING_SCHEME 1 */
/* #define SHM_MEMORY_MAPPING_SCHEME 1 */
/*************************************************
** enable error checking ? (optional) **

View File

@ -59,99 +59,100 @@
** Global functions **
*******************************/
void Yap_init_optyap_data(int max_table_size, int n_workers, int sch_loop, int delay_load) {
void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop, int delay_load) {
int i;
/* global data related to memory management */
#ifdef LIMIT_TABLING
if (max_table_size)
Yap_max_pages = ((max_table_size - 1) * 1024 * 1024 / SHMMAX + 1) * SHMMAX / Yap_page_size;
GLOBAL_max_pages = ((max_table_size - 1) * 1024 * 1024 / SHMMAX + 1) * SHMMAX / Yap_page_size;
else
Yap_max_pages = -1;
GLOBAL_max_pages = -1;
#endif /* LIMIT_TABLING */
INIT_PAGES(Yap_pages_void, void *);
INIT_PAGES(GLOBAL_pages_void, void *);
#ifdef YAPOR
INIT_PAGES(Yap_pages_or_fr , struct or_frame);
INIT_PAGES(Yap_pages_qg_sol_fr , struct query_goal_solution_frame);
INIT_PAGES(Yap_pages_qg_ans_fr, struct query_goal_answer_frame);
INIT_PAGES(GLOBAL_pages_or_fr, struct or_frame);
INIT_PAGES(GLOBAL_pages_qg_sol_fr, struct query_goal_solution_frame);
INIT_PAGES(GLOBAL_pages_qg_ans_fr, struct query_goal_answer_frame);
#endif /* YAPOR */
#ifdef TABLING_INNER_CUTS
INIT_PAGES(Yap_pages_tg_sol_fr, struct table_subgoal_solution_frame);
INIT_PAGES(Yap_pages_tg_ans_fr, struct table_subgoal_answer_frame);
INIT_PAGES(GLOBAL_pages_tg_sol_fr, struct table_subgoal_solution_frame);
INIT_PAGES(GLOBAL_pages_tg_ans_fr, struct table_subgoal_answer_frame);
#endif /* TABLING_INNER_CUTS */
#ifdef TABLING
INIT_PAGES(Yap_pages_tab_ent, struct table_entry);
INIT_PAGES(Yap_pages_sg_fr, struct subgoal_frame);
INIT_PAGES(Yap_pages_dep_fr, struct dependency_frame);
INIT_PAGES(Yap_pages_sg_node, struct subgoal_trie_node);
INIT_PAGES(Yap_pages_ans_node, struct answer_trie_node);
INIT_PAGES(Yap_pages_gt_node, struct global_trie_node);
INIT_PAGES(Yap_pages_sg_hash, struct subgoal_trie_hash);
INIT_PAGES(Yap_pages_ans_hash, struct answer_trie_hash);
INIT_PAGES(Yap_pages_gt_hash, struct global_trie_hash);
INIT_PAGES(GLOBAL_pages_tab_ent, struct table_entry);
INIT_PAGES(GLOBAL_pages_sg_fr, struct subgoal_frame);
INIT_PAGES(GLOBAL_pages_dep_fr, struct dependency_frame);
INIT_PAGES(GLOBAL_pages_sg_node, struct subgoal_trie_node);
INIT_PAGES(GLOBAL_pages_ans_node, struct answer_trie_node);
INIT_PAGES(GLOBAL_pages_gt_node, struct global_trie_node);
INIT_PAGES(GLOBAL_pages_sg_hash, struct subgoal_trie_hash);
INIT_PAGES(GLOBAL_pages_ans_hash, struct answer_trie_hash);
INIT_PAGES(GLOBAL_pages_gt_hash, struct global_trie_hash);
#endif /* TABLING */
#if defined(YAPOR) && defined(TABLING)
INIT_PAGES(Yap_pages_susp_fr, struct suspension_frame);
INIT_PAGES(GLOBAL_pages_susp_fr, struct suspension_frame);
#endif /* YAPOR && TABLING */
#ifdef YAPOR
/* global static data */
Yap_number_workers= n_workers;
Yap_worker_pid(0) = getpid();
for (i = 1; i < Yap_number_workers; i++) Yap_worker_pid(i) = 0;
Yap_scheduler_loop = sch_loop;
Yap_delayed_release_load = delay_load;
GLOBAL_number_workers= n_workers;
GLOBAL_worker_pid(0) = getpid();
for (i = 1; i < GLOBAL_number_workers; i++) GLOBAL_worker_pid(i) = 0;
GLOBAL_scheduler_loop = sch_loop;
GLOBAL_delayed_release_load = delay_load;
/* global data related to or-performance */
Yap_number_goals = 0;
Yap_best_times(0) = 0;
Yap_performance_mode = PERFORMANCE_OFF;
GLOBAL_number_goals = 0;
GLOBAL_best_times(0) = 0;
GLOBAL_performance_mode = PERFORMANCE_OFF;
/* global data related to or-parallelism */
BITMAP_clear(Yap_bm_present_workers);
for (i = 0; i < Yap_number_workers; i++)
BITMAP_insert(Yap_bm_present_workers, i);
BITMAP_copy(Yap_bm_idle_workers, Yap_bm_present_workers);
BITMAP_clear(Yap_bm_root_cp_workers);
BITMAP_clear(Yap_bm_invisible_workers);
BITMAP_clear(Yap_bm_requestable_workers);
BITMAP_clear(Yap_bm_executing_workers);
BITMAP_copy(Yap_bm_finished_workers, Yap_bm_present_workers);
INIT_LOCK(Yap_locks_bm_idle_workers);
INIT_LOCK(Yap_locks_bm_root_cp_workers);
INIT_LOCK(Yap_locks_bm_invisible_workers);
INIT_LOCK(Yap_locks_bm_requestable_workers);
INIT_LOCK(Yap_locks_bm_executing_workers);
INIT_LOCK(Yap_locks_bm_finished_workers);
ALLOC_OR_FRAME(GLOBAL_root_or_fr);
BITMAP_clear(GLOBAL_bm_present_workers);
for (i = 0; i < GLOBAL_number_workers; i++)
BITMAP_insert(GLOBAL_bm_present_workers, i);
BITMAP_copy(GLOBAL_bm_idle_workers, GLOBAL_bm_present_workers);
BITMAP_clear(GLOBAL_bm_root_cp_workers);
BITMAP_clear(GLOBAL_bm_invisible_workers);
BITMAP_clear(GLOBAL_bm_requestable_workers);
BITMAP_clear(GLOBAL_bm_executing_workers);
BITMAP_copy(GLOBAL_bm_finished_workers, GLOBAL_bm_present_workers);
INIT_LOCK(GLOBAL_locks_bm_idle_workers);
INIT_LOCK(GLOBAL_locks_bm_root_cp_workers);
INIT_LOCK(GLOBAL_locks_bm_invisible_workers);
INIT_LOCK(GLOBAL_locks_bm_requestable_workers);
INIT_LOCK(GLOBAL_locks_bm_executing_workers);
INIT_LOCK(GLOBAL_locks_bm_finished_workers);
#ifdef TABLING_INNER_CUTS
INIT_LOCK(Yap_locks_bm_pruning_workers);
INIT_LOCK(GLOBAL_locks_bm_pruning_workers);
#endif /* TABLING_INNER_CUTS */
Yap_locks_who_locked_heap = MAX_WORKERS;
INIT_LOCK(Yap_locks_heap_access);
INIT_LOCK(Yap_locks_alloc_block);
if (Yap_number_workers== 1)
Yap_parallel_execution_mode = FALSE;
GLOBAL_locks_who_locked_heap = MAX_WORKERS;
INIT_LOCK(GLOBAL_locks_heap_access);
INIT_LOCK(GLOBAL_locks_alloc_block);
if (GLOBAL_number_workers== 1)
GLOBAL_parallel_execution_mode = FALSE;
else
Yap_parallel_execution_mode = TRUE;
GLOBAL_parallel_execution_mode = TRUE;
#endif /* YAPOR */
#ifdef TABLING
/* global data related to tabling */
new_global_trie_node(Yap_root_gt, 0, NULL, NULL, NULL);
Yap_root_tab_ent = NULL;
new_global_trie_node(GLOBAL_root_gt, 0, NULL, NULL, NULL);
GLOBAL_root_tab_ent = NULL;
#ifdef LIMIT_TABLING
Yap_first_sg_fr = NULL;
Yap_last_sg_fr = NULL;
Yap_check_sg_fr = NULL;
GLOBAL_first_sg_fr = NULL;
GLOBAL_last_sg_fr = NULL;
GLOBAL_check_sg_fr = NULL;
#endif /* LIMIT_TABLING */
Yap_root_dep_fr = NULL;
new_dependency_frame(GLOBAL_root_dep_fr, FALSE, NULL, NULL, NULL, NULL, NULL);
for (i = 0; i < MAX_TABLE_VARS; i++) {
CELL *pt = Yap_table_var_enumerator_addr(i);
CELL *pt = GLOBAL_table_var_enumerator_addr(i);
RESET_VARIABLE(pt);
}
#ifdef TABLE_LOCK_AT_WRITE_LEVEL
for (i = 0; i < TABLE_LOCK_BUCKETS; i++)
INIT_LOCK(Yap_table_lock(i));
INIT_LOCK(GLOBAL_table_lock(i));
#endif /* TABLE_LOCK_AT_WRITE_LEVEL */
#endif /* TABLING */
@ -159,47 +160,46 @@ void Yap_init_optyap_data(int max_table_size, int n_workers, int sch_loop, int d
}
void Yap_init_local(void) {
void Yap_init_local_optyap_data(int wid) {
#ifdef YAPOR
CACHE_REGS
/* local data related to or-parallelism */
LOCAL = REMOTE + worker_id;
Set_LOCAL_top_cp((choiceptr) Yap_LocalBase);
LOCAL_top_or_fr = Yap_root_or_fr;
LOCAL_load = 0;
LOCAL_share_request = MAX_WORKERS;
LOCAL_reply_signal = worker_ready;
Set_REMOTE_top_cp(wid, (choiceptr) LOCAL_LocalBase);
REMOTE_top_or_fr(wid) = GLOBAL_root_or_fr;
REMOTE_load(wid) = 0;
REMOTE_share_request(wid) = MAX_WORKERS;
REMOTE_reply_signal(wid) = worker_ready;
#ifdef YAPOR_COPY
INIT_LOCK(LOCAL_lock_signals);
INIT_LOCK(REMOTE_lock_signals(wid));
#endif /* YAPOR_COPY */
Set_LOCAL_prune_request(NULL);
Set_REMOTE_prune_request(wid, NULL);
INIT_LOCK(REMOTE_lock(wid));
#endif /* YAPOR */
INIT_LOCK(LOCAL_lock);
#ifdef TABLING
/* local data related to tabling */
LOCAL_next_free_ans_node = NULL;
LOCAL_top_sg_fr = NULL;
LOCAL_top_dep_fr = Yap_root_dep_fr;
REMOTE_next_free_ans_node(wid) = NULL;
REMOTE_top_sg_fr(wid) = NULL;
REMOTE_top_dep_fr(wid) = GLOBAL_root_dep_fr;
#ifdef YAPOR
Set_LOCAL_top_cp_on_stack((choiceptr) Yap_LocalBase); /* ??? */
LOCAL_top_susp_or_fr = Yap_root_or_fr;
Set_REMOTE_top_cp_on_stack(wid, (choiceptr) LOCAL_LocalBase); /* ??? */
REMOTE_top_susp_or_fr(wid) = GLOBAL_root_or_fr;
#endif /* YAPOR */
#endif /* TABLING */
return;
}
void make_root_frames(void) {
#ifdef YAPOR
void Yap_init_root_frames(void) {
CACHE_REGS
/* root or frame */
or_fr_ptr or_fr;
ALLOC_OR_FRAME(or_fr);
#ifdef YAPOR
/* root or frame */
or_fr_ptr or_fr = GLOBAL_root_or_fr;
INIT_LOCK(OrFr_lock(or_fr));
OrFr_alternative(or_fr) = NULL;
BITMAP_copy(OrFr_members(or_fr), Yap_bm_present_workers);
SetOrFr_node(or_fr, (choiceptr) Yap_LocalBase);
BITMAP_copy(OrFr_members(or_fr), GLOBAL_bm_present_workers);
SetOrFr_node(or_fr, (choiceptr) LOCAL_LocalBase);
OrFr_nearest_livenode(or_fr) = NULL;
OrFr_depth(or_fr) = 0;
Set_OrFr_pend_prune_cp(or_fr, NULL);
@ -209,69 +209,20 @@ void make_root_frames(void) {
OrFr_tg_solutions(or_fr) = NULL;
#endif /* TABLING_INNER_CUTS */
#ifdef TABLING
OrFr_owners(or_fr) = Yap_number_workers;
OrFr_owners(or_fr) = GLOBAL_number_workers;
OrFr_next_on_stack(or_fr) = NULL;
OrFr_suspensions(or_fr) = NULL;
OrFr_nearest_suspnode(or_fr) = or_fr;
#endif /* TABLING */
OrFr_next(or_fr) = NULL;
Yap_root_or_fr = or_fr;
#endif /* YAPOR */
#ifdef TABLING
/* root dependency frame */
if (!Yap_root_dep_fr) {
new_dependency_frame(Yap_root_dep_fr, FALSE, NULL, NULL, NULL, NULL, NULL);
#ifdef TABLING
DepFr_cons_cp(Yap_root_dep_fr) = B;
#endif /* TABLING */
}
DepFr_cons_cp(GLOBAL_root_dep_fr) = B;
#endif /* TABLING */
}
#ifdef YAPOR
void init_workers(void) {
CACHE_REGS
int proc;
#ifdef YAPOR_THREADS
return;
#endif /* YAPOR_THREADS */
#ifdef YAPOR_COW
if (Yap_number_workers> 1) {
int son;
son = fork();
if (son == -1)
Yap_Error(FATAL_ERROR, TermNil, "fork error (init_workers)");
if (son > 0) {
/* I am the father, I must stay here and wait for my children to all die */
struct sigaction sigact;
Yap_master_worker = getpid();
sigact.sa_handler = SIG_DFL;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = SA_RESTART;
sigaction(SIGINT, &sigact, NULL);
pause();
exit(0);
} else Yap_worker_pid(0) = getpid();
}
#endif /* YAPOR_COW */
for (proc = 1; proc < Yap_number_workers; proc++) {
int son;
son = fork();
if (son == -1)
Yap_Error(FATAL_ERROR, TermNil, "fork error (init_workers)");
if (son == 0) {
/* new worker */
worker_id = proc;
Yap_remap_optyap_memory();
break;
}
else Yap_worker_pid(proc) = son;
}
}
#endif /* YAPOR */
void itos(int i, char *s) {
int n,r,j;

View File

@ -86,11 +86,11 @@ extern int Yap_page_size;
** USE_PAGES_MALLOC **
*************************************************************************************************/
#define FREE_PAGE(PG_HD) \
LOCK(Pg_lock(Yap_pages_void)); \
UPDATE_STATS(Pg_str_in_use(Yap_pages_void), -1); \
PgHd_next(PG_HD) = Pg_free_pg(Yap_pages_void); \
Pg_free_pg(Yap_pages_void) = PG_HD; \
UNLOCK(Pg_lock(Yap_pages_void))
LOCK(Pg_lock(GLOBAL_pages_void)); \
UPDATE_STATS(Pg_str_in_use(GLOBAL_pages_void), -1); \
PgHd_next(PG_HD) = Pg_free_pg(GLOBAL_pages_void); \
Pg_free_pg(GLOBAL_pages_void) = PG_HD; \
UNLOCK(Pg_lock(GLOBAL_pages_void))
#define FREE_STRUCT(STR, STR_PAGES, STR_TYPE) \
{ pg_hd_ptr pg_hd; \
@ -152,28 +152,28 @@ extern int Yap_page_size;
if (shmctl(shmid, IPC_RMID, 0) != 0) \
Yap_Error(FATAL_ERROR, TermNil, "shmctl error (ALLOC_PAGE)"); \
aux_pg_hd = (pg_hd_ptr)(((void *)PG_HD) + Yap_page_size); \
Pg_free_pg(Yap_pages_void) = aux_pg_hd; \
Pg_free_pg(GLOBAL_pages_void) = aux_pg_hd; \
for (i = 2; i < SHMMAX / Yap_page_size; i++) { \
PgHd_next(aux_pg_hd) = (pg_hd_ptr)(((void *)aux_pg_hd) + Yap_page_size); \
aux_pg_hd = PgHd_next(aux_pg_hd); \
} \
PgHd_next(aux_pg_hd) = NULL; \
UPDATE_STATS(Pg_pg_alloc(Yap_pages_void), SHMMAX / Yap_page_size); \
UPDATE_STATS(Pg_pg_alloc(GLOBAL_pages_void), SHMMAX / Yap_page_size); \
}
#define RECOVER_UNUSED_SPACE(STR_PAGES) \
{ sg_fr_ptr sg_fr = Yap_check_sg_fr; \
{ sg_fr_ptr sg_fr = GLOBAL_check_sg_fr; \
do { \
if (sg_fr) \
sg_fr = SgFr_next(sg_fr); \
else \
sg_fr = Yap_first_sg_fr; \
sg_fr = GLOBAL_first_sg_fr; \
if (sg_fr == NULL) \
Yap_Error(FATAL_ERROR, TermNil, "no space left (RECOVER_UNUSED_SPACE)"); \
/* see function 'InteractSIGINT' in file 'sysbits.c' */ \
/* Yap_Error(PURE_ABORT, TermNil, ""); */ \
/* restore_absmi_regs(&Yap_standard_regs); */ \
/* siglongjmp (Yap_RestartEnv, 1); */ \
/* siglongjmp (LOCAL_RestartEnv, 1); */ \
if (SgFr_first_answer(sg_fr) && \
SgFr_first_answer(sg_fr) != SgFr_answer_trie(sg_fr)) { \
SgFr_state(sg_fr) = ready; \
@ -185,8 +185,8 @@ extern int Yap_page_size;
TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST); \
TrNode_child(SgFr_answer_trie(sg_fr)) = NULL; \
} \
} while (Pg_free_pg(Yap_pages_void) == Pg_free_pg(STR_PAGES)); \
Yap_check_sg_fr = sg_fr; \
} while (Pg_free_pg(GLOBAL_pages_void) == Pg_free_pg(STR_PAGES)); \
GLOBAL_check_sg_fr = sg_fr; \
}
#define ALLOC_STRUCT(STR, STR_PAGES, STR_TYPE) \
@ -195,20 +195,20 @@ extern int Yap_page_size;
pg_hd = Pg_free_pg(STR_PAGES); \
while (pg_hd == NULL) { \
UNLOCK(Pg_lock(STR_PAGES)); \
LOCK(Pg_lock(Yap_pages_void)); \
if (Pg_free_pg(Yap_pages_void)) { \
pg_hd = Pg_free_pg(Yap_pages_void); \
Pg_free_pg(Yap_pages_void) = PgHd_next(pg_hd); \
UPDATE_STATS(Pg_str_in_use(Yap_pages_void), 1); \
UNLOCK(Pg_lock(Yap_pages_void)); \
LOCK(Pg_lock(GLOBAL_pages_void)); \
if (Pg_free_pg(GLOBAL_pages_void)) { \
pg_hd = Pg_free_pg(GLOBAL_pages_void); \
Pg_free_pg(GLOBAL_pages_void) = PgHd_next(pg_hd); \
UPDATE_STATS(Pg_str_in_use(GLOBAL_pages_void), 1); \
UNLOCK(Pg_lock(GLOBAL_pages_void)); \
INIT_PAGE(pg_hd, STR_PAGES, STR_TYPE); \
} else if (Yap_max_pages != Pg_pg_alloc(Yap_pages_void)) { \
} else if ( GLOBAL_max_pages != Pg_pg_alloc(GLOBAL_pages_void)) { \
ALLOC_PAGE(pg_hd); \
UPDATE_STATS(Pg_str_in_use(Yap_pages_void), 1); \
UNLOCK(Pg_lock(Yap_pages_void)); \
UPDATE_STATS(Pg_str_in_use(GLOBAL_pages_void), 1); \
UNLOCK(Pg_lock(GLOBAL_pages_void)); \
INIT_PAGE(pg_hd, STR_PAGES, STR_TYPE); \
} else { \
UNLOCK(Pg_lock(Yap_pages_void)); \
UNLOCK(Pg_lock(GLOBAL_pages_void)); \
RECOVER_UNUSED_SPACE(STR_PAGES); \
LOCK(Pg_lock(STR_PAGES)); \
pg_hd = Pg_free_pg(STR_PAGES); \
@ -230,20 +230,20 @@ extern int Yap_page_size;
pg_hd = Pg_free_pg(STR_PAGES); \
while (pg_hd == NULL) { \
UNLOCK(Pg_lock(STR_PAGES)); \
LOCK(Pg_lock(Yap_pages_void)); \
if (Pg_free_pg(Yap_pages_void)) { \
pg_hd = Pg_free_pg(Yap_pages_void); \
Pg_free_pg(Yap_pages_void) = PgHd_next(pg_hd); \
UPDATE_STATS(Pg_str_in_use(Yap_pages_void), 1); \
UNLOCK(Pg_lock(Yap_pages_void)); \
LOCK(Pg_lock(GLOBAL_pages_void)); \
if (Pg_free_pg(GLOBAL_pages_void)) { \
pg_hd = Pg_free_pg(GLOBAL_pages_void); \
Pg_free_pg(GLOBAL_pages_void) = PgHd_next(pg_hd); \
UPDATE_STATS(Pg_str_in_use(GLOBAL_pages_void), 1); \
UNLOCK(Pg_lock(GLOBAL_pages_void)); \
INIT_PAGE(pg_hd, STR_PAGES, STR_TYPE); \
} else if (Yap_max_pages != Pg_pg_alloc(Yap_pages_void)) { \
} else if ( GLOBAL_max_pages != Pg_pg_alloc(GLOBAL_pages_void)) { \
ALLOC_PAGE(pg_hd); \
UPDATE_STATS(Pg_str_in_use(Yap_pages_void), 1); \
UNLOCK(Pg_lock(Yap_pages_void)); \
UPDATE_STATS(Pg_str_in_use(GLOBAL_pages_void), 1); \
UNLOCK(Pg_lock(GLOBAL_pages_void)); \
INIT_PAGE(pg_hd, STR_PAGES, STR_TYPE); \
} else { \
UNLOCK(Pg_lock(Yap_pages_void)); \
UNLOCK(Pg_lock(GLOBAL_pages_void)); \
RECOVER_UNUSED_SPACE(STR_PAGES); \
LOCK(Pg_lock(STR_PAGES)); \
pg_hd = Pg_free_pg(STR_PAGES); \
@ -263,8 +263,8 @@ extern int Yap_page_size;
** USE_PAGES_MALLOC && ! LIMIT_TABLING **
*************************************************************************************************/
#define ALLOC_PAGE(PG_HD) \
LOCK(Pg_lock(Yap_pages_void)); \
if (Pg_free_pg(Yap_pages_void) == NULL) { \
LOCK(Pg_lock(GLOBAL_pages_void)); \
if (Pg_free_pg(GLOBAL_pages_void) == NULL) { \
int i, shmid; \
pg_hd_ptr pg_hd, aux_pg_hd; \
if ((shmid = shmget(IPC_PRIVATE, SHMMAX, SHM_R|SHM_W)) == -1) \
@ -273,19 +273,19 @@ extern int Yap_page_size;
Yap_Error(FATAL_ERROR, TermNil, "shmat error (ALLOC_PAGE)"); \
if (shmctl(shmid, IPC_RMID, 0) != 0) \
Yap_Error(FATAL_ERROR, TermNil, "shmctl error (ALLOC_PAGE)"); \
Pg_free_pg(Yap_pages_void) = pg_hd; \
Pg_free_pg(GLOBAL_pages_void) = pg_hd; \
for (i = 1; i < SHMMAX / Yap_page_size; i++) { \
aux_pg_hd = (pg_hd_ptr)(((void *)pg_hd) + Yap_page_size); \
PgHd_next(pg_hd) = aux_pg_hd; \
pg_hd = aux_pg_hd; \
} \
PgHd_next(pg_hd) = NULL; \
UPDATE_STATS(Pg_pg_alloc(Yap_pages_void), SHMMAX / Yap_page_size); \
UPDATE_STATS(Pg_pg_alloc(GLOBAL_pages_void), SHMMAX / Yap_page_size); \
} \
UPDATE_STATS(Pg_str_in_use(Yap_pages_void), 1); \
PG_HD = Pg_free_pg(Yap_pages_void); \
Pg_free_pg(Yap_pages_void) = PgHd_next(PG_HD); \
UNLOCK(Pg_lock(Yap_pages_void))
UPDATE_STATS(Pg_str_in_use(GLOBAL_pages_void), 1); \
PG_HD = Pg_free_pg(GLOBAL_pages_void); \
Pg_free_pg(GLOBAL_pages_void) = PgHd_next(PG_HD); \
UNLOCK(Pg_lock(GLOBAL_pages_void))
#define ALLOC_STRUCT(STR, STR_PAGES, STR_TYPE) \
{ pg_hd_ptr pg_hd; \
@ -380,55 +380,55 @@ extern int Yap_page_size;
}
#define FREE_HASH_BUCKETS(BUCKET_PTR) FREE_BLOCK(BUCKET_PTR)
#define ALLOC_OR_FRAME(STR) ALLOC_STRUCT(STR, Yap_pages_or_fr , struct or_frame)
#define FREE_OR_FRAME(STR) FREE_STRUCT(STR, Yap_pages_or_fr , struct or_frame)
#define ALLOC_OR_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_pages_or_fr , struct or_frame)
#define FREE_OR_FRAME(STR) FREE_STRUCT(STR, GLOBAL_pages_or_fr , struct or_frame)
#define ALLOC_QG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, Yap_pages_qg_sol_fr , struct query_goal_solution_frame)
#define FREE_QG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, Yap_pages_qg_sol_fr , struct query_goal_solution_frame)
#define ALLOC_QG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_pages_qg_sol_fr , struct query_goal_solution_frame)
#define FREE_QG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, GLOBAL_pages_qg_sol_fr , struct query_goal_solution_frame)
#define ALLOC_QG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, Yap_pages_qg_ans_fr, struct query_goal_answer_frame)
#define FREE_QG_ANSWER_FRAME(STR) FREE_STRUCT(STR, Yap_pages_qg_ans_fr, struct query_goal_answer_frame)
#define ALLOC_QG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_pages_qg_ans_fr, struct query_goal_answer_frame)
#define FREE_QG_ANSWER_FRAME(STR) FREE_STRUCT(STR, GLOBAL_pages_qg_ans_fr, struct query_goal_answer_frame)
#define ALLOC_TG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, Yap_pages_tg_sol_fr, struct table_subgoal_solution_frame)
#define FREE_TG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, Yap_pages_tg_sol_fr, struct table_subgoal_solution_frame)
#define ALLOC_TG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_pages_tg_sol_fr, struct table_subgoal_solution_frame)
#define FREE_TG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, GLOBAL_pages_tg_sol_fr, struct table_subgoal_solution_frame)
#define ALLOC_TG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, Yap_pages_tg_ans_fr, struct table_subgoal_answer_frame)
#define FREE_TG_ANSWER_FRAME(STR) FREE_STRUCT(STR, Yap_pages_tg_ans_fr, struct table_subgoal_answer_frame)
#define ALLOC_TG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_pages_tg_ans_fr, struct table_subgoal_answer_frame)
#define FREE_TG_ANSWER_FRAME(STR) FREE_STRUCT(STR, GLOBAL_pages_tg_ans_fr, struct table_subgoal_answer_frame)
#define ALLOC_TABLE_ENTRY(STR) ALLOC_STRUCT(STR, Yap_pages_tab_ent, struct table_entry)
#define FREE_TABLE_ENTRY(STR) FREE_STRUCT(STR, Yap_pages_tab_ent, struct table_entry)
#define ALLOC_TABLE_ENTRY(STR) ALLOC_STRUCT(STR, GLOBAL_pages_tab_ent, struct table_entry)
#define FREE_TABLE_ENTRY(STR) FREE_STRUCT(STR, GLOBAL_pages_tab_ent, struct table_entry)
#define ALLOC_SUBGOAL_FRAME(STR) ALLOC_STRUCT(STR, Yap_pages_sg_fr, struct subgoal_frame)
#define FREE_SUBGOAL_FRAME(STR) FREE_STRUCT(STR, Yap_pages_sg_fr, struct subgoal_frame)
#define ALLOC_SUBGOAL_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_pages_sg_fr, struct subgoal_frame)
#define FREE_SUBGOAL_FRAME(STR) FREE_STRUCT(STR, GLOBAL_pages_sg_fr, struct subgoal_frame)
#define ALLOC_DEPENDENCY_FRAME(STR) ALLOC_STRUCT(STR, Yap_pages_dep_fr, struct dependency_frame)
#define FREE_DEPENDENCY_FRAME(STR) FREE_STRUCT(STR, Yap_pages_dep_fr, struct dependency_frame)
#define ALLOC_DEPENDENCY_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_pages_dep_fr, struct dependency_frame)
#define FREE_DEPENDENCY_FRAME(STR) FREE_STRUCT(STR, GLOBAL_pages_dep_fr, struct dependency_frame)
#define ALLOC_SUSPENSION_FRAME(STR) ALLOC_STRUCT(STR, Yap_pages_susp_fr, struct suspension_frame)
#define ALLOC_SUSPENSION_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_pages_susp_fr, struct suspension_frame)
#define FREE_SUSPENSION_FRAME(STR) FREE_BLOCK(SuspFr_global_start(STR)); \
FREE_STRUCT(STR, Yap_pages_susp_fr, struct suspension_frame)
FREE_STRUCT(STR, GLOBAL_pages_susp_fr, struct suspension_frame)
#define ALLOC_GLOBAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, Yap_pages_gt_node, struct global_trie_node)
#define FREE_GLOBAL_TRIE_NODE(STR) FREE_STRUCT(STR, Yap_pages_gt_node, struct global_trie_node)
#define ALLOC_GLOBAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, GLOBAL_pages_gt_node, struct global_trie_node)
#define FREE_GLOBAL_TRIE_NODE(STR) FREE_STRUCT(STR, GLOBAL_pages_gt_node, struct global_trie_node)
#define ALLOC_SUBGOAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, Yap_pages_sg_node, struct subgoal_trie_node)
#define FREE_SUBGOAL_TRIE_NODE(STR) FREE_STRUCT(STR, Yap_pages_sg_node, struct subgoal_trie_node)
#define ALLOC_SUBGOAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, GLOBAL_pages_sg_node, struct subgoal_trie_node)
#define FREE_SUBGOAL_TRIE_NODE(STR) FREE_STRUCT(STR, GLOBAL_pages_sg_node, struct subgoal_trie_node)
#ifdef YAPOR
#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_NEXT_FREE_STRUCT(STR, Yap_pages_ans_node, struct answer_trie_node)
#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_NEXT_FREE_STRUCT(STR, GLOBAL_pages_ans_node, struct answer_trie_node)
#else /* TABLING */
#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_STRUCT(STR, Yap_pages_ans_node, struct answer_trie_node)
#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_STRUCT(STR, GLOBAL_pages_ans_node, struct answer_trie_node)
#endif /* YAPOR - TABLING */
#define FREE_ANSWER_TRIE_NODE(STR) FREE_STRUCT(STR, Yap_pages_ans_node, struct answer_trie_node)
#define FREE_ANSWER_TRIE_NODE(STR) FREE_STRUCT(STR, GLOBAL_pages_ans_node, struct answer_trie_node)
#define ALLOC_GLOBAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, Yap_pages_gt_hash, struct global_trie_hash)
#define FREE_GLOBAL_TRIE_HASH(STR) FREE_STRUCT(STR, Yap_pages_gt_hash, struct global_trie_hash)
#define ALLOC_GLOBAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, GLOBAL_pages_gt_hash, struct global_trie_hash)
#define FREE_GLOBAL_TRIE_HASH(STR) FREE_STRUCT(STR, GLOBAL_pages_gt_hash, struct global_trie_hash)
#define ALLOC_SUBGOAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, Yap_pages_sg_hash, struct subgoal_trie_hash)
#define FREE_SUBGOAL_TRIE_HASH(STR) FREE_STRUCT(STR, Yap_pages_sg_hash, struct subgoal_trie_hash)
#define ALLOC_SUBGOAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, GLOBAL_pages_sg_hash, struct subgoal_trie_hash)
#define FREE_SUBGOAL_TRIE_HASH(STR) FREE_STRUCT(STR, GLOBAL_pages_sg_hash, struct subgoal_trie_hash)
#define ALLOC_ANSWER_TRIE_HASH(STR) ALLOC_STRUCT(STR, Yap_pages_ans_hash, struct answer_trie_hash)
#define FREE_ANSWER_TRIE_HASH(STR) FREE_STRUCT(STR, Yap_pages_ans_hash, struct answer_trie_hash)
#define ALLOC_ANSWER_TRIE_HASH(STR) ALLOC_STRUCT(STR, GLOBAL_pages_ans_hash, struct answer_trie_hash)
#define FREE_ANSWER_TRIE_HASH(STR) FREE_STRUCT(STR, GLOBAL_pages_ans_hash, struct answer_trie_hash)
@ -457,7 +457,7 @@ extern int Yap_page_size;
************************************************************************/
#define INFORMATION_MESSAGE(MESSAGE,ARGS...) \
fprintf(stderr, "[ " MESSAGE " ]\n", ##ARGS)
Sfprintf(Serror, "[ " MESSAGE " ]\n", ##ARGS)
#ifdef YAPOR
#define ERROR_MESSAGE(MESSAGE) \

View File

@ -1,274 +0,0 @@
/************************************************************************
** **
** The YapTab/YapOr/OPTYap systems **
** **
** YapTab extends the Yap Prolog engine to support sequential tabling **
** YapOr extends the Yap Prolog engine to support or-parallelism **
** OPTYap extends the Yap Prolog engine to support or-parallel tabling **
** **
** **
** Yap Prolog was developed at University of Porto, Portugal **
** **
************************************************************************/
/**************************************
** Includes & Declarations **
**************************************/
#include "Yap.h"
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <sys/shm.h>
#include <sys/mman.h>
#include "Yatom.h"
#include "YapHeap.h"
#include "alloc.h"
#include "heapgc.h"
#include "or.macros.h"
/************************************
** Macros & Declarations **
************************************/
#define KBYTES 1024
#ifdef MMAP_MEMORY_MAPPING_SCHEME
int fd_mapfile;
#else /* SHM_MEMORY_MAPPING_SCHEME */
int shm_mapid[MAX_WORKERS + 1];
#endif /* MEMORY_MAPPING_SCHEME */
/******************************************
** Local functions declaration **
******************************************/
#ifdef MMAP_MEMORY_MAPPING_SCHEME
void open_mapfile(long TotalArea);
#else /* SHM_MEMORY_MAPPING_SCHEME */
void shm_map_memory(int id, int size, void *shmaddr);
#endif /* MEMORY_MAPPING_SCHEME */
/********************************
** Global functions **
********************************/
void Yap_init_optyap_memory(long TrailAuxArea, long HeapArea, long GlobalLocalArea, int n_workers) {
#ifdef YAPOR_COW
int private_fd_mapfile;
#if MMAP_MEMORY_MAPPING_SCHEME
long TotalArea;
#endif /* MMAP_MEMORY_MAPPING_SCHEME */
#else /* YAPOR_COPY || YAPOR_SBA */
long TotalArea;
#endif
long ExtraArea;
HeapArea = ADJUST_SIZE_TO_PAGE(HeapArea);
GlobalLocalArea = ADJUST_SIZE(GlobalLocalArea);
TrailAuxArea = ADJUST_SIZE(TrailAuxArea);
/* initial allocation - model independent */
ExtraArea = ADJUST_SIZE_TO_PAGE(sizeof(struct global_data) + MAX_WORKERS * sizeof(struct worker_local));
Yap_WLocal = (struct worker_local *)(MMAP_ADDR - ExtraArea);
Yap_global = (struct global_data *)(MMAP_ADDR - sizeof(struct global_data));
Yap_HeapBase = (ADDR) MMAP_ADDR;
Yap_GlobalBase = (ADDR) (MMAP_ADDR + HeapArea);
/* shared memory allocation - model dependent */
#ifdef YAPOR_COW
/* acow just needs one stack */
#ifdef MMAP_MEMORY_MAPPING_SCHEME
/* I need this for MMAP to know what it must allocate */
TotalArea = HeapArea;
#endif /* MMAP_MEMORY_MAPPING_SCHEME */
#else /* YAPOR_COPY || YAPOR_SBA */
/* the others need n stacks */
Yap_worker_area_size = ADJUST_SIZE_TO_PAGE(GlobalLocalArea + TrailAuxArea);
TotalArea = ExtraArea + HeapArea + Yap_worker_area_size * n_workers;
#endif
#ifdef MMAP_MEMORY_MAPPING_SCHEME
/* map total area in a single go */
open_mapfile(TotalArea);
if (mmap((void *) Yap_WLocal, (size_t) TotalArea, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd_mapfile, 0) == (void *) -1)
Yap_Error(FATAL_ERROR, TermNil, "mmap error (Yap_init_optyap_memory)");
#else /* SHM_MEMORY_MAPPING_SCHEME */
/* most systems are limited regarding what we can allocate */
#ifdef YAPOR_COW
/* single shared segment in ACOW */
shm_map_memory(0, ExtraArea + HeapArea, (void *) MMAP_ADDR);
#else /* YAPOR_COPY || YAPOR_SBA */
/* place as segment n otherwise (0..n-1 reserved for worker areas */
shm_map_memory(n_workers, ExtraArea + HeapArea, (void *) Yap_WLocal);
{ int i;
for (i = 0; i < n_workers; i++)
shm_map_memory(i, Yap_worker_area_size, Yap_GlobalBase + Yap_worker_area_size * i);
}
#endif
#endif /* MEMORY_MAPPING_SCHEME */
#ifdef YAPOR_COW
/* just allocate local space for stacks */
if ((private_fd_mapfile = open("/dev/zero", O_RDWR)) < 0)
Yap_Error(FATAL_ERROR, TermNil, "open error (Yap_init_optyap_memory)");
if (mmap(Yap_GlobalBase, GlobalLocalArea + TrailAuxArea, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, private_fd_mapfile, 0) == (void *) -1)
Yap_Error(FATAL_ERROR, TermNil, "mmap error (Yap_init_optyap_memory)");
close(private_fd_mapfile);
#endif /* YAPOR_COW */
#ifdef YAPOR_SBA
/* alloc space for the sparse binding array */
sba_size = Yap_worker_area_size * n_workers;
if ((binding_array = (char *)malloc(sba_size)) == NULL)
Yap_Error(FATAL_ERROR, TermNil, "malloc error (Yap_init_optyap_memory)");
if ((CELL)binding_array & MBIT) {
Yap_Error(INTERNAL_ERROR, TermNil, "binding_array start address conflicts with tag used in IDB (Yap_init_optyap_memory)");
}
sba_offset = binding_array - Yap_GlobalBase;
sba_end = (int)binding_array + sba_size;
#endif /* YAPOR_SBA */
Yap_TrailBase = Yap_GlobalBase + GlobalLocalArea;
Yap_LocalBase = Yap_TrailBase - CellSize;
if (TrailAuxArea > 262144) /* 262144 = 256 * 1024 */
Yap_TrailTop = Yap_TrailBase + (TrailAuxArea - 131072); /* 131072 = 262144 / 2 */
else
Yap_TrailTop = Yap_TrailBase + (TrailAuxArea / 2);
HeapMax = (CELL)(Yap_TrailBase + (TrailAuxArea - CellSize));
Yap_InitHeap(Yap_HeapBase);
}
void Yap_remap_optyap_memory(void) {
#ifdef YAPOR_SBA
/* setup workers so that they have different areas */
Yap_GlobalBase += worker_id * Yap_worker_area_size;
Yap_TrailBase += worker_id * Yap_worker_area_size;
Yap_LocalBase += worker_id * Yap_worker_area_size;
Yap_TrailTop += worker_id * Yap_worker_area_size;
#endif /* YAPOR_SBA */
#ifdef YAPOR_COPY
int i;
void *remap_addr = Yap_GlobalBase;
#ifdef MMAP_MEMORY_MAPPING_SCHEME
long remap_offset = (ADDR) remap_addr - (ADDR) Yap_WLocal;
if (munmap(remap_addr, (size_t)(Yap_worker_area_size * Yap_number_workers)) == -1)
Yap_Error(FATAL_ERROR, TermNil, "munmap error (Yap_remap_optyap_memory)");
for (i = 0; i < Yap_number_workers; i++)
if (mmap(remap_addr + worker_offset(i), (size_t)Yap_worker_area_size, PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED, fd_mapfile, remap_offset + i * Yap_worker_area_size) == (void *) -1)
Yap_Error(FATAL_ERROR, TermNil, "mmap error (Yap_remap_optyap_memory)");
#else /* SHM_MEMORY_MAPPING_SCHEME */
for (i = 0; i < Yap_number_workers; i++)
if (shmdt(remap_addr + Yap_worker_area_size * i) == -1)
Yap_Error(FATAL_ERROR, TermNil, "shmdt error (Yap_remap_optyap_memory)");
for (i = 0; i < Yap_number_workers; i++)
if(shmat(shm_mapid[i], remap_addr + worker_offset(i), 0) == (void *) -1)
Yap_Error(FATAL_ERROR, TermNil, "shmat error (Yap_remap_optyap_memory)");
#endif /* MEMORY_MAPPING_SCHEME */
#endif /* YAPOR_COPY */
}
void Yap_unmap_optyap_memory (void) {
#ifdef MMAP_MEMORY_MAPPING_SCHEME
char MapFile[20];
#else /* SHM_MEMORY_MAPPING_SCHEME */
int i;
#endif /* MEMORY_MAPPING_SCHEME */
int proc;
INFORMATION_MESSAGE("Worker %d exiting...", worker_id);
for (proc = 0; proc < Yap_number_workers; proc++) {
if (proc != worker_id && Yap_worker_pid(proc) != 0) {
if (kill(Yap_worker_pid(proc), SIGKILL) != 0)
INFORMATION_MESSAGE("Can't kill process %d", Yap_worker_pid(proc));
else
INFORMATION_MESSAGE("Killing process %d", Yap_worker_pid(proc));
}
}
#ifdef YAPOR_COW
if (Yap_number_workers > 1) {
if (kill(Yap_master_worker, SIGINT) != 0)
INFORMATION_MESSAGE("Can't kill process %d", Yap_master_worker);
else
INFORMATION_MESSAGE("Killing process %d", Yap_master_worker);
}
#endif /* YAPOR_COW */
#ifdef MMAP_MEMORY_MAPPING_SCHEME
strcpy(MapFile,"./mapfile");
#ifdef YAPOR_COW
itos(Yap_master_worker, &MapFile[9]);
#else /* YAPOR_COPY || YAPOR_SBA */
itos(Yap_worker_pid(0), &MapFile[9]);
#endif
if (remove(MapFile) == 0)
INFORMATION_MESSAGE("Removing mapfile \"%s\"", MapFile);
else
INFORMATION_MESSAGE("Can't remove mapfile \"%s\"", MapFile);
#else /* SHM_MEMORY_MAPPING_SCHEME */
#ifdef YAPOR_COW
i = 0;
#else /* YAPOR_COPY || YAPOR_SBA */
for (i = 0; i < Yap_number_workers + 1; i++)
#endif
{
if (shmctl(shm_mapid[i], IPC_RMID, 0) == 0)
INFORMATION_MESSAGE("Removing shared memory segment %d", shm_mapid[i]);
else
INFORMATION_MESSAGE("Can't remove shared memory segment %d", shm_mapid[i]);
}
#endif /* MEMORY_MAPPING_SCHEME */
return;
}
/* ------------------------- **
** Local functions **
** ------------------------- */
#ifdef MMAP_MEMORY_MAPPING_SCHEME
void open_mapfile(long TotalArea) {
char mapfile[20];
strcpy(mapfile,"./mapfile");
itos(getpid(), &mapfile[9]);
if ((fd_mapfile = open(mapfile, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0)
Yap_Error(FATAL_ERROR, TermNil, "open error (open_mapfile)");
if (lseek(fd_mapfile, TotalArea, SEEK_SET) < 0)
Yap_Error(FATAL_ERROR, TermNil, "lseek error (open_mapfile)");
if (write(fd_mapfile, "", 1) < 0)
Yap_Error(FATAL_ERROR, TermNil, "write error (open_mapfile)");
return;
}
#else /* SHM_MEMORY_MAPPING_SCHEME */
void shm_map_memory(int id, int size, void *shmaddr) {
if (size > SHMMAX)
Yap_Error(FATAL_ERROR, TermNil, "maximum size for a shm segment exceeded (shm_map_memory)");
if ((shm_mapid[id] = shmget(IPC_PRIVATE, size, SHM_R|SHM_W)) == -1)
Yap_Error(FATAL_ERROR, TermNil, "shmget error (shm_map_memory)");
if (shmat(shm_mapid[id], shmaddr, 0) == (void *) -1)
Yap_Error(FATAL_ERROR, TermNil, "shmat error (shm_map_memory)");
return;
}
#endif /* MMAP_MEMORY_MAPPING_SCHEME */
#endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA */

File diff suppressed because it is too large Load Diff

View File

@ -11,15 +11,9 @@
** **
************************************************************************/
/***************************
** opt.memory.c **
***************************/
#ifdef YAPOR
void Yap_init_optyap_memory(long, long, long, int);
void Yap_unmap_optyap_memory(void);
void Yap_remap_optyap_memory(void);
#endif /* YAPOR */
#if defined(TABLING) || defined(YAPOR)
#include "SWI-Stream.h"
#endif /* TABLING || YAPOR */
@ -27,12 +21,9 @@ void Yap_remap_optyap_memory(void);
** opt.init.c **
*************************/
void Yap_init_optyap_data(int, int, int, int);
void Yap_init_local(void);
void make_root_frames(void);
#ifdef YAPOR
void init_workers(void);
#endif /* YAPOR */
void Yap_init_global_optyap_data(int, int, int, int);
void Yap_init_local_optyap_data(int);
void Yap_init_root_frames(void);
void itos(int, char *);
@ -61,8 +52,8 @@ void free_subgoal_trie(sg_node_ptr, int, int);
void free_answer_trie(ans_node_ptr, int, int);
void free_subgoal_hash_chain(sg_hash_ptr);
void free_answer_hash_chain(ans_hash_ptr);
void show_table(tab_ent_ptr, int);
void show_global_trie(int);
void show_table(tab_ent_ptr, int, IOSTREAM *);
void show_global_trie(int, IOSTREAM *);
#endif /* TABLING */
@ -84,9 +75,22 @@ void resume_suspension_frame(susp_fr_ptr, or_fr_ptr);
/**************************
** or.copy_engine.c **
** or.memory.c **
**************************/
#ifdef YAPOR
void Yap_init_yapor_global_local_memory(void);
void Yap_init_yapor_stacks_memory(long, long, long, int);
void Yap_unmap_yapor_memory(void);
void Yap_remap_yapor_memory(void);
#endif /* YAPOR */
/*******************************
** or.copy_engine.c **
*******************************/
#ifdef YAPOR
void make_root_choice_point(void);
void free_root_choice_point(void);

View File

@ -57,6 +57,7 @@ cptr_to_offset_with_null(choiceptr node)
** Struct page_header **
*********************************/
#ifdef USE_PAGES_MALLOC
typedef struct page_header {
volatile int structs_in_use;
void *first_free_struct;
@ -68,6 +69,7 @@ typedef struct page_header {
#define PgHd_free_str(X) ((X)->first_free_struct)
#define PgHd_previous(X) ((X)->previous)
#define PgHd_next(X) ((X)->next)
#endif /* USE_PAGES_MALLOC */
@ -132,12 +134,12 @@ struct global_pages {
/**********************************
** Struct global_locks **
**********************************/
/*****************************************
** Struct global_optyap_locks **
*****************************************/
#ifdef YAPOR
struct global_locks {
struct global_optyap_locks {
lockvar bitmap_idle_workers;
lockvar bitmap_root_cp_workers;
lockvar bitmap_invisible_workers;
@ -160,7 +162,7 @@ struct global_locks {
* Struct global_optyap_data **
*********************************/
struct global_optyap_data{
struct global_optyap_data {
/* global data related to memory management */
struct global_pages pages;
@ -198,7 +200,7 @@ struct global_optyap_data{
#ifdef TABLING_INNER_CUTS
volatile bitmap pruning_workers;
#endif /* TABLING_INNER_CUTS */
struct global_locks locks;
struct global_optyap_locks locks;
volatile unsigned int branch[MAX_WORKERS][MAX_BRANCH_DEPTH];
volatile char parallel_execution_mode; /* TRUE / FALSE */
volatile int answers;
@ -224,81 +226,81 @@ struct global_optyap_data{
#endif /* TABLING */
};
#define Yap_max_pages (Yap_optyap_data.pages.max_pages)
#define Yap_pages_void (Yap_optyap_data.pages.void_pages)
#define Yap_pages_or_fr (Yap_optyap_data.pages.or_frame_pages)
#define Yap_pages_qg_sol_fr (Yap_optyap_data.pages.query_goal_solution_frame_pages)
#define Yap_pages_qg_ans_fr (Yap_optyap_data.pages.query_goal_answer_frame_pages)
#define Yap_pages_tg_sol_fr (Yap_optyap_data.pages.table_subgoal_solution_frame_pages)
#define Yap_pages_tg_ans_fr (Yap_optyap_data.pages.table_subgoal_answer_frame_pages)
#define Yap_pages_tab_ent (Yap_optyap_data.pages.table_entry_pages)
#define Yap_pages_sg_fr (Yap_optyap_data.pages.subgoal_frame_pages)
#define Yap_pages_dep_fr (Yap_optyap_data.pages.dependency_frame_pages)
#define Yap_pages_sg_node (Yap_optyap_data.pages.subgoal_trie_node_pages)
#define Yap_pages_ans_node (Yap_optyap_data.pages.answer_trie_node_pages)
#define Yap_pages_gt_node (Yap_optyap_data.pages.global_trie_node_pages)
#define Yap_pages_sg_hash (Yap_optyap_data.pages.subgoal_trie_hash_pages)
#define Yap_pages_ans_hash (Yap_optyap_data.pages.answer_trie_hash_pages)
#define Yap_pages_gt_hash (Yap_optyap_data.pages.global_trie_hash_pages)
#define Yap_pages_susp_fr (Yap_optyap_data.pages.suspension_frame_pages)
#define Yap_scheduler_loop (Yap_optyap_data.scheduler_loop)
#define Yap_delayed_release_load (Yap_optyap_data.delayed_release_load)
#define Yap_number_workers (Yap_optyap_data.number_workers)
#define Yap_worker_pid(worker) (Yap_optyap_data.worker_pid[worker])
#define Yap_master_worker (Yap_optyap_data.master_worker)
#define Yap_execution_time (Yap_optyap_data.execution_time)
#define Yap_best_times(time) (Yap_optyap_data.best_execution_times[time])
#define Yap_number_goals (Yap_optyap_data.number_of_executed_goals)
#define Yap_performance_mode (Yap_optyap_data.performance_mode)
#define GLOBAL_max_pages (GLOBAL_optyap_data.pages.max_pages)
#define GLOBAL_pages_void (GLOBAL_optyap_data.pages.void_pages)
#define GLOBAL_pages_or_fr (GLOBAL_optyap_data.pages.or_frame_pages)
#define GLOBAL_pages_qg_sol_fr (GLOBAL_optyap_data.pages.query_goal_solution_frame_pages)
#define GLOBAL_pages_qg_ans_fr (GLOBAL_optyap_data.pages.query_goal_answer_frame_pages)
#define GLOBAL_pages_tg_sol_fr (GLOBAL_optyap_data.pages.table_subgoal_solution_frame_pages)
#define GLOBAL_pages_tg_ans_fr (GLOBAL_optyap_data.pages.table_subgoal_answer_frame_pages)
#define GLOBAL_pages_tab_ent (GLOBAL_optyap_data.pages.table_entry_pages)
#define GLOBAL_pages_sg_fr (GLOBAL_optyap_data.pages.subgoal_frame_pages)
#define GLOBAL_pages_dep_fr (GLOBAL_optyap_data.pages.dependency_frame_pages)
#define GLOBAL_pages_sg_node (GLOBAL_optyap_data.pages.subgoal_trie_node_pages)
#define GLOBAL_pages_ans_node (GLOBAL_optyap_data.pages.answer_trie_node_pages)
#define GLOBAL_pages_gt_node (GLOBAL_optyap_data.pages.global_trie_node_pages)
#define GLOBAL_pages_sg_hash (GLOBAL_optyap_data.pages.subgoal_trie_hash_pages)
#define GLOBAL_pages_ans_hash (GLOBAL_optyap_data.pages.answer_trie_hash_pages)
#define GLOBAL_pages_gt_hash (GLOBAL_optyap_data.pages.global_trie_hash_pages)
#define GLOBAL_pages_susp_fr (GLOBAL_optyap_data.pages.suspension_frame_pages)
#define GLOBAL_scheduler_loop (GLOBAL_optyap_data.scheduler_loop)
#define GLOBAL_delayed_release_load (GLOBAL_optyap_data.delayed_release_load)
#define GLOBAL_number_workers (GLOBAL_optyap_data.number_workers)
#define GLOBAL_worker_pid(worker) (GLOBAL_optyap_data.worker_pid[worker])
#define GLOBAL_master_worker (GLOBAL_optyap_data.master_worker)
#define GLOBAL_execution_time (GLOBAL_optyap_data.execution_time)
#define GLOBAL_best_times(time) (GLOBAL_optyap_data.best_execution_times[time])
#define GLOBAL_number_goals (GLOBAL_optyap_data.number_of_executed_goals)
#define GLOBAL_performance_mode (GLOBAL_optyap_data.performance_mode)
#ifdef YAPOR_THREADS
#define Get_Yap_root_cp() offset_to_cptr(Yap_optyap_data.root_choice_point_offset)
#define Set_Yap_root_cp(bptr) (Yap_optyap_data.root_choice_point_offset = cptr_to_offset(bptr))
#define Get_GLOBAL_root_cp() offset_to_cptr(GLOBAL_optyap_data.root_choice_point_offset)
#define Set_GLOBAL_root_cp(bptr) (GLOBAL_optyap_data.root_choice_point_offset = cptr_to_offset(bptr))
#else
#define Yap_root_cp (Yap_optyap_data.root_choice_point)
#define Get_Yap_root_cp() (Yap_optyap_data.root_choice_point)
#define Set_Yap_root_cp(bptr) (Yap_optyap_data.root_choice_point = (bptr))
#define GLOBAL_root_cp (GLOBAL_optyap_data.root_choice_point)
#define Get_GLOBAL_root_cp() (GLOBAL_optyap_data.root_choice_point)
#define Set_GLOBAL_root_cp(bptr) (GLOBAL_optyap_data.root_choice_point = (bptr))
#endif
#define Yap_root_or_fr (Yap_optyap_data.root_or_frame)
#define Yap_bm_present_workers (Yap_optyap_data.present_workers)
#define Yap_bm_idle_workers (Yap_optyap_data.idle_workers)
#define Yap_bm_root_cp_workers (Yap_optyap_data.root_cp_workers)
#define Yap_bm_invisible_workers (Yap_optyap_data.invisible_workers)
#define Yap_bm_requestable_workers (Yap_optyap_data.requestable_workers)
#define Yap_bm_executing_workers (Yap_optyap_data.executing_workers)
#define Yap_bm_finished_workers (Yap_optyap_data.finished_workers)
#define Yap_bm_pruning_workers (Yap_optyap_data.pruning_workers)
#define Yap_locks_bm_idle_workers (Yap_optyap_data.locks.bitmap_idle_workers)
#define Yap_locks_bm_root_cp_workers (Yap_optyap_data.locks.bitmap_root_cp_workers)
#define Yap_locks_bm_invisible_workers (Yap_optyap_data.locks.bitmap_invisible_workers)
#define Yap_locks_bm_requestable_workers (Yap_optyap_data.locks.bitmap_requestable_workers)
#define Yap_locks_bm_executing_workers (Yap_optyap_data.locks.bitmap_executing_workers)
#define Yap_locks_bm_finished_workers (Yap_optyap_data.locks.bitmap_finished_workers)
#define Yap_locks_bm_pruning_workers (Yap_optyap_data.locks.bitmap_pruning_workers)
#define Yap_locks_who_locked_heap (Yap_optyap_data.locks.who_locked_heap)
#define Yap_locks_heap_access (Yap_optyap_data.locks.heap_access)
#define Yap_locks_alloc_block (Yap_optyap_data.locks.alloc_block)
#define Yap_branch(worker, depth) (Yap_optyap_data.branch[worker][depth])
#define Yap_parallel_execution_mode (Yap_optyap_data.parallel_execution_mode)
#define Yap_answers (Yap_optyap_data.answers)
#define Yap_root_gt (Yap_optyap_data.root_global_trie)
#define Yap_root_tab_ent (Yap_optyap_data.root_table_entry)
#define Yap_first_sg_fr (Yap_optyap_data.first_subgoal_frame)
#define Yap_last_sg_fr (Yap_optyap_data.last_subgoal_frame)
#define Yap_check_sg_fr (Yap_optyap_data.check_subgoal_frame)
#define Yap_root_dep_fr (Yap_optyap_data.root_dependency_frame)
#define Yap_table_var_enumerator(index) (Yap_optyap_data.table_var_enumerator[index])
#define Yap_table_var_enumerator_addr(index) (Yap_optyap_data.table_var_enumerator + (index))
#define Yap_table_lock(index) (Yap_optyap_data.table_lock[index])
#define Yap_timestamp (Yap_optyap_data.timestamp)
#define GLOBAL_root_or_fr (GLOBAL_optyap_data.root_or_frame)
#define GLOBAL_bm_present_workers (GLOBAL_optyap_data.present_workers)
#define GLOBAL_bm_idle_workers (GLOBAL_optyap_data.idle_workers)
#define GLOBAL_bm_root_cp_workers (GLOBAL_optyap_data.root_cp_workers)
#define GLOBAL_bm_invisible_workers (GLOBAL_optyap_data.invisible_workers)
#define GLOBAL_bm_requestable_workers (GLOBAL_optyap_data.requestable_workers)
#define GLOBAL_bm_executing_workers (GLOBAL_optyap_data.executing_workers)
#define GLOBAL_bm_finished_workers (GLOBAL_optyap_data.finished_workers)
#define GLOBAL_bm_pruning_workers (GLOBAL_optyap_data.pruning_workers)
#define GLOBAL_locks_bm_idle_workers (GLOBAL_optyap_data.locks.bitmap_idle_workers)
#define GLOBAL_locks_bm_root_cp_workers (GLOBAL_optyap_data.locks.bitmap_root_cp_workers)
#define GLOBAL_locks_bm_invisible_workers (GLOBAL_optyap_data.locks.bitmap_invisible_workers)
#define GLOBAL_locks_bm_requestable_workers (GLOBAL_optyap_data.locks.bitmap_requestable_workers)
#define GLOBAL_locks_bm_executing_workers (GLOBAL_optyap_data.locks.bitmap_executing_workers)
#define GLOBAL_locks_bm_finished_workers (GLOBAL_optyap_data.locks.bitmap_finished_workers)
#define GLOBAL_locks_bm_pruning_workers (GLOBAL_optyap_data.locks.bitmap_pruning_workers)
#define GLOBAL_locks_who_locked_heap (GLOBAL_optyap_data.locks.who_locked_heap)
#define GLOBAL_locks_heap_access (GLOBAL_optyap_data.locks.heap_access)
#define GLOBAL_locks_alloc_block (GLOBAL_optyap_data.locks.alloc_block)
#define GLOBAL_branch(worker, depth) (GLOBAL_optyap_data.branch[worker][depth])
#define GLOBAL_parallel_execution_mode (GLOBAL_optyap_data.parallel_execution_mode)
#define GLOBAL_answers (GLOBAL_optyap_data.answers)
#define GLOBAL_root_gt (GLOBAL_optyap_data.root_global_trie)
#define GLOBAL_root_tab_ent (GLOBAL_optyap_data.root_table_entry)
#define GLOBAL_first_sg_fr (GLOBAL_optyap_data.first_subgoal_frame)
#define GLOBAL_last_sg_fr (GLOBAL_optyap_data.last_subgoal_frame)
#define GLOBAL_check_sg_fr (GLOBAL_optyap_data.check_subgoal_frame)
#define GLOBAL_root_dep_fr (GLOBAL_optyap_data.root_dependency_frame)
#define GLOBAL_table_var_enumerator(index) (GLOBAL_optyap_data.table_var_enumerator[index])
#define GLOBAL_table_var_enumerator_addr(index) (GLOBAL_optyap_data.table_var_enumerator + (index))
#define GLOBAL_table_lock(index) (GLOBAL_optyap_data.table_lock[index])
#define GLOBAL_timestamp (GLOBAL_optyap_data.timestamp)
/***********************************
** Struct local_signals **
***********************************/
/******************************************
** Struct local_optyap_signals **
******************************************/
#ifdef YAPOR
struct local_signals{
struct local_optyap_signals{
#if defined(YAPOR_COPY) || defined(YAPOR_THREADS)
lockvar lock;
volatile enum {
@ -341,11 +343,11 @@ typedef struct {
/********************************
** Struct local_data **
********************************/
/***************************************
** Struct local_optyap_data **
***************************************/
struct local_data{
struct local_optyap_data {
#ifdef YAPOR
lockvar lock;
/* local data related to or-parallelism */
@ -362,7 +364,7 @@ struct local_data{
choiceptr prune_request;
#endif
volatile int share_request;
struct local_signals share_signals;
struct local_optyap_signals share_signals;
volatile struct {
CELL start;
CELL end;
@ -394,95 +396,95 @@ struct local_data{
#endif /* (TABLING || !YAPOR_COW) && MULTI_ASSIGNMENT_VARIABLES */
};
#define LOCAL_lock (LOCAL->lock)
#define LOCAL_load (LOCAL->load)
#define LOCAL_lock (LOCAL_optyap_data.lock)
#define LOCAL_load (LOCAL_optyap_data.load)
#ifdef YAPOR_THREADS
#define Get_LOCAL_top_cp() offset_to_cptr(LOCAL->top_choice_point_offset)
#define Set_LOCAL_top_cp(cpt) (LOCAL->top_choice_point_offset = cptr_to_offset(cpt))
#define Get_LOCAL_top_cp() offset_to_cptr(LOCAL_optyap_data.top_choice_point_offset)
#define Set_LOCAL_top_cp(cpt) (LOCAL_optyap_data.top_choice_point_offset = cptr_to_offset(cpt))
#else
#define LOCAL_top_cp (LOCAL->top_choice_point)
#define Get_LOCAL_top_cp() (LOCAL->top_choice_point)
#define Set_LOCAL_top_cp(cpt) (LOCAL->top_choice_point = cpt)
#endif
#define LOCAL_top_or_fr (LOCAL->top_or_frame)
#define LOCAL_top_cp (LOCAL_optyap_data.top_choice_point)
#define Get_LOCAL_top_cp() (LOCAL_optyap_data.top_choice_point)
#define Set_LOCAL_top_cp(cpt) (LOCAL_optyap_data.top_choice_point = cpt)
#endif /* YAPOR_THREADS */
#define LOCAL_top_or_fr (LOCAL_optyap_data.top_or_frame)
#ifdef YAPOR_THREADS
#define Get_LOCAL_prune_request() offset_to_cptr_with_null(LOCAL->prune_request_offset)
#define Set_LOCAL_prune_request(cpt) (LOCAL->prune_request_offset = cptr_to_offset_with_null(cpt))
#define Get_LOCAL_prune_request() offset_to_cptr_with_null(LOCAL_optyap_data.prune_request_offset)
#define Set_LOCAL_prune_request(cpt) (LOCAL_optyap_data.prune_request_offset = cptr_to_offset_with_null(cpt))
#else
#define LOCAL_prune_request (LOCAL->prune_request)
#define Get_LOCAL_prune_request() (LOCAL->prune_request)
#define Set_LOCAL_prune_request(cpt) (LOCAL->prune_request = cpt)
#endif
#define LOCAL_share_request (LOCAL->share_request)
#define LOCAL_reply_signal (LOCAL->share_signals.reply_signal)
#define LOCAL_p_fase_signal (LOCAL->share_signals.P_fase)
#define LOCAL_q_fase_signal (LOCAL->share_signals.Q_fase)
#define LOCAL_lock_signals (LOCAL->share_signals.lock)
#define LOCAL_start_global_copy (LOCAL->global_copy.start)
#define LOCAL_end_global_copy (LOCAL->global_copy.end)
#define LOCAL_start_local_copy (LOCAL->local_copy.start)
#define LOCAL_end_local_copy (LOCAL->local_copy.end)
#define LOCAL_start_trail_copy (LOCAL->trail_copy.start)
#define LOCAL_end_trail_copy (LOCAL->trail_copy.end)
#define LOCAL_next_free_ans_node (LOCAL->next_free_answer_trie_node)
#define LOCAL_top_sg_fr (LOCAL->top_subgoal_frame)
#define LOCAL_top_dep_fr (LOCAL->top_dependency_frame)
#define LOCAL_pruning_scope (LOCAL->bottom_pruning_scope)
#define LOCAL_prune_request (LOCAL_optyap_data.prune_request)
#define Get_LOCAL_prune_request() (LOCAL_optyap_data.prune_request)
#define Set_LOCAL_prune_request(cpt) (LOCAL_optyap_data.prune_request = cpt)
#endif /* YAPOR_THREADS */
#define LOCAL_share_request (LOCAL_optyap_data.share_request)
#define LOCAL_reply_signal (LOCAL_optyap_data.share_signals.reply_signal)
#define LOCAL_p_fase_signal (LOCAL_optyap_data.share_signals.P_fase)
#define LOCAL_q_fase_signal (LOCAL_optyap_data.share_signals.Q_fase)
#define LOCAL_lock_signals (LOCAL_optyap_data.share_signals.lock)
#define LOCAL_start_global_copy (LOCAL_optyap_data.global_copy.start)
#define LOCAL_end_global_copy (LOCAL_optyap_data.global_copy.end)
#define LOCAL_start_local_copy (LOCAL_optyap_data.local_copy.start)
#define LOCAL_end_local_copy (LOCAL_optyap_data.local_copy.end)
#define LOCAL_start_trail_copy (LOCAL_optyap_data.trail_copy.start)
#define LOCAL_end_trail_copy (LOCAL_optyap_data.trail_copy.end)
#define LOCAL_next_free_ans_node (LOCAL_optyap_data.next_free_answer_trie_node)
#define LOCAL_top_sg_fr (LOCAL_optyap_data.top_subgoal_frame)
#define LOCAL_top_dep_fr (LOCAL_optyap_data.top_dependency_frame)
#define LOCAL_pruning_scope (LOCAL_optyap_data.bottom_pruning_scope)
#ifdef YAPOR_THREADS
#define Get_LOCAL_top_cp_on_stack() offset_to_cptr(LOCAL->top_choice_point_on_stack_offset)
#define Set_LOCAL_top_cp_on_stack(cpt) (LOCAL->top_choice_point_on_stack_offset = cptr_to_offset(cpt))
#define Get_LOCAL_top_cp_on_stack() offset_to_cptr(LOCAL_optyap_data.top_choice_point_on_stack_offset)
#define Set_LOCAL_top_cp_on_stack(cpt) (LOCAL_optyap_data.top_choice_point_on_stack_offset = cptr_to_offset(cpt))
#else
#define LOCAL_top_cp_on_stack (LOCAL->top_choice_point_on_stack)
#define Get_LOCAL_top_cp_on_stack() (LOCAL->top_choice_point_on_stack)
#define Set_LOCAL_top_cp_on_stack(cpt) (LOCAL->top_choice_point_on_stack = cpt)
#endif
#define LOCAL_top_susp_or_fr (LOCAL->top_or_frame_with_suspensions)
#define LOCAL_ma_timestamp (LOCAL->ma_timestamp)
#define LOCAL_ma_h_top (LOCAL->ma_h_top)
#define LOCAL_ma_hash_table (LOCAL->ma_hash_table)
#define LOCAL_top_cp_on_stack (LOCAL_optyap_data.top_choice_point_on_stack)
#define Get_LOCAL_top_cp_on_stack() (LOCAL_optyap_data.top_choice_point_on_stack)
#define Set_LOCAL_top_cp_on_stack(cpt) (LOCAL_optyap_data.top_choice_point_on_stack = cpt)
#endif /* YAPOR_THREADS */
#define LOCAL_top_susp_or_fr (LOCAL_optyap_data.top_or_frame_with_suspensions)
#define LOCAL_ma_timestamp (LOCAL_optyap_data.ma_timestamp)
#define LOCAL_ma_h_top (LOCAL_optyap_data.ma_h_top)
#define LOCAL_ma_hash_table (LOCAL_optyap_data.ma_hash_table)
#define REMOTE_lock(worker) (REMOTE[worker].lock)
#define REMOTE_load(worker) (REMOTE[worker].load)
#define REMOTE_lock(wid) (REMOTE(wid)->optyap_data_.lock)
#define REMOTE_load(wid) (REMOTE(wid)->optyap_data_.load)
#ifdef YAPOR_THREADS
#define REMOTE_top_cp(worker) offset_to_cptr(REMOTE[worker].top_choice_point_offset)
#define Set_REMOTE_top_cp(worker, bptr) (REMOTE[worker].top_choice_point_offset = cptr_to_offset(bptr))
#define REMOTE_top_cp(wid) offset_to_cptr(REMOTE(wid)->optyap_data_.top_choice_point_offset)
#define Set_REMOTE_top_cp(wid, bptr) (REMOTE(wid)->optyap_data_.top_choice_point_offset = cptr_to_offset(bptr))
#else
#define REMOTE_top_cp(worker) (REMOTE[worker].top_choice_point)
#define Set_REMOTE_top_cp(worker, bptr) (REMOTE[worker].top_choice_point = (bptr))
#endif
#define REMOTE_top_or_fr(worker) (REMOTE[worker].top_or_frame)
#define REMOTE_top_cp(wid) (REMOTE(wid)->optyap_data_.top_choice_point)
#define Set_REMOTE_top_cp(wid, bptr) (REMOTE(wid)->optyap_data_.top_choice_point = (bptr))
#endif /* YAPOR_THREADS */
#define REMOTE_top_or_fr(wid) (REMOTE(wid)->optyap_data_.top_or_frame)
#ifdef YAPOR_THREADS
#define Get_REMOTE_prune_request(worker) offset_to_cptr_with_null(REMOTE[worker].prune_request_offset)
#define Set_REMOTE_prune_request(worker,cp) (REMOTE[worker].prune_request_offset = cptr_to_offset_with_null(cp))
#define Get_REMOTE_prune_request(wid) offset_to_cptr_with_null(REMOTE(wid)->optyap_data_.prune_request_offset)
#define Set_REMOTE_prune_request(wid,cp) (REMOTE(wid)->optyap_data_.prune_request_offset = cptr_to_offset_with_null(cp))
#else
#define REMOTE_prune_request(worker) (REMOTE[worker].prune_request)
#define Get_REMOTE_prune_request(worker) (REMOTE[worker].prune_request)
#define Set_REMOTE_prune_request(worker,cp) (REMOTE[worker].prune_request = cp)
#endif
#define REMOTE_share_request(worker) (REMOTE[worker].share_request)
#define REMOTE_reply_signal(worker) (REMOTE[worker].share_signals.reply_signal)
#define REMOTE_p_fase_signal(worker) (REMOTE[worker].share_signals.P_fase)
#define REMOTE_q_fase_signal(worker) (REMOTE[worker].share_signals.Q_fase)
#define REMOTE_lock_signals(worker) (REMOTE[worker].share_signals.lock)
#define REMOTE_start_global_copy(worker) (REMOTE[worker].global_copy.start)
#define REMOTE_end_global_copy(worker) (REMOTE[worker].global_copy.end)
#define REMOTE_start_local_copy(worker) (REMOTE[worker].local_copy.start)
#define REMOTE_end_local_copy(worker) (REMOTE[worker].local_copy.end)
#define REMOTE_start_trail_copy(worker) (REMOTE[worker].trail_copy.start)
#define REMOTE_end_trail_copy(worker) (REMOTE[worker].trail_copy.end)
#define REMOTE_next_free_ans_node(worker) (REMOTE[worker].next_free_answer_trie_node)
#define REMOTE_top_sg_fr(worker) (REMOTE[worker].top_subgoal_frame)
#define REMOTE_top_dep_fr(worker) (REMOTE[worker].top_dependency_frame)
#define REMOTE_pruning_scope(worker) (REMOTE[worker].bottom_pruning_scope)
#define REMOTE_prune_request(wid) (REMOTE(wid)->optyap_data_.prune_request)
#define Get_REMOTE_prune_request(wid) (REMOTE(wid)->optyap_data_.prune_request)
#define Set_REMOTE_prune_request(wid,cp) (REMOTE(wid)->optyap_data_.prune_request = cp)
#endif /* YAPOR_THREADS */
#define REMOTE_share_request(wid) (REMOTE(wid)->optyap_data_.share_request)
#define REMOTE_reply_signal(wid) (REMOTE(wid)->optyap_data_.share_signals.reply_signal)
#define REMOTE_p_fase_signal(wid) (REMOTE(wid)->optyap_data_.share_signals.P_fase)
#define REMOTE_q_fase_signal(wid) (REMOTE(wid)->optyap_data_.share_signals.Q_fase)
#define REMOTE_lock_signals(wid) (REMOTE(wid)->optyap_data_.share_signals.lock)
#define REMOTE_start_global_copy(wid) (REMOTE(wid)->optyap_data_.global_copy.start)
#define REMOTE_end_global_copy(wid) (REMOTE(wid)->optyap_data_.global_copy.end)
#define REMOTE_start_local_copy(wid) (REMOTE(wid)->optyap_data_.local_copy.start)
#define REMOTE_end_local_copy(wid) (REMOTE(wid)->optyap_data_.local_copy.end)
#define REMOTE_start_trail_copy(wid) (REMOTE(wid)->optyap_data_.trail_copy.start)
#define REMOTE_end_trail_copy(wid) (REMOTE(wid)->optyap_data_.trail_copy.end)
#define REMOTE_next_free_ans_node(wid) (REMOTE(wid)->optyap_data_.next_free_answer_trie_node)
#define REMOTE_top_sg_fr(wid) (REMOTE(wid)->optyap_data_.top_subgoal_frame)
#define REMOTE_top_dep_fr(wid) (REMOTE(wid)->optyap_data_.top_dependency_frame)
#define REMOTE_pruning_scope(wid) (REMOTE(wid)->optyap_data_.bottom_pruning_scope)
#ifdef YAPOR_THREADS
#define REMOTE_top_cp_on_stack(worker) offset_to_cptr(REMOTE[worker].top_choice_point_on_stack_offset)
#define Set_REMOTE_top_cp_on_stack(worker, bptr) (REMOTE[worker].top_choice_point_on_stack_offset = cptr_to_offset(bptr))
#define REMOTE_top_cp_on_stack(wid) offset_to_cptr(REMOTE(wid)->optyap_data_.top_choice_point_on_stack_offset)
#define Set_REMOTE_top_cp_on_stack(wid, bptr) (REMOTE(wid)->optyap_data_.top_choice_point_on_stack_offset = cptr_to_offset(bptr))
#else
#define REMOTE_top_cp_on_stack(worker) (REMOTE[worker].top_choice_point_on_stack)
#define Set_REMOTE_top_cp_on_stack(worker, bptr) (REMOTE[worker].top_choice_point_on_stack = (bptr))
#endif
#define REMOTE_top_susp_or_fr(worker) (REMOTE[worker].top_or_frame_with_suspensions)
#define REMOTE_top_cp_on_stack(wid) (REMOTE(wid)->optyap_data_.top_choice_point_on_stack)
#define Set_REMOTE_top_cp_on_stack(wid, bptr) (REMOTE(wid)->optyap_data_.top_choice_point_on_stack = (bptr))
#endif /* YAPOR_THREADS */
#define REMOTE_top_susp_or_fr(wid) (REMOTE(wid)->optyap_data_.top_or_frame_with_suspensions)
#ifdef YAPOR

View File

@ -58,7 +58,7 @@ static void share_private_nodes(int worker_q);
REMOTE_end_global_copy(Q) = (CELL) (H); \
REMOTE_start_local_copy(Q) = (CELL) (B); \
REMOTE_end_local_copy(Q) = (CELL) (LCL0); \
REMOTE_start_trail_copy(Q) = (CELL) (Yap_TrailBase); \
REMOTE_start_trail_copy(Q) = (CELL) (LOCAL_TrailBase); \
REMOTE_end_trail_copy(Q) = (CELL) (TR)
#endif
@ -97,15 +97,15 @@ static void share_private_nodes(int worker_q);
void make_root_choice_point(void) {
if (worker_id == 0) {
LOCAL_top_cp = Yap_root_cp = OrFr_node(Yap_root_or_fr) = B;
LOCAL_top_cp = GLOBAL_root_cp = OrFr_node(GLOBAL_root_or_fr) = B;
} else {
B = LOCAL_top_cp = Yap_root_cp;
B = LOCAL_top_cp = GLOBAL_root_cp;
B->cp_tr = TR = ((choiceptr) (worker_offset(0) + (CELL)(B)))->cp_tr;
}
B->cp_h = H0;
B->cp_ap = GETWORK;
B->cp_or_fr = Yap_root_or_fr;
LOCAL_top_or_fr = Yap_root_or_fr;
B->cp_or_fr = GLOBAL_root_or_fr;
LOCAL_top_or_fr = GLOBAL_root_or_fr;
LOCAL_load = 0;
Set_LOCAL_prune_request(NULL);
BRANCH(worker_id, 0) = 0;
@ -125,7 +125,7 @@ void free_root_choice_point(void) {
#ifdef TABLING
LOCAL_top_cp_on_stack =
#endif /* TABLING */
LOCAL_top_cp = Yap_root_cp = OrFr_node(Yap_root_or_fr) = (choiceptr) Yap_LocalBase;
LOCAL_top_cp = GLOBAL_root_cp = OrFr_node(GLOBAL_root_or_fr) = (choiceptr) LOCAL_LocalBase;
return;
}
@ -135,7 +135,7 @@ int p_share_work(void) {
if (! BITMAP_member(OrFr_members(REMOTE_top_or_fr(worker_q)), worker_id) ||
B == REMOTE_top_cp(worker_q) ||
(LOCAL_load <= Yap_delayed_release_load && OrFr_nearest_livenode(LOCAL_top_or_fr) == NULL)) {
(LOCAL_load <= GLOBAL_delayed_release_load && OrFr_nearest_livenode(LOCAL_top_or_fr) == NULL)) {
/* refuse sharing request */
REMOTE_reply_signal(LOCAL_share_request) = no_sharing;
LOCAL_share_request = MAX_WORKERS;
@ -220,10 +220,10 @@ int q_share_work(int worker_p) {
#ifdef TABLING
} else if (IsPairTerm(aux_cell)) {
aux_cell = (CELL) RepPair(aux_cell);
if (IN_BETWEEN(Yap_TrailBase, aux_cell, Yap_TrailTop)) {
if (IN_BETWEEN(LOCAL_TrailBase, aux_cell, LOCAL_TrailTop)) {
/* avoid frozen segments */
TR = (tr_fr_ptr) aux_cell;
TABLING_ERROR_CHECKING(q_share_work, TR > (tr_fr_ptr) Yap_TrailTop);
TABLING_ERROR_CHECKING(q_share_work, TR > (tr_fr_ptr) LOCAL_TrailTop);
TABLING_ERROR_CHECKING(q_share_work, TR < aux_tr);
}
#endif /* TABLING */
@ -242,7 +242,7 @@ int q_share_work(int worker_p) {
/* make sharing request */
LOCK_WORKER(worker_p);
if (BITMAP_member(Yap_bm_idle_workers, worker_p) ||
if (BITMAP_member(GLOBAL_bm_idle_workers, worker_p) ||
REMOTE_share_request(worker_p) != MAX_WORKERS) {
/* worker p is idle or has another request */
UNLOCK_WORKER(worker_p);
@ -308,7 +308,7 @@ sync_with_p:
if (IsVarTerm(aux_cell)) {
if (aux_cell < LOCAL_start_global_copy || EQUAL_OR_YOUNGER_CP((choiceptr)LOCAL_end_local_copy, (choiceptr)aux_cell)) {
YAPOR_ERROR_CHECKING(q_share_work, (CELL *)aux_cell < H0);
YAPOR_ERROR_CHECKING(q_share_work, (ADDR)aux_cell > Yap_LocalBase);
YAPOR_ERROR_CHECKING(q_share_work, (ADDR)aux_cell > LOCAL_LocalBase);
#ifdef TABLING
*((CELL *) aux_cell) = TrailVal(aux_tr);
#else
@ -318,7 +318,7 @@ sync_with_p:
#ifdef TABLING
} else if (IsPairTerm(aux_cell)) {
aux_cell = (CELL) RepPair(aux_cell);
if (IN_BETWEEN(Yap_TrailBase, aux_cell, Yap_TrailTop)) {
if (IN_BETWEEN(LOCAL_TrailBase, aux_cell, LOCAL_TrailTop)) {
/* avoid frozen segments */
aux_tr = (tr_fr_ptr) aux_cell;
}
@ -443,7 +443,7 @@ void share_private_nodes(int worker_q) {
consumer_cp = DepFr_cons_cp(dep_frame);
next_node_on_branch = NULL;
stack_limit = (CELL *)TR;
stack = (CELL *)Yap_TrailTop;
stack = (CELL *)LOCAL_TrailTop;
#endif /* TABLING */
/* initialize auxiliary variables */
@ -549,7 +549,7 @@ void share_private_nodes(int worker_q) {
#ifdef TABLING
/* update or-frames stored in auxiliary stack */
while (STACK_NOT_EMPTY(stack, (CELL *)Yap_TrailTop)) {
while (STACK_NOT_EMPTY(stack, (CELL *)LOCAL_TrailTop)) {
next_node_on_branch = (choiceptr) STACK_POP_DOWN(stack);
or_frame = (or_fr_ptr) STACK_POP_DOWN(stack);
OrFr_nearest_livenode(or_frame) = OrFr_next(or_frame) = next_node_on_branch->cp_or_fr;
@ -658,7 +658,7 @@ void share_private_nodes(int worker_q) {
#ifdef DEBUG_OPTYAP
{ dep_fr_ptr aux_dep_fr = LOCAL_top_dep_fr;
while(aux_dep_fr != Yap_root_dep_fr) {
while(aux_dep_fr != GLOBAL_root_dep_fr) {
choiceptr top_cp_on_branch;
top_cp_on_branch = DepFr_cons_cp(aux_dep_fr);
while (YOUNGER_CP(top_cp_on_branch, B)) {

View File

@ -43,9 +43,9 @@ STD_PROTO(static inline void PUT_BUSY, (int));
static inline
void PUT_BUSY(int worker_num) {
LOCK(Yap_locks_bm_idle_workers);
BITMAP_delete(Yap_bm_idle_workers, worker_num);
UNLOCK(Yap_locks_bm_idle_workers);
LOCK(GLOBAL_locks_bm_idle_workers);
BITMAP_delete(GLOBAL_bm_idle_workers, worker_num);
UNLOCK(GLOBAL_locks_bm_idle_workers);
return;
}
@ -57,15 +57,15 @@ void PUT_BUSY(int worker_num) {
void make_root_choice_point(void) {
if (worker_id == 0) {
LOCAL_top_cp = Yap_root_cp = OrFr_node(Yap_root_or_fr) = B;
LOCAL_top_cp = GLOBAL_root_cp = OrFr_node(GLOBAL_root_or_fr) = B;
} else {
B = LOCAL_top_cp = Yap_root_cp;
B = LOCAL_top_cp = GLOBAL_root_cp;
B->cp_tr = TR = ((choiceptr) (worker_offset(0) + (CELL)(B)))->cp_tr;
}
B->cp_h = H0;
B->cp_ap = GETWORK;
B->cp_or_fr = Yap_root_or_fr;
LOCAL_top_or_fr = Yap_root_or_fr;
B->cp_or_fr = GLOBAL_root_or_fr;
LOCAL_top_or_fr = GLOBAL_root_or_fr;
LOCAL_load = 0;
LOCAL_prune_request = NULL;
BRANCH(worker_id, 0) = 0;
@ -75,7 +75,7 @@ void make_root_choice_point(void) {
void free_root_choice_point(void) {
B = LOCAL_top_cp->cp_b;
LOCAL_top_cp = (choiceptr) Yap_LocalBase;
LOCAL_top_cp = (choiceptr) LOCAL_LocalBase;
return;
}
@ -86,7 +86,7 @@ int p_share_work(void) {
if (! BITMAP_member(OrFr_members(REMOTE_top_or_fr(worker_q)), worker_id) ||
B == REMOTE_top_cp(worker_q) ||
(LOCAL_load <= Yap_delayed_release_load && OrFr_nearest_livenode(LOCAL_top_or_fr) == NULL)) {
(LOCAL_load <= GLOBAL_delayed_release_load && OrFr_nearest_livenode(LOCAL_top_or_fr) == NULL)) {
/* refuse sharing request */
REMOTE_reply_signal(LOCAL_share_request) = no_sharing;
LOCAL_share_request = MAX_WORKERS;
@ -98,14 +98,14 @@ int p_share_work(void) {
share_private_nodes(worker_q);
if ((son = fork()) == 0) {
worker_id = worker_q; /* child becomes requesting worker */
LOCAL = REMOTE + worker_id;
LOCAL = REMOTE(worker_id);
LOCAL_reply_signal = worker_ready;
PUT_IN_REQUESTABLE(worker_id);
PUT_BUSY(worker_id);
return FALSE;
} else {
Yap_worker_pid(worker_q) = son;
GLOBAL_worker_pid(worker_q) = son;
LOCAL_share_request = MAX_WORKERS;
PUT_IN_REQUESTABLE(worker_id);
@ -129,7 +129,7 @@ int q_share_work(int worker_p) {
/* make sharing request */
LOCK_WORKER(worker_p);
if (BITMAP_member(Yap_bm_idle_workers, worker_p) ||
if (BITMAP_member(GLOBAL_bm_idle_workers, worker_p) ||
REMOTE_share_request(worker_p) != MAX_WORKERS) {
/* worker p is idle or has another request */
UNLOCK_WORKER(worker_p);

View File

@ -40,7 +40,6 @@ void prune_shared_branch(choiceptr prune_cp) {
#ifdef TABLING_INNER_CUTS
tg_sol_fr_ptr tg_solutions, aux_tg_solutions;
#endif /* TABLING_INNER_CUTS */
leftmost_or_fr = CUT_leftmost_or_frame();
leftmost_cp = GetOrFr_node(leftmost_or_fr);
qg_solutions = NULL;
@ -58,7 +57,7 @@ void prune_shared_branch(choiceptr prune_cp) {
LOCK_OR_FRAME(prune_or_fr);
members = OrFr_members(prune_or_fr);
BITMAP_delete(members, worker_id);
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(members, i) && ltt == BRANCH_LTT(i, depth)) {
CUT_send_prune_request(i, prune_cp);
}
@ -139,7 +138,7 @@ void prune_shared_branch(choiceptr prune_cp) {
LOCK_OR_FRAME(leftmost_or_fr);
members = OrFr_members(leftmost_or_fr);
BITMAP_delete(members, worker_id);
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(members, i)) {
if (ltt >= BRANCH_LTT(i, depth)) {
CUT_send_prune_request(i, leftmost_cp->cp_b);
@ -231,7 +230,7 @@ void prune_shared_branch(choiceptr prune_cp) {
ltt = BRANCH_LTT(worker_id, depth);
LOCK_OR_FRAME(leftmost_or_fr);
BITMAP_difference(members, OrFr_members(leftmost_or_fr), members);
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(members, i)) {
if (ltt > BRANCH_LTT(i, depth)) {
CUT_send_prune_request(i, leftmost_cp->cp_b);

View File

@ -17,22 +17,22 @@
PBOp(getwork_first_time,e)
/* wait for a new parallel goal */
while (BITMAP_same(Yap_bm_present_workers, Yap_bm_finished_workers));
while (BITMAP_same(GLOBAL_bm_present_workers, GLOBAL_bm_finished_workers));
make_root_choice_point();
PUT_IN_EXECUTING(worker_id);
/* wait until everyone else is executing! */
while (! BITMAP_same(Yap_bm_present_workers, Yap_bm_executing_workers));
while (! BITMAP_same(GLOBAL_bm_present_workers, GLOBAL_bm_executing_workers));
SCHEDULER_GET_WORK();
shared_end:
PUT_IN_FINISHED(worker_id);
/* wait until everyone else is finished! */
while (! BITMAP_same(Yap_bm_present_workers, Yap_bm_finished_workers));
while (! BITMAP_same(GLOBAL_bm_present_workers, GLOBAL_bm_finished_workers));
PUT_OUT_EXECUTING(worker_id);
if (worker_id == 0) {
finish_yapor();
free_root_choice_point();
/* wait until no one is executing */
while (! BITMAP_empty(Yap_bm_executing_workers));
while (! BITMAP_empty(GLOBAL_bm_executing_workers));
goto fail;
} else {
PREG = GETWORK_FIRST_TIME;

View File

@ -88,7 +88,7 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
#define PUT_YAMOP_SEQ(INST) (INST)->u.Otapl.or_arg |= YAMOP_SEQ_FLAG
#define PUT_YAMOP_CUT(INST) (INST)->u.Otapl.or_arg |= YAMOP_CUT_FLAG
#define BRANCH(WORKER, DEPTH) Yap_branch(WORKER, DEPTH)
#define BRANCH(WORKER, DEPTH) GLOBAL_branch(WORKER, DEPTH)
#define BRANCH_LTT(WORKER, DEPTH) (BRANCH(WORKER, DEPTH) & YAMOP_LTT_BITS)
#define BRANCH_CUT(WORKER, DEPTH) (BRANCH(WORKER, DEPTH) & YAMOP_CUT_FLAG)
@ -108,7 +108,7 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
** Engine Macros **
** ----------------------- */
#define worker_offset(X) ((Yap_number_workers + X - worker_id) % Yap_number_workers * Yap_worker_area_size)
#define worker_offset(X) ((GLOBAL_number_workers + X - worker_id) % GLOBAL_number_workers * Yap_worker_area_size)
#define LOCK_OR_FRAME(fr) LOCK(OrFr_lock(fr))
#define UNLOCK_OR_FRAME(fr) UNLOCK(OrFr_lock(fr))
@ -177,7 +177,7 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
}
#define CUT_wait_leftmost() \
if (Yap_parallel_execution_mode) { \
if (GLOBAL_parallel_execution_mode) { \
/* parallel execution mode --> wait until leftmost */ \
int i, loop, depth, ltt; \
bitmap members; \
@ -191,13 +191,13 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
SCH_check_requests(); \
BITMAP_copy(members, OrFr_members(leftmost_or_fr)); \
BITMAP_delete(members, worker_id); \
for (i = 0; i < Yap_number_workers; i++) { \
for (i = 0; i < GLOBAL_number_workers; i++) { \
/* not leftmost in current frame if there is a */ \
/* worker in a left branch and it is not idle or */ \
/* if it is idle it is in a younger node */ \
if (BITMAP_member(members, i) && \
BRANCH_LTT(i, depth) > ltt && \
(! BITMAP_member(Yap_bm_idle_workers, i) || \
(! BITMAP_member(GLOBAL_bm_idle_workers, i) || \
leftmost_or_fr != REMOTE_top_or_fr(i))) { \
loop = TRUE; \
break; \
@ -205,7 +205,7 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
} \
} while (loop); \
leftmost_or_fr = OrFr_nearest_leftnode(leftmost_or_fr); \
} while (leftmost_or_fr != Yap_root_or_fr); \
} while (leftmost_or_fr != GLOBAL_root_or_fr); \
}
@ -216,27 +216,27 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
static inline
void PUT_IN_EXECUTING(int w) {
LOCK(Yap_locks_bm_executing_workers);
BITMAP_insert(Yap_bm_executing_workers, w);
UNLOCK(Yap_locks_bm_executing_workers);
LOCK(GLOBAL_locks_bm_executing_workers);
BITMAP_insert(GLOBAL_bm_executing_workers, w);
UNLOCK(GLOBAL_locks_bm_executing_workers);
return;
}
static inline
void PUT_OUT_EXECUTING(int w) {
LOCK(Yap_locks_bm_executing_workers);
BITMAP_delete(Yap_bm_executing_workers, w);
UNLOCK(Yap_locks_bm_executing_workers);
LOCK(GLOBAL_locks_bm_executing_workers);
BITMAP_delete(GLOBAL_bm_executing_workers, w);
UNLOCK(GLOBAL_locks_bm_executing_workers);
return;
}
static inline
void PUT_IN_FINISHED(int w) {
LOCK(Yap_locks_bm_finished_workers);
BITMAP_insert(Yap_bm_finished_workers, w);
UNLOCK(Yap_locks_bm_finished_workers);
LOCK(GLOBAL_locks_bm_finished_workers);
BITMAP_insert(GLOBAL_bm_finished_workers, w);
UNLOCK(GLOBAL_locks_bm_finished_workers);
return;
}
@ -244,18 +244,18 @@ void PUT_IN_FINISHED(int w) {
#ifdef TABLING_INNER_CUTS
static inline
void PUT_IN_PRUNING(int w) {
LOCK(Yap_locks_bm_pruning_workers);
BITMAP_insert(Yap_bm_pruning_workers, w);
UNLOCK(Yap_locks_bm_pruning_workers);
LOCK(GLOBAL_locks_bm_pruning_workers);
BITMAP_insert(GLOBAL_bm_pruning_workers, w);
UNLOCK(GLOBAL_locks_bm_pruning_workers);
return;
}
static inline
void PUT_OUT_PRUNING(int w) {
LOCK(Yap_locks_bm_pruning_workers);
BITMAP_delete(Yap_bm_pruning_workers, w);
UNLOCK(Yap_locks_bm_pruning_workers);
LOCK(GLOBAL_locks_bm_pruning_workers);
BITMAP_delete(GLOBAL_bm_pruning_workers, w);
UNLOCK(GLOBAL_locks_bm_pruning_workers);
return;
}
#endif /* TABLING_INNER_CUTS */
@ -268,18 +268,18 @@ void PUT_OUT_PRUNING(int w) {
static inline
void PUT_IN_REQUESTABLE(int p) {
LOCK(Yap_locks_bm_requestable_workers);
BITMAP_insert(Yap_bm_requestable_workers, p);
UNLOCK(Yap_locks_bm_requestable_workers);
LOCK(GLOBAL_locks_bm_requestable_workers);
BITMAP_insert(GLOBAL_bm_requestable_workers, p);
UNLOCK(GLOBAL_locks_bm_requestable_workers);
return;
}
static inline
void PUT_OUT_REQUESTABLE(int p) {
LOCK(Yap_locks_bm_requestable_workers);
BITMAP_delete(Yap_bm_requestable_workers, p);
UNLOCK(Yap_locks_bm_requestable_workers);
LOCK(GLOBAL_locks_bm_requestable_workers);
BITMAP_delete(GLOBAL_bm_requestable_workers, p);
UNLOCK(GLOBAL_locks_bm_requestable_workers);
return;
}
@ -381,7 +381,7 @@ int CUT_last_worker_left_pending_prune(or_fr_ptr or_frame) {
ltt = OrFr_pend_prune_ltt(or_frame);
members = OrFr_members(or_frame);
BITMAP_delete(members, worker_id);
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(members, i) && BRANCH_LTT(i, depth) > ltt)
return FALSE;
}
@ -404,7 +404,7 @@ or_fr_ptr CUT_leftmost_or_frame(void) {
ltt = BRANCH_LTT(worker_id, depth);
BITMAP_difference(members, OrFr_members(leftmost_or_fr), members);
if (members)
for (i = 0; i < Yap_number_workers; i++)
for (i = 0; i < GLOBAL_number_workers; i++)
if (BITMAP_member(members, i) && BRANCH_LTT(i, depth) > ltt)
goto update_nearest_leftnode_data;
BITMAP_copy(members, OrFr_members(leftmost_or_fr));
@ -438,12 +438,12 @@ or_fr_ptr CUT_leftmost_until(or_fr_ptr start_or_fr, int until_depth) {
leftmost_or_fr = OrFr_nearest_leftnode(start_or_fr);
depth = OrFr_depth(leftmost_or_fr);
if (depth > until_depth) {
BITMAP_copy(prune_members, Yap_bm_pruning_workers);
BITMAP_copy(prune_members, GLOBAL_bm_pruning_workers);
BITMAP_delete(prune_members, worker_id);
ltt = BRANCH_LTT(worker_id, depth);
BITMAP_intersection(members, prune_members, OrFr_members(leftmost_or_fr));
if (members) {
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(members, i) &&
BRANCH_LTT(i, depth) > ltt &&
EQUAL_OR_YOUNGER_CP(GetOrFr_node(leftmost_or_fr), REMOTE_pruning_scope(i)))
@ -458,7 +458,7 @@ or_fr_ptr CUT_leftmost_until(or_fr_ptr start_or_fr, int until_depth) {
ltt = BRANCH_LTT(worker_id, depth);
BITMAP_intersection(members, prune_members, OrFr_members(leftmost_or_fr));
if (members) {
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(members, i) &&
BRANCH_LTT(i, depth) > ltt &&
EQUAL_OR_YOUNGER_CP(GetOrFr_node(leftmost_or_fr), REMOTE_pruning_scope(i))) {

254
OPTYap/or.memory.c Normal file
View File

@ -0,0 +1,254 @@
/************************************************************************
** **
** The YapTab/YapOr/OPTYap systems **
** **
** YapTab extends the Yap Prolog engine to support sequential tabling **
** YapOr extends the Yap Prolog engine to support or-parallelism **
** OPTYap extends the Yap Prolog engine to support or-parallel tabling **
** **
** **
** Yap Prolog was developed at University of Porto, Portugal **
** **
************************************************************************/
/**************************************
** Includes & Declarations **
**************************************/
#include "Yap.h"
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
#include <signal.h>
#include <fcntl.h>
#include <string.h>
#include <sys/shm.h>
#include <sys/mman.h>
#include "Yatom.h"
#include "alloc.h"
#include "or.macros.h"
/************************************
** Macros & Declarations **
************************************/
#define GLOBAL_LOCAL_STRUCTS_AREA ADJUST_SIZE_TO_PAGE(sizeof(struct global_data) + MAX_WORKERS * sizeof(struct worker_local))
#ifdef MMAP_MEMORY_MAPPING_SCHEME
int fd_mapfile;
#elif SHM_MEMORY_MAPPING_SCHEME
int shm_mapid[MAX_WORKERS + 2];
#endif /* MEMORY_MAPPING_SCHEME */
/******************************************
** Local functions declaration **
******************************************/
#ifdef SHM_MEMORY_MAPPING_SCHEME
void shm_map_memory(int id, int size, void *shmaddr);
void shm_unmap_memory(int id);
#endif /* SHM_MEMORY_MAPPING_SCHEME */
/********************************
** Global functions **
********************************/
void Yap_init_yapor_global_local_memory(void) {
Yap_local = (struct worker_local *)(MMAP_ADDR - GLOBAL_LOCAL_STRUCTS_AREA);
Yap_global = (struct global_data *)(MMAP_ADDR - sizeof(struct global_data));
#ifdef MMAP_MEMORY_MAPPING_SCHEME
{ char mapfile[20];
strcpy(mapfile,"./mapfile");
itos(getpid(), &mapfile[9]);
if ((fd_mapfile = open(mapfile, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0)
Yap_Error(FATAL_ERROR, TermNil, "open error (Yap_init_yapor_global_local_memory)");
if (lseek(fd_mapfile, GLOBAL_LOCAL_STRUCTS_AREA, SEEK_SET) < 0)
Yap_Error(FATAL_ERROR, TermNil, "lseek error (Yap_init_yapor_global_local_memory)");
if (write(fd_mapfile, "", 1) < 0)
Yap_Error(FATAL_ERROR, TermNil, "write error (Yap_init_yapor_global_local_memory)");
if (mmap((void *) Yap_local, (size_t) GLOBAL_LOCAL_STRUCTS_AREA, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd_mapfile, 0) == (void *) -1)
Yap_Error(FATAL_ERROR, TermNil, "mmap error (Yap_init_global_local_memory)");
}
#elif SHM_MEMORY_MAPPING_SCHEME
/* place as segment MAX_WORKERS (0..MAX_WORKERS-1 reserved for worker areas) */
shm_map_memory(MAX_WORKERS, GLOBAL_LOCAL_STRUCTS_AREA, (void *) Yap_local);
#endif /* MEMORY_MAPPING_SCHEME */
return;
}
void Yap_init_yapor_stacks_memory(long TrailStackArea, long HeapStackArea, long GlobalLocalStackArea, int n_workers) {
long StacksArea;
TrailStackArea = ADJUST_SIZE_TO_PAGE(TrailStackArea);
HeapStackArea = ADJUST_SIZE_TO_PAGE(HeapStackArea);
GlobalLocalStackArea = ADJUST_SIZE_TO_PAGE(GlobalLocalStackArea);
Yap_worker_area_size = GlobalLocalStackArea + TrailStackArea;
#if defined(YAPOR_COPY) || defined(YAPOR_SBA)
StacksArea = HeapStackArea + Yap_worker_area_size * n_workers;
#elif defined(YAPOR_COW)
StacksArea = HeapStackArea;
#endif /* YAPOR_COPY || YAPOR_SBA || YAPOR_COW */
Yap_HeapBase = (ADDR) MMAP_ADDR;
LOCAL_GlobalBase = (ADDR) (MMAP_ADDR + HeapStackArea);
#ifdef MMAP_MEMORY_MAPPING_SCHEME
/* map stacks in a single go */
if (lseek(fd_mapfile, GLOBAL_LOCAL_STRUCTS_AREA + StacksArea, SEEK_SET) < 0)
Yap_Error(FATAL_ERROR, TermNil, "lseek error (Yap_init_yapor_stacks_memory)");
if (write(fd_mapfile, "", 1) < 0)
Yap_Error(FATAL_ERROR, TermNil, "write error (Yap_init_yapor_stacks_memory)");
if (mmap((void *) Yap_HeapBase, (size_t) StacksArea, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd_mapfile, GLOBAL_LOCAL_STRUCTS_AREA) == (void *) -1)
Yap_Error(FATAL_ERROR, TermNil, "mmap error (Yap_init_yapor_stacks_memory)");
#elif SHM_MEMORY_MAPPING_SCHEME
/* place heap stack segment as MAX_WORKERS+1 */
shm_map_memory(MAX_WORKERS + 1, HeapStackArea, (void *) Yap_HeapBase);
#if defined(YAPOR_COPY) || defined(YAPOR_SBA)
/* map segments for worker areas as 0..MAX_WORKERS-1 */
{ int i;
for (i = 0; i < n_workers; i++)
shm_map_memory(i, Yap_worker_area_size, LOCAL_GlobalBase + Yap_worker_area_size * i);
}
#endif /* YAPOR_COPY || YAPOR_SBA */
#endif /* MEMORY_MAPPING_SCHEME */
#ifdef YAPOR_COW
/* just allocate local space for stacks */
{ int private_fd_mapfile;
if ((private_fd_mapfile = open("/dev/zero", O_RDWR)) < 0)
Yap_Error(FATAL_ERROR, TermNil, "open error (Yap_init_yapor_stacks_memory)");
if (mmap(LOCAL_GlobalBase, Yap_worker_area_size, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, private_fd_mapfile, 0) == (void *) -1)
Yap_Error(FATAL_ERROR, TermNil, "mmap error (Yap_init_yapor_stacks_memory)");
close(private_fd_mapfile);
}
#endif /* YAPOR_COW */
#ifdef YAPOR_SBA
/* alloc space for the sparse binding array */
sba_size = Yap_worker_area_size * n_workers;
if ((binding_array = (char *)malloc(sba_size)) == NULL)
Yap_Error(FATAL_ERROR, TermNil, "malloc error (Yap_init_yapor_stacks_memory)");
if ((CELL)binding_array & MBIT)
Yap_Error(INTERNAL_ERROR, TermNil, "binding_array start address conflicts with tag used in IDB (Yap_init_yapor_stacks_memory)");
sba_offset = binding_array - LOCAL_GlobalBase;
sba_end = (int)binding_array + sba_size;
#endif /* YAPOR_SBA */
LOCAL_TrailBase = LOCAL_GlobalBase + GlobalLocalStackArea;
LOCAL_LocalBase = LOCAL_TrailBase - CellSize;
LOCAL_TrailTop = LOCAL_TrailBase + TrailStackArea;
HeapLim = LOCAL_GlobalBase;
Yap_InitHeap(Yap_HeapBase);
return;
}
void Yap_remap_yapor_memory(void) {
#if defined(YAPOR_COPY)
int i;
void *remap_addr = LOCAL_GlobalBase;
#ifdef MMAP_MEMORY_MAPPING_SCHEME
long remap_offset = (ADDR) remap_addr - (ADDR) Yap_local;
if (munmap(remap_addr, (size_t)(Yap_worker_area_size * GLOBAL_number_workers)) == -1)
Yap_Error(FATAL_ERROR, TermNil, "munmap error (Yap_remap_yapor_memory)");
for (i = 0; i < GLOBAL_number_workers; i++)
if (mmap(remap_addr + worker_offset(i), (size_t)Yap_worker_area_size, PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED, fd_mapfile, remap_offset + i * Yap_worker_area_size) == (void *) -1)
Yap_Error(FATAL_ERROR, TermNil, "mmap error (Yap_remap_yapor_memory)");
#else /* SHM_MEMORY_MAPPING_SCHEME */
for (i = 0; i < GLOBAL_number_workers; i++)
if (shmdt(remap_addr + Yap_worker_area_size * i) == -1)
Yap_Error(FATAL_ERROR, TermNil, "shmdt error (Yap_remap_yapor_memory)");
for (i = 0; i < GLOBAL_number_workers; i++)
if(shmat(shm_mapid[i], remap_addr + worker_offset(i), 0) == (void *) -1)
Yap_Error(FATAL_ERROR, TermNil, "shmat error (Yap_remap_yapor_memory)");
#endif /* MEMORY_MAPPING_SCHEME */
#elif defined(YAPOR_SBA)
/* setup workers so that they have different areas */
LOCAL_GlobalBase += worker_id * Yap_worker_area_size;
LOCAL_TrailBase += worker_id * Yap_worker_area_size;
LOCAL_LocalBase += worker_id * Yap_worker_area_size;
LOCAL_TrailTop += worker_id * Yap_worker_area_size;
#endif /* YAPOR_COPY || YAPOR_SBA */
}
void Yap_unmap_yapor_memory (void) {
int i;
INFORMATION_MESSAGE("Worker %d exiting...", worker_id);
for (i = 0; i < GLOBAL_number_workers; i++)
if (i != worker_id && GLOBAL_worker_pid(i) != 0) {
if (kill(GLOBAL_worker_pid(i), SIGKILL) != 0)
INFORMATION_MESSAGE("Can't kill process %d", GLOBAL_worker_pid(i));
else
INFORMATION_MESSAGE("Killing process %d", GLOBAL_worker_pid(i));
}
#ifdef YAPOR_COW
if (GLOBAL_number_workers > 1) {
if (kill(GLOBAL_master_worker, SIGINT) != 0)
INFORMATION_MESSAGE("Can't kill process %d", GLOBAL_master_worker);
else
INFORMATION_MESSAGE("Killing process %d", GLOBAL_master_worker);
}
#endif /* YAPOR_COW */
#ifdef MMAP_MEMORY_MAPPING_SCHEME
{ char mapfile[20];
strcpy(mapfile,"./mapfile");
#if defined(YAPOR_COPY) || defined(YAPOR_SBA)
itos(GLOBAL_worker_pid(0), &mapfile[9]);
#elif defined(YAPOR_COW)
itos(GLOBAL_master_worker, &mapfile[9]);
#endif /* YAPOR_COPY || YAPOR_SBA || YAPOR_COW */
if (remove(mapfile) == 0)
INFORMATION_MESSAGE("Removing mapfile \"%s\"", mapfile);
else
INFORMATION_MESSAGE("Can't remove mapfile \"%s\"", mapfile);
}
#elif SHM_MEMORY_MAPPING_SCHEME
#if defined(YAPOR_COPY) || defined(YAPOR_SBA)
shm_unmap_memory(MAX_WORKERS);
shm_unmap_memory(MAX_WORKERS + 1);
for (i = 0; i < GLOBAL_number_workers; i++)
shm_unmap_memory(i);
#elif defined(YAPOR_COW)
shm_unmap_memory(0);
#endif /* YAPOR_COPY || YAPOR_SBA || YAPOR_COW */
#endif /* MEMORY_MAPPING_SCHEME */
return;
}
/* ------------------------- **
** Local functions **
** ------------------------- */
#ifdef SHM_MEMORY_MAPPING_SCHEME
void shm_map_memory(int id, int size, void *shmaddr) {
if ((shm_mapid[id] = shmget(IPC_PRIVATE, size, SHM_R|SHM_W)) == -1)
Yap_Error(FATAL_ERROR, TermNil, "shmget error (shm_map_memory)");
if (shmat(shm_mapid[id], shmaddr, 0) == (void *) -1)
Yap_Error(FATAL_ERROR, TermNil, "shmat error (shm_map_memory)");
return;
}
void shm_unmap_memory(int id) {
if (shmctl(shm_mapid[id], IPC_RMID, 0) == 0)
INFORMATION_MESSAGE("Removing shared memory segment %d", shm_mapid[id]);
else
INFORMATION_MESSAGE("Can't remove shared memory segment %d", shm_mapid[id]);
return;
}
#endif /* SHM_MEMORY_MAPPING_SCHEME */
#endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA */

View File

@ -66,7 +66,6 @@ Dereferencing macros
if (0 == (D)) break; \
if (IsPairTerm(D)) goto LabelList; \
} while (TRUE);
#endif /* UNIQUE_TAG_FOR_PAIRS */
EXTERN inline Term Deref(Term a)
@ -108,6 +107,7 @@ A contains the address of the variable that is to be trailed
#define RESET_VARIABLE(V) (*(CELL *)(V) = 0)
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
inline EXTERN void
AlignGlobalForDouble(void)
{
@ -118,6 +118,7 @@ AlignGlobalForDouble(void)
H++;
}
}
#endif /* SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT */
#ifdef YAPOR

View File

@ -87,21 +87,21 @@ reset_trail(tr_fr_ptr tr_top, tr_fr_ptr trp)
void make_root_choice_point(void) {
if (worker_id == 0) {
LOCAL_top_cp = Yap_root_cp = OrFr_node(Yap_root_or_fr) = B;
LOCAL_top_cp = GLOBAL_root_cp = OrFr_node(GLOBAL_root_or_fr) = B;
B->cp_h = H0;
B->cp_ap = GETWORK;
B->cp_or_fr = Yap_root_or_fr;
B->cp_or_fr = GLOBAL_root_or_fr;
} else {
B = LOCAL_top_cp = Yap_root_cp;
B = LOCAL_top_cp = GLOBAL_root_cp;
TR = B->cp_tr;
}
LOCAL_top_or_fr = Yap_root_or_fr;
LOCAL_top_or_fr = GLOBAL_root_or_fr;
LOCAL_load = 0;
LOCAL_prune_request = NULL;
BRANCH(worker_id, 0) = 0;
H_FZ = (CELL *) Yap_GlobalBase;
B_FZ = (choiceptr) Yap_LocalBase;
TR_FZ = (tr_fr_ptr) Yap_TrailBase;
H_FZ = (CELL *) LOCAL_GlobalBase;
B_FZ = (choiceptr) LOCAL_LocalBase;
TR_FZ = (tr_fr_ptr) LOCAL_TrailBase;
}
@ -109,10 +109,10 @@ void free_root_choice_point(void) {
reset_trail(LOCAL_top_cp->cp_tr, TR);
TR = LOCAL_top_cp->cp_tr;
B = LOCAL_top_cp->cp_b;
LOCAL_top_cp = (choiceptr) Yap_LocalBase;
H_FZ = (CELL *) Yap_GlobalBase;
B_FZ = (choiceptr) Yap_LocalBase;
TR_FZ = (tr_fr_ptr) Yap_TrailBase;
LOCAL_top_cp = (choiceptr) LOCAL_LocalBase;
H_FZ = (CELL *) LOCAL_GlobalBase;
B_FZ = (choiceptr) LOCAL_LocalBase;
TR_FZ = (tr_fr_ptr) LOCAL_TrailBase;
}
@ -121,7 +121,7 @@ void p_share_work(void) {
if (! BITMAP_member(OrFr_members(REMOTE_top_or_fr(worker_q)), worker_id) ||
B == REMOTE_top_cp(worker_q) ||
(LOCAL_load <= Yap_delayed_release_load && OrFr_nearest_livenode(LOCAL_top_or_fr) == NULL)) {
(LOCAL_load <= GLOBAL_delayed_release_load && OrFr_nearest_livenode(LOCAL_top_or_fr) == NULL)) {
/* refuse sharing request */
REMOTE_reply_signal(LOCAL_share_request) = no_sharing;
LOCAL_share_request = MAX_WORKERS;
@ -163,7 +163,7 @@ int q_share_work(int worker_p) {
/* make sharing request */
LOCK_WORKER(worker_p);
if (BITMAP_member(Yap_bm_idle_workers, worker_p) ||
if (BITMAP_member(GLOBAL_bm_idle_workers, worker_p) ||
REMOTE_share_request(worker_p) != MAX_WORKERS) {
/* worker p is idle or has another request */
UNLOCK_WORKER(worker_p);

Some files were not shown because too many files have changed in this diff Show More