more updates to HEAPFIELDS.

This commit is contained in:
Vitor Santos Costa 2009-10-30 23:59:00 +00:00
parent 7116d1385b
commit 923094bd01
14 changed files with 1055 additions and 585 deletions

90
C/agc.c
View File

@ -20,6 +20,7 @@ static char SccsId[] = "@(#)agc.c 1.3 3/15/90";
#include "absmi.h"
#include "foreign.h"
#include "alloc.h"
#include "yapio.h"
#include "iopreds.h"
@ -152,6 +153,7 @@ AtomAdjust(Atom a)
#define SIndexAdjust(P) (P)
#define LocalAddrAdjust(P) (P)
#define GlobalAddrAdjust(P) (P)
#define OpListAdjust(P) (P)
#define PtoLUCAdjust(P) (P)
#define PtoStCAdjust(P) (P)
#define PtoArrayEAdjust(P) (P)
@ -173,6 +175,8 @@ AtomAdjust(Atom a)
#define XAdjust(P) (P)
#define YAdjust(P) (P)
#define HoldEntryAdjust(P) (P)
#define CodeCharPAdjust(P) (P)
#define CodeVoidPAdjust(P) (P)
#define recompute_mask(dbr)
@ -196,64 +200,21 @@ static void init_reg_copies(void)
static void
mark_hash_entry(AtomHashEntry *HashPtr)
RestoreAtomList(Atom atm)
{
Atom atm;
AtomEntry *at;
atm = HashPtr->Entry;
if (atm) {
AtomEntry *at = RepAtom(atm);
do {
RestoreAtom(at);
atm = at->NextOfAE;
at = RepAtom(CleanAtomMarkedBit(atm));
} while (!EndOfPAEntr(at));
}
at = RepAtom(atm);
if (EndOfPAEntr(at))
return;
do {
RestoreAtom(atm);
atm = CleanAtomMarkedBit(at->NextOfAE);
at = RepAtom(atm);
} while (!EndOfPAEntr(at));
}
static void
mark_hash_preds(void)
{
UInt i;
for (i = 0; i < PredHashTableSize; i++) {
PredEntry *p = PredHash[i];
while (p) {
Prop nextp = p->NextOfPE = PropAdjust(p->NextOfPE);
CleanCode(p);
p = RepPredProp(nextp);
}
}
}
/*
* This is the really tough part, to restore the whole of the heap
*/
static void
mark_atoms(void)
{
AtomHashEntry *HashPtr = HashChain;
register int i;
restore_codes();
for (i = 0; i < AtomHashTableSize; ++i) {
mark_hash_entry(HashPtr);
HashPtr++;
}
HashPtr = WideHashChain;
for (i = 0; i < WideAtomHashTableSize; ++i) {
mark_hash_entry(HashPtr);
HashPtr++;
}
mark_hash_entry(&INVISIBLECHAIN);
RestoreAtom(RepAtom(AtomFoundVar));
RestoreAtom(RepAtom(AtomFreeTerm));
mark_hash_preds();
}
static void
mark_trail(void)
@ -379,26 +340,6 @@ mark_stacks(void)
mark_global();
}
static void
mark_streams(void)
{
int i;
for (i=0; i < MaxStreams; i++) {
if (!(Stream[i].status & (Free_Stream_f|Socket_Stream_f|InMemory_Stream_f|Pipe_Stream_f))) {
/* This is a file, so it has a name */
AtomEntry *ae = RepAtom(Stream[i].u.file.name);
MarkAtomEntry(ae);
ae = RepAtom(AtomOfTerm(Stream[i].u.file.user_name));
MarkAtomEntry(ae);
}
}
for (i=0;i<NOfFileAliases;i++) {
AtomEntry *ae = RepAtom(FileAliases[i].name);
MarkAtomEntry(ae);
}
}
static void
clean_atom_list(AtomHashEntry *HashPtr)
{
@ -480,8 +421,7 @@ atom_gc(void)
YAPEnterCriticalSection();
init_reg_copies();
mark_stacks();
mark_streams();
mark_atoms();
restore_codes();
clean_atoms();
AGcLastCall = NOfAtoms;
YAPLeaveCriticalSection();

177
C/init.c
View File

@ -79,10 +79,10 @@ STD_PROTO(void exit, (int));
/************* variables related to memory allocation ***************/
ADDR Yap_HeapBase;
#if defined(THREADS)
ADDR Yap_HeapBase;
struct restore_info rinfo[MAX_THREADS];
struct thread_globs Yap_thread_gl[MAX_THREADS];
@ -1006,14 +1006,14 @@ InitEnvInst(yamop start[2], yamop **instp, op_numbers opc, PredEntry *pred)
}
static void
InitOtaplInst(yamop start[1], OPCODE opc)
InitOtaplInst(yamop start[1], OPCODE opc, PredEntry *pe)
{
yamop *ipc = start;
/* this is a place holder, it should not really be used */
ipc->opc = Yap_opcode(opc);
ipc->u.Otapl.s = 0;
ipc->u.Otapl.p = PredFail;
ipc->u.Otapl.p = pe;
ipc->u.Otapl.d = NULL;
#ifdef YAPOR
INIT_YAMOP_LTT(ipc, 1);
@ -1057,27 +1057,74 @@ InitLogDBErasedMarker(void)
}
static void
InitCodes(void)
InitAtoms(void)
{
int i;
AtomHashTableSize = MaxHash;
HashChain = (AtomHashEntry *)Yap_AllocAtomSpace(sizeof(AtomHashEntry) * MaxHash);
if (HashChain == NULL) {
Yap_Error(FATAL_ERROR,MkIntTerm(0),"allocating initial atom table");
}
for (i = 0; i < MaxHash; ++i) {
INIT_RWLOCK(HashChain[i].AERWLock);
HashChain[i].Entry = NIL;
}
NOfAtoms = 0;
#if THREADS
SF_STORE->AtFoundVar = Yap_LookupAtom("**");
Yap_ReleaseAtom(AtomFoundVar);
SF_STORE->AtFreeTerm = Yap_LookupAtom("?");
Yap_ReleaseAtom(AtomFreeTerm);
SF_STORE->AtNil = Yap_LookupAtom("[]");
SF_STORE->AtDot = Yap_LookupAtom(".");
#else
Yap_LookupAtomWithAddress("**",&(SF_STORE->AtFoundVar));
Yap_ReleaseAtom(AtomFoundVar);
Yap_LookupAtomWithAddress("?",&(SF_STORE->AtFreeTerm));
Yap_ReleaseAtom(AtomFreeTerm);
Yap_LookupAtomWithAddress("[]",&(SF_STORE->AtNil));
Yap_LookupAtomWithAddress(".",&(SF_STORE->AtDot));
#endif
}
static void
InitWideAtoms(void)
{
int i;
WideAtomHashTableSize = MaxWideHash;
WideHashChain = (AtomHashEntry *)Yap_AllocAtomSpace(sizeof(AtomHashEntry) * MaxWideHash);
if (WideHashChain == NULL) {
Yap_Error(FATAL_ERROR,MkIntTerm(0),"allocating wide atom table");
}
for (i = 0; i < MaxWideHash; ++i) {
INIT_RWLOCK(WideHashChain[i].AERWLock);
WideHashChain[i].Entry = NIL;
}
NOfWideAtoms = 0;
}
static void
InitInvisibleAtoms(void)
{
/* initialise invisible chain */
Yap_heap_regs->invisiblechain.Entry = NIL;
INIT_RWLOCK(Yap_heap_regs->invisiblechain.AERWLock);
#include "iatoms.h"
#include "ihstruct.h"
Yap_InitModules();
}
#ifdef THREADS
INIT_LOCK(Yap_heap_regs->thread_handles_lock);
{
int i;
for (i=0; i < MAX_THREADS; i++) {
Yap_heap_regs->thread_handle[i].in_use = FALSE;
Yap_heap_regs->thread_handle[i].zombie = FALSE;
Yap_heap_regs->thread_handle[i].local_preds = NULL;
static void
InitThreadHandles(void)
{
int i;
for (i=0; i < MAX_THREADS; i++) {
Yap_heap_regs->thread_handle[i].in_use = FALSE;
Yap_heap_regs->thread_handle[i].zombie = FALSE;
Yap_heap_regs->thread_handle[i].local_preds = NULL;
#ifdef LOW_LEVEL_TRACER
Yap_heap_regs->thread_handle[i].thread_inst_count = 0LL;
Yap_heap_regs->thread_handle[i].thread_inst_count = 0LL;
#endif
pthread_mutex_init(&Yap_heap_regs->thread_handle[i].tlock, NULL);
}
pthread_mutex_init(&Yap_heap_regs->thread_handle[i].tlock, NULL);
}
Yap_heap_regs->thread_handle[0].id = 0;
Yap_heap_regs->thread_handle[0].in_use = TRUE;
@ -1087,22 +1134,14 @@ InitCodes(void)
Yap_heap_regs->thread_handle[0].handle = pthread_self();
pthread_mutex_init(&ThreadHandle[0].tlock, NULL);
pthread_mutex_init(&ThreadHandle[0].tlock_status, NULL);
Yap_heap_regs->n_of_threads = 1;
Yap_heap_regs->n_of_threads_created = 1;
Yap_heap_regs->threads_total_time = 0;
#endif
#ifdef YAPOR
Yap_heap_regs->n_of_threads = 1;
}
#endif
static void
InitCodes(void)
{
#include "ihstruct.h"
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_heap_regs->bgl);
INIT_LOCK(Yap_heap_regs->free_blocks_lock);
INIT_LOCK(Yap_heap_regs->heap_used_lock);
INIT_LOCK(Yap_heap_regs->heap_top_lock);
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);
Yap_heap_regs->heap_top_owner = -1;
{
int i;
for (i=0; i < MAX_AGENTS; i++) {
@ -1156,38 +1195,9 @@ InitCodes(void)
Yap_heap_regs->wl.consultbase = Yap_heap_regs->wl.consultsp =
Yap_heap_regs->wl.consultlow + Yap_heap_regs->wl.consultcapacity;
#endif /* YAPOR */
Yap_heap_regs->system_pred_goal_expansion_on = FALSE;
Yap_heap_regs->maxdepth = 0;
Yap_heap_regs->maxlist = 0;
Yap_heap_regs->maxwriteargs = 0;
Yap_heap_regs->atprompt = 0;
/* use Quintus compatible atom_chars and number_chars, not ISO compatible */
Yap_heap_regs->char_conversion_table = NULL;
Yap_heap_regs->char_conversion_table2 = NULL;
/*
don't initialise this here, this is initialised by Yap_InitModules!!!!
Yap_heap_regs->no_of_modules = 1;
*/
Yap_heap_regs->term_refound_var = MkAtomTerm(AtomRefoundVar);
Yap_heap_regs->n_of_file_aliases = 0;
Yap_heap_regs->file_aliases = NULL;
Yap_heap_regs->foreign_code_loaded = NULL;
Yap_heap_regs->yap_lib_dir = NULL;
Yap_heap_regs->agc_last_call = 0;
Yap_heap_regs->agc_threshold = 10000;
Yap_heap_regs->agc_hook = NULL;
Yap_heap_regs->parser_error_style = EXCEPTION_ON_PARSER_ERROR;
Yap_heap_regs->global_hold_entry = Yap_InitAtomHold();
Yap_heap_regs->size_of_overflow = 0;
/* make sure no one else can use these two atoms */
CurrentModule = 0;
OpList = NULL;
Yap_heap_regs->op_list = NULL;
Yap_heap_regs->dead_static_clauses = NULL;
Yap_heap_regs->dead_mega_clauses = NULL;
Yap_heap_regs->dead_static_indices = NULL;
Yap_ReleaseAtom(AtomOfTerm(Yap_heap_regs->term_refound_var));
/* make sure we have undefp defined */
/* predicates can only be defined after this point */
@ -1201,7 +1211,6 @@ InitCodes(void)
Yap_heap_regs->getwork_seq_code.u.Otapl.p = RepPredProp(PredPropByAtom(AtomGetworkSeq, PROLOG_MODULE));
#endif /* YAPOR */
Yap_heap_regs->yap_streams = NULL;
}
@ -1216,7 +1225,6 @@ InitVersion(void)
#endif
}
void
Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_size,
int n_workers, int sch_loop, int delay_load)
@ -1273,57 +1281,17 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
#else
Yap_InitMemory (Trail, Heap, Stack+Atts);
#endif /* YAPOR */
Yap_AttsSize = Atts;
#if defined(YAPOR) || defined(TABLING)
Yap_init_global(max_table_size, n_workers, sch_loop, delay_load);
#endif /* YAPOR || TABLING */
Yap_AttsSize = Atts;
Yap_InitTime ();
AtomHashTableSize = MaxHash;
WideAtomHashTableSize = MaxWideHash;
HashChain = (AtomHashEntry *)Yap_AllocAtomSpace(sizeof(AtomHashEntry) * MaxHash);
if (HashChain == NULL) {
Yap_Error(FATAL_ERROR,MkIntTerm(0),"allocating initial atom table");
}
for (i = 0; i < MaxHash; ++i) {
INIT_RWLOCK(HashChain[i].AERWLock);
HashChain[i].Entry = NIL;
}
WideHashChain = (AtomHashEntry *)Yap_AllocAtomSpace(sizeof(AtomHashEntry) * MaxWideHash);
if (WideHashChain == NULL) {
Yap_Error(FATAL_ERROR,MkIntTerm(0),"allocating initial atom table");
}
for (i = 0; i < MaxWideHash; ++i) {
INIT_RWLOCK(WideHashChain[i].AERWLock);
WideHashChain[i].Entry = NIL;
}
NOfAtoms = 0;
NOfWideAtoms = 0;
PredsInHashTable = 0;
#if THREADS
SF_STORE->AtFoundVar = Yap_LookupAtom("**");
Yap_ReleaseAtom(AtomFoundVar);
SF_STORE->AtFreeTerm = Yap_LookupAtom("?");
Yap_ReleaseAtom(AtomFreeTerm);
SF_STORE->AtNil = Yap_LookupAtom("[]");
SF_STORE->AtDot = Yap_LookupAtom(".");
#else
Yap_LookupAtomWithAddress("**",&(SF_STORE->AtFoundVar));
Yap_ReleaseAtom(AtomFoundVar);
Yap_LookupAtomWithAddress("?",&(SF_STORE->AtFreeTerm));
Yap_ReleaseAtom(AtomFreeTerm);
Yap_LookupAtomWithAddress("[]",&(SF_STORE->AtNil));
Yap_LookupAtomWithAddress(".",&(SF_STORE->AtDot));
#endif
/* InitAbsmi must be done before InitCodes */
/* This must be done before initialising predicates */
for (i = 0; i <= LAST_FLAG; i++) {
yap_flags[i] = 0;
}
#ifdef LOW_PROF
ProfilerOn = FALSE;
FPreds = NULL;
#endif
ActiveSignals = 0;
DoingUndefp = FALSE;
DelayArenaOverflows = 0;
@ -1342,7 +1310,6 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
InitDebug();
InitVersion();
Yap_InitSysPath();
InitFlags();
InitStdPreds();
/* make sure tmp area is available */
{

View File

@ -967,7 +967,7 @@ p_setprompt (void)
Term t = Deref(ARG1);
if (IsVarTerm (t) || !IsAtomTerm (t))
return (FALSE);
*AtPrompt = AtomOfTerm (t);
AtPrompt = AtomOfTerm (t);
return (TRUE);
}
@ -989,7 +989,7 @@ p_prompt (void)
{ /* prompt(Old,New) */
Term t = Deref (ARG2);
Atom a;
if (!Yap_unify_constant (ARG1, MkAtomTerm (*AtPrompt)))
if (!Yap_unify_constant (ARG1, MkAtomTerm (AtPrompt)))
return (FALSE);
if (IsVarTerm (t) || !IsAtomTerm (t))
return (FALSE);
@ -999,7 +999,7 @@ p_prompt (void)
return(FALSE);
}
strncpy(Prompt, RepAtom (a)->StrOfAE, MAX_PROMPT);
*AtPrompt = a;
AtPrompt = a;
return (TRUE);
}
@ -1118,7 +1118,7 @@ ReadlineGetc(int sno)
Yap_PrologMode &= ~ConsoleGetcMode;
}
newline=FALSE;
strncpy (Prompt, RepAtom (*AtPrompt)->StrOfAE, MAX_PROMPT);
strncpy (Prompt, RepAtom (AtPrompt)->StrOfAE, MAX_PROMPT);
/* window of vulnerability closed */
if (myrl_line == NULL)
return console_post_process_eof(s);
@ -1369,7 +1369,7 @@ ConsoleSocketGetc(int sno)
while ((ch = *cptr++) != '\0') {
Stream[StdErrStream].stream_putc(StdErrStream, ch);
}
strncpy(Prompt, RepAtom (*AtPrompt)->StrOfAE, MAX_PROMPT);
strncpy(Prompt, RepAtom (AtPrompt)->StrOfAE, MAX_PROMPT);
newline = FALSE;
}
/* should be able to use a buffer */
@ -1444,7 +1444,7 @@ ConsolePipeGetc(int sno)
while ((ch = *cptr++) != '\0') {
Stream[StdErrStream].stream_putc(StdErrStream, ch);
}
strncpy(Prompt, RepAtom (*AtPrompt)->StrOfAE, MAX_PROMPT);
strncpy(Prompt, RepAtom (AtPrompt)->StrOfAE, MAX_PROMPT);
newline = FALSE;
}
#if _MSC_VER || defined(__MINGW32__)
@ -1577,7 +1577,7 @@ ConsoleGetc(int sno)
Stream[StdErrStream].stream_putc(StdErrStream, ch);
}
}
strncpy (Prompt, RepAtom (*AtPrompt)->StrOfAE, MAX_PROMPT);
strncpy (Prompt, RepAtom (AtPrompt)->StrOfAE, MAX_PROMPT);
newline = FALSE;
}
#if HAVE_SIGINTERRUPT

View File

@ -1007,7 +1007,6 @@ restore_heap_regs(void)
}
HeapMax = Yap_heap_regs->heap_used = OldHeapUsed;
HeapLim = Yap_GlobalBase;
restore_codes();
}
/* adjust abstract machine registers */
@ -1170,45 +1169,6 @@ rehash(CELL *oldcode, int NOfE, int KindOfEntries)
#include "rheap.h"
/* restore the atom entries which are invisible for the user */
static void
RestoreForeignCodeStructure(void)
{
ForeignObj *f_code;
if (ForeignCodeLoaded != NULL)
ForeignCodeLoaded = (void *)AddrAdjust((ADDR)ForeignCodeLoaded);
f_code = ForeignCodeLoaded;
while (f_code != NULL) {
StringList objs, libs;
if (f_code->objs != NULL)
f_code->objs = (StringList)AddrAdjust((ADDR)f_code->objs);
objs = f_code->objs;
while (objs != NULL) {
if (objs->next != NULL)
objs->next = (StringList)AddrAdjust((ADDR)objs->next);
if (objs->s != NULL)
objs->s = (char *)AddrAdjust((ADDR)objs->s);
objs = objs->next;
}
if (f_code->libs != NULL)
f_code->libs = (StringList)AddrAdjust((ADDR)f_code->libs);
libs = f_code->libs;
while (libs != NULL) {
if (libs->next != NULL)
libs->next = (StringList)AddrAdjust((ADDR)libs->next);
if (libs->s != NULL)
libs->s = (char *)AddrAdjust((ADDR)libs->s);
libs = libs->next;
}
if (f_code->f != NULL)
f_code->f = (char *)AddrAdjust((ADDR)f_code->f);
if (f_code->next != NULL)
f_code->next = (ForeignObj *)AddrAdjust((ADDR)f_code->f);
f_code = f_code->next;
}
}
/* restore the atom entries which are invisible for the user */
static void
RestoreIOStructures(void)
@ -1333,25 +1293,8 @@ RestoreHashPreds(void)
static void
restore_heap(void)
{
AtomHashEntry *HashPtr = HashChain;
register int i;
for (i = 0; i < AtomHashTableSize; ++i) {
HashPtr->Entry = AtomAdjust(HashPtr->Entry);
RestoreAtomList(HashPtr->Entry);
HashPtr++;
}
HashPtr = WideHashChain;
for (i = 0; i < WideAtomHashTableSize; ++i) {
HashPtr->Entry = AtomAdjust(HashPtr->Entry);
RestoreAtomList(HashPtr->Entry);
HashPtr++;
}
INVISIBLECHAIN.Entry = AtomAdjust(INVISIBLECHAIN.Entry);
RestoreAtomList(INVISIBLECHAIN.Entry);
RestoreAtom(RepAtom(AtomFoundVar));
RestoreAtom(RepAtom(AtomFreeTerm));
restore_codes();
RestoreHashPreds();
RestoreForeignCodeStructure();
RestoreIOStructures();
}

View File

@ -93,7 +93,7 @@ typedef struct ForeignLoadItem {
StringList objs;
StringList libs;
char *f;
int module;
Term module;
struct ForeignLoadItem *next;
} ForeignObj;

View File

@ -18,12 +18,6 @@
#ifndef HEAP_H
#define HEAP_H 1
#if defined(YAPOR) || defined(THREADS)
#define WL wl[worker_id]
#else
#define WL wl
#endif
#if defined(THREADS)
#define RINFO rinfo[worker_id]
#else
@ -180,6 +174,7 @@ typedef struct worker_local_struct {
struct array_entry *dynamic_arrays;
struct static_array_entry *static_arrays;
struct global_entry *global_variables;
struct reduction_counters call_counters;
int allow_restart;
Term global_arena;
UInt global_arena_overflows;
@ -224,136 +219,9 @@ typedef int (*Agc_hook)(Atom);
typedef struct various_codes {
/* memory allocation and management */
special_functors funcs;
UInt hole_size;
struct malloc_state *av_;
#if USE_DL_MALLOC
struct memory_hole memory_holes[MAX_DLMALLOC_HOLES];
UInt nof_memory_holes;
#endif
Int heap_used;
Int heap_max;
ADDR heap_top;
ADDR heap_lim;
struct FREEB *free_blocks;
#if defined(YAPOR) || defined(THREADS)
lockvar heap_used_lock; /* protect HeapUsed */
lockvar heap_top_lock; /* protect HeapTop */
int heap_top_owner;
#endif
/* multi-thread/ORP support */
#if defined(YAPOR) || defined(THREADS)
unsigned int n_of_threads; /* number of threads and processes in system */
unsigned int n_of_threads_created; /* number of threads created since start */
UInt threads_total_time; /* total run time for dead threads */
lockvar bgl; /* protect long critical regions */
lockvar free_blocks_lock; /* protect the list of free blocks */
worker_local wl[MAX_AGENTS];
#else
worker_local wl;
#endif
#ifdef THREADS
lockvar thread_handles_lock; /* protect ThreadManipulation */
struct thandle thread_handle[MAX_THREADS];
#endif
/* atoms and functors */
UInt n_of_atoms;
UInt atom_hash_table_size;
UInt wide_atom_hash_table_size;
UInt n_of_wide_atoms;
AtomHashEntry invisiblechain;
AtomHashEntry *wide_hash_chain;
AtomHashEntry *hash_chain;
#include "tatoms.h"
/* Terms multiply used */
#include "hstruct.h"
/* Dead clauses and IDB entries */
struct static_clause *dead_static_clauses;
struct static_mega_clause *dead_mega_clauses;
struct static_index *dead_static_indices;
struct logic_upd_clause *db_erased_list;
struct logic_upd_index *db_erased_ilist;
#if defined(YAPOR) || defined(THREADS)
lockvar dead_static_clauses_lock; /* protect DeadStaticClauses */
lockvar dead_mega_clauses_lock; /* protect DeadMegaClauses */
lockvar dead_static_indices_lock; /* protect DeadStaticIndices */
#endif
/* execution counters */
struct reduction_counters call_counters;
/* number of attribute modules */
UInt atts_size;
/* stack overflow expansion/gc control */
int allow_local_expansion;
int allow_global_expansion;
int allow_trail_expansion;
unsigned int size_of_overflow;
struct hold_entry *global_hold_entry;
UInt agc_last_call; /* amount of space recovered in all garbage collections */
UInt agc_threshold; /* amount of space recovered in all garbage collections */
Agc_hook agc_hook;
/* YAP control flags */
Int yap_flags_field[NUMBER_OF_YAP_FLAGS];
/* Operators */
struct operator_entry *op_list;
/* Input/Output */
/* stream array */
struct stream_desc *yap_streams;
/* stream aliases */
UInt n_of_file_aliases;
UInt sz_of_file_aliases;
struct AliasDescS * file_aliases;
/* prompting */
Atom atprompt;
char prompt[MAX_PROMPT];
/* readline */
#if HAVE_LIBREADLINE
char *readline_buf, *readline_pos;
#endif
/* ISO char conversion: I will make no comments */
char *char_conversion_table;
char *char_conversion_table2;
/* write depth */
UInt maxdepth, maxlist, maxwriteargs;
/* what to do when the parser gives an error: should be thread bound? */
int parser_error_style;
/* library location. */
char *yap_lib_dir;
/* time */
void *last_wtime;
/* profiling */
int debugger_output_msg;
#if LOW_PROF
int profiler_on;
int offline_profiler;
FILE *f_prof, *f_preds;
UInt prof_preds;
#endif /* LOW_PROF */
/* foreign code loaded */
void *foreign_code_loaded;
ADDR foreign_code_base;
ADDR foreign_code_top;
ADDR foreign_code_max;
#if defined(YAPOR) || defined(TABLING)
struct global_data global;
@ -367,71 +235,12 @@ extern struct various_codes *Yap_heap_regs;
#define Yap_heap_regs ((all_heap_codes *)HEAP_INIT_BASE)
#endif
#define Yap_HoleSize Yap_heap_regs->hole_size
#define Yap_av Yap_heap_regs->av_
#define Yap_AttsSize Yap_heap_regs->atts_size
#define Yap_MemoryHoles Yap_heap_regs->memory_holes
#define Yap_NOfMemoryHoles Yap_heap_regs->nof_memory_holes
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
#define HeapUsed Yap_givemallinfo()
#ifdef YAPOR
#define HeapUsedLock Yap_heap_regs->heap_used_lock
#endif
#else
#define HeapUsed Yap_heap_regs->heap_used
#define HeapUsedLock Yap_heap_regs->heap_used_lock
#endif
#define HeapMax Yap_heap_regs->heap_max
#define HeapTop Yap_heap_regs->heap_top
#define HeapLim Yap_heap_regs->heap_lim
#define INVISIBLECHAIN Yap_heap_regs->invisiblechain
#define max_depth Yap_heap_regs->maxdepth
#define max_list Yap_heap_regs->maxlist
#define max_write_args Yap_heap_regs->maxwriteargs
#define AtPrompt (&(Yap_heap_regs->atprompt ))
#define Prompt Yap_heap_regs->prompt
#define yap_flags Yap_heap_regs->yap_flags_field
#ifdef THREADS
#define ThreadHandlesLock Yap_heap_regs->thread_handles_lock
#define ThreadHandle Yap_heap_regs->thread_handle
#endif
#define NOfAtoms Yap_heap_regs->n_of_atoms
#define AtomHashTableSize Yap_heap_regs->atom_hash_table_size
#define HashChain Yap_heap_regs->hash_chain
#define NOfWideAtoms Yap_heap_regs->n_of_wide_atoms
#define WideAtomHashTableSize Yap_heap_regs->wide_atom_hash_table_size
#define WideHashChain Yap_heap_regs->wide_hash_chain
#define CharConversionTable Yap_heap_regs->char_conversion_table
#define CharConversionTable2 Yap_heap_regs->char_conversion_table2
#define OpList Yap_heap_regs->op_list
#define FloatFormat Yap_heap_regs->float_format
#define PROLOG_MODULE 0
#include "dhstruct.h"
#define DBErasedList Yap_heap_regs->db_erased_list
#define DBErasedIList Yap_heap_regs->db_erased_ilist
#define Stream Yap_heap_regs->yap_streams
#define output_msg Yap_heap_regs->debugger_output_msg
#define NOfFileAliases Yap_heap_regs->n_of_file_aliases
#define SzOfFileAliases Yap_heap_regs->sz_of_file_aliases
#define FileAliases Yap_heap_regs->file_aliases
#if LOW_PROF
#define ProfilerOn Yap_heap_regs->profiler_on
#define Yap_OffLineProfiler Yap_heap_regs->offline_profiler
#define FProf Yap_heap_regs->f_prof
#define FPreds Yap_heap_regs->f_preds
#define ProfPreds Yap_heap_regs->prof_preds
#endif /* LOW_PROF */
#define ReductionsCounter Yap_heap_regs->call_counters.reductions
#define PredEntriesCounter Yap_heap_regs->call_counters.reductions_retries
#define RetriesCounter Yap_heap_regs->call_counters.retries
#define ReductionsCounterOn Yap_heap_regs->call_counters.reductions_on
#define PredEntriesCounterOn Yap_heap_regs->call_counters.reductions_retries_on
#define RetriesCounterOn Yap_heap_regs->call_counters.retries_on
#define Yap_LibDir Yap_heap_regs->yap_lib_dir
#define AGcLastCall Yap_heap_regs->agc_last_call
#define AGcThreshold Yap_heap_regs->agc_threshold
#define AGCHook Yap_heap_regs->agc_hook
#define ParserErrorStyle Yap_heap_regs->parser_error_style
#if defined(YAPOR) || defined(THREADS)
#define SignalLock Yap_heap_regs->wl[worker_id].signal_lock
#define WPP Yap_heap_regs->wl[worker_id].wpp
@ -486,6 +295,14 @@ extern struct various_codes *Yap_heap_regs;
#define XDiff RINFO.x_diff
#define DelayDiff RINFO.delay_diff
#define BaseDiff RINFO.base_diff
#define ReductionsCounter Yap_heap_regs->WL.call_counters.reductions
#define PredEntriesCounter Yap_heap_regs->WL.call_counters.reductions_retries
#define RetriesCounter Yap_heap_regs->WL.call_counters.retries
#define ReductionsCounterOn Yap_heap_regs->WL.call_counters.reductions_on
#define PredEntriesCounterOn Yap_heap_regs->WL.call_counters.reductions_retries_on
#define RetriesCounterOn Yap_heap_regs->WL.call_counters.retries_on
#define Yap_InterruptsDisabled Yap_heap_regs->WL.interrupts_disabled
/* current consult stack */
#define ConsultSp Yap_heap_regs->WL.consultsp
@ -533,38 +350,10 @@ extern struct various_codes *Yap_heap_regs;
#define GlobalArenaOverflows Yap_heap_regs->WL.global_arena_overflows
#define Yap_AllowRestart Yap_heap_regs->WL.allow_restart
#define GlobalDelayArena Yap_heap_regs->WL.global_delay_arena
#define ForeignCodeBase Yap_heap_regs->foreign_code_base;
#define ForeignCodeTop Yap_heap_regs->foreign_code_top;
#define ForeignCodeMax Yap_heap_regs->foreign_code_max;
#define ForeignCodeLoaded Yap_heap_regs->foreign_code_loaded
#define PredHashInitialSize 1039L
#define PredHashIncrement 7919L
#define ParserErrorStyle Yap_heap_regs->parser_error_style
#define GlobalHoldEntry Yap_heap_regs->global_hold_entry
#define DeadStaticClauses Yap_heap_regs->dead_static_clauses
#define DeadMegaClauses Yap_heap_regs->dead_mega_clauses
#define DeadStaticIndices Yap_heap_regs->dead_static_indices
#define Yap_AllowLocalExpansion Yap_heap_regs->allow_local_expansion
#define Yap_AllowGlobalExpansion Yap_heap_regs->allow_global_expansion
#define Yap_AllowTrailExpansion Yap_heap_regs->allow_trail_expansion
#define SizeOfOverflow Yap_heap_regs->size_of_overflow
#define LastWtimePtr Yap_heap_regs->last_wtime
#define BGL Yap_heap_regs->bgl
#define FreeBlocks Yap_heap_regs->free_blocks
#if defined(YAPOR) || defined(THREADS)
#define FreeBlocksLock Yap_heap_regs->free_blocks_lock
#define HeapTopLock Yap_heap_regs->heap_top_lock
#define HeapTopOwner Yap_heap_regs->heap_top_owner
#define NOfThreads Yap_heap_regs->n_of_threads
#define NOfThreadsCreated Yap_heap_regs->n_of_threads_created
#define ThreadsTotalTime Yap_heap_regs->threads_total_time
#define DeadStaticClausesLock Yap_heap_regs->dead_static_clauses_lock
#define DeadMegaClausesLock Yap_heap_regs->dead_mega_clauses_lock
#define DeadStaticIndicesLock Yap_heap_regs->dead_static_indices_lock
#define ModulesLock Yap_heap_regs->modules_lock
#endif
#if defined(YAPOR) || defined(TABLING)
#define GLOBAL Yap_heap_regs->global
#define REMOTE Yap_heap_regs->remote
@ -578,10 +367,6 @@ extern struct various_codes *Yap_heap_regs;
/* initially allow for files with up to 1024 predicates. This number
is extended whenever needed */
#define InitialConsultCapacity 1024
#if HAVE_LIBREADLINE
#define ReadlineBuf Yap_heap_regs->readline_buf
#define ReadlinePos Yap_heap_regs->readline_pos
#endif
#if (defined(USE_SYSTEM_MALLOC) && HAVE_MALLINFO)||USE_DL_MALLOC

View File

@ -22,6 +22,66 @@
#if defined(YAPOR) || defined(THREADS)
#define NOfThreads Yap_heap_regs->n_of_threads
#define NOfThreadsCreated Yap_heap_regs->n_of_threads_created
#define ThreadsTotalTime Yap_heap_regs->threads_total_time
#define BGL Yap_heap_regs->bgl
#define WorkerLocal Yap_heap_regs->wl
#ifndef WL
#define WL wl[worker_id]
#endif
#else
#define WorkerLocak Yap_heap_regs->wl
#ifndef WL
#define WL wl
#endif
#endif
#ifdef THREADS
#define ThreadHandlesLock Yap_heap_regs->thread_handles_lock
#define ThreadHandle Yap_heap_regs->thread_handle
#endif
#define Yap_HoleSize Yap_heap_regs->hole_size
#define Yap_av Yap_heap_regs->av_
#if USE_DL_MALLOC
#define Yap_MemoryHoles Yap_heap_regs->memory_holes
#define Yap_NOfMemoryHoles Yap_heap_regs->nof_memory_holes
#endif
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
#ifndef HeapUsed
#define HeapUsed Yap_givemallinfo()
#endif
#define NotHeapUsed Yap_heap_regs->heap_used
#else
#define HeapUsed Yap_heap_regs->heap_used
#endif
#define HeapMax Yap_heap_regs->heap_max
#define HeapTop Yap_heap_regs->heap_top
#define HeapLim Yap_heap_regs->heap_lim
#define FreeBlocks Yap_heap_regs->free_blocks
#if defined(YAPOR) || defined(THREADS)
#define FreeBlocksLock Yap_heap_regs->free_blocks_lock
#define HeapUsedLock Yap_heap_regs->heap_used_lock
#define HeapTopLock Yap_heap_regs->heap_top_lock
#define HeapTopOwner Yap_heap_regs->heap_top_owner
#endif
#define NOfAtoms Yap_heap_regs->n_of_atoms
#define AtomHashTableSize Yap_heap_regs->atom_hash_table_size
#define WideAtomHashTableSize Yap_heap_regs->wide_atom_hash_table_size
#define NOfWideAtoms Yap_heap_regs->n_of_wide_atoms
#define INVISIBLECHAIN Yap_heap_regs->invisiblechain
#define WideHashChain Yap_heap_regs->wide_hash_chain
#define HashChain Yap_heap_regs->hash_chain
#ifdef EUROTRA
@ -75,7 +135,6 @@
#define PredFail Yap_heap_regs->pred_fail
#define PredTrue Yap_heap_regs->pred_true
#ifdef COROUTINING
#define NUM_OF_ATTS Yap_heap_regs->num_of_atts
#define WakeUpCode Yap_heap_regs->wake_up_code
#endif
#define PredGoalExpansion Yap_heap_regs->pred_goal_expansion
@ -89,6 +148,10 @@
#define PredThrow Yap_heap_regs->pred_throw
#define PredHandleThrow Yap_heap_regs->pred_handle_throw
#define PredIs Yap_heap_regs->pred_is
#ifdef YAPOR
#define PredGetwork Yap_heap_regs->pred_getwork
#define PredGetworkSeq Yap_heap_regs->pred_getwork_seq
#endif /* YAPOR */
#ifdef LOW_LEVEL_TRACER
#define Yap_do_low_level_trace Yap_heap_regs->yap_do_low_level_trace
@ -190,3 +253,77 @@
#define DBErasedMarker Yap_heap_regs->db_erased_marker
#define LogDBErasedMarker Yap_heap_regs->logdb_erased_marker
#define DeadStaticClauses Yap_heap_regs->dead_static_clauses
#define DeadMegaClauses Yap_heap_regs->dead_mega_clauses
#define DeadStaticIndices Yap_heap_regs->dead_static_indices
#define DBErasedList Yap_heap_regs->db_erased_list
#define DBErasedIList Yap_heap_regs->db_erased_ilist
#if defined(YAPOR) || defined(THREADS)
#define DeadStaticClausesLock Yap_heap_regs->dead_static_clauses_lock
#define DeadMegaClausesLock Yap_heap_regs->dead_mega_clauses_lock
#define DeadStaticIndicesLock Yap_heap_regs->dead_static_indices_lock
#endif
#ifdef COROUTINING
#define NUM_OF_ATTS Yap_heap_regs->num_of_atts
#define Yap_AttsSize Yap_heap_regs->atts_size
#endif
#define Yap_AllowLocalExpansion Yap_heap_regs->allow_local_expansion
#define Yap_AllowGlobalExpansion Yap_heap_regs->allow_global_expansion
#define Yap_AllowTrailExpansion Yap_heap_regs->allow_trail_expansion
#define SizeOfOverflow Yap_heap_regs->size_of_overflow
#define GlobalHoldEntry Yap_heap_regs->global_hold_entry
#define AGcLastCall Yap_heap_regs->agc_last_call
#define AGcThreshold Yap_heap_regs->agc_threshold
#define AGCHook Yap_heap_regs->agc_hook
#define yap_flags Yap_heap_regs->yap_flags_field
#define OpList Yap_heap_regs->op_list
#define Stream Yap_heap_regs->yap_streams
#define NOfFileAliases Yap_heap_regs->n_of_file_aliases
#define SzOfFileAliases Yap_heap_regs->sz_of_file_aliases
#define FileAliases Yap_heap_regs->file_aliases
#define AtPrompt Yap_heap_regs->atprompt
#define Prompt Yap_heap_regs->prompt
#if HAVE_LIBREADLINE
#define ReadlineBuf Yap_heap_regs->readline_buf
#define ReadlinePos Yap_heap_regs->readline_pos
#endif
#define CharConversionTable Yap_heap_regs->char_conversion_table
#define CharConversionTable2 Yap_heap_regs->char_conversion_table2
#define max_depth Yap_heap_regs->maxdepth
#define max_list Yap_heap_regs->axlist
#define max_write_args Yap_heap_regs->maxwriteargs
#define ParserErrorStyle Yap_heap_regs->parser_error_style
#define Yap_LibDir Yap_heap_regs->yap_lib_dir
#define LastWtimePtr Yap_heap_regs->last_wtime
#define output_msg Yap_heap_regs->debugger_output_msg
#if LOW_PROF
#define ProfilerOn Yap_heap_regs->profiler_on
#define Yap_OffLineProfiler Yap_heap_regs->offline_profiler
#define FProf Yap_heap_regs->f_prof
#define FPreds Yap_heap_regs->f_preds
#define ProfPreds Yap_heap_regs->prof_preds
#endif /* LOW_PROF */
#define ForeignCodeLoaded Yap_heap_regs->foreign_code_loaded
#define ForeignCodeBase Yap_heap_regs->foreign_code_base
#define ForeignCodeTop Yap_heap_regs->foreign_code_top
#define ForeignCodeMax Yap_heap_regs->foreign_code_max

View File

@ -24,6 +24,66 @@
#if defined(YAPOR) || defined(THREADS)
UInt n_of_threads;
UInt n_of_threads_created;
UInt threads_total_time;
lockvar bgl;
worker_local wl[MAX_AGENTS];
#ifndef WL
#define WL wl[worker_id]
#endif
#else
worker_local wl;
#ifndef WL
#define WL wl
#endif
#endif
#ifdef THREADS
lockvar thread_handles_lock;
struct thandle thread_handle[MAX_THREADS];
#endif
UInt hole_size;
struct malloc_state *av_;
#if USE_DL_MALLOC
struct memory_hole memory_holes[MAX_DLMALLOC_HOLES];
UInt nof_memory_holes;
#endif
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
#ifndef HeapUsed
#define HeapUsed Yap_givemallinfo()
#endif
Int heap_used;
#else
Int heap_used;
#endif
Int heap_max;
ADDR heap_top;
ADDR heap_lim;
struct FREEB *free_blocks;
#if defined(YAPOR) || defined(THREADS)
lockvar free_blocks_lock;
lockvar heap_used_lock;
lockvar heap_top_lock;
int heap_top_owner;
#endif
UInt n_of_atoms;
UInt atom_hash_table_size;
UInt wide_atom_hash_table_size;
UInt n_of_wide_atoms;
AtomHashEntry invisiblechain;
AtomHashEntry *wide_hash_chain;
AtomHashEntry *hash_chain;
#include "tatoms.h"
#ifdef EUROTRA
Term term_dollar_u;
#endif
@ -75,7 +135,6 @@
struct pred_entry *pred_fail;
struct pred_entry *pred_true;
#ifdef COROUTINING
int num_of_atts;
struct pred_entry *wake_up_code;
#endif
struct pred_entry *pred_goal_expansion;
@ -89,6 +148,10 @@
struct pred_entry *pred_throw;
struct pred_entry *pred_handle_throw;
struct pred_entry *pred_is;
#ifdef YAPOR
struct pred_entry *pred_getwork;
struct pred_entry *pred_getwork_seq;
#endif /* YAPOR */
#ifdef LOW_LEVEL_TRACER
int yap_do_low_level_trace;
@ -190,3 +253,77 @@
struct DB_STRUCT *db_erased_marker;
struct logic_upd_clause *logdb_erased_marker;
struct static_clause *dead_static_clauses;
struct static_mega_clause *dead_mega_clauses;
struct static_index *dead_static_indices;
struct logic_upd_clause *db_erased_list;
struct logic_upd_index *db_erased_ilist;
#if defined(YAPOR) || defined(THREADS)
lockvar dead_static_clauses_lock;
lockvar dead_mega_clauses_lock;
lockvar dead_static_indices_lock;
#endif
#ifdef COROUTINING
int num_of_atts;
UInt atts_size;
#endif
int allow_local_expansion;
int allow_global_expansion;
int allow_trail_expansion;
UInt size_of_overflow;
struct hold_entry *global_hold_entry;
UInt agc_last_call;
UInt agc_threshold;
Agc_hook agc_hook;
Int yap_flags_field[NUMBER_OF_YAP_FLAGS];
struct operator_entry *op_list;
struct stream_desc *yap_streams;
UInt n_of_file_aliases;
UInt sz_of_file_aliases;
struct AliasDescS *file_aliases;
Atom atprompt;
char prompt[MAX_PROMPT];
#if HAVE_LIBREADLINE
char *readline_buf;
char *readline_pos;
#endif
char *char_conversion_table;
char *char_conversion_table2;
UInt maxdepth;
UInt axlist;
UInt maxwriteargs;
int parser_error_style;
char *yap_lib_dir;
void *last_wtime;
int debugger_output_msg;
#if LOW_PROF
int profiler_on;
int offline_profiler;
FILE *f_prof;
FILE *f_preds;
UInt prof_preds;
#endif /* LOW_PROF */
void *foreign_code_loaded;
ADDR foreign_code_base;
ADDR foreign_code_top;
ADDR foreign_code_max;

View File

@ -24,6 +24,66 @@
#if defined(YAPOR) || defined(THREADS)
Yap_heap_regs->n_of_threads = 1;
Yap_heap_regs->n_of_threads_created = 1;
Yap_heap_regs->threads_total_time = 0L;
INIT_LOCK(Yap_heap_regs->bgl);
#ifndef WL
#define WL wl[worker_id]
#endif
#else
#ifndef WL
#define WL wl
#endif
#endif
#ifdef THREADS
INIT_LOCK(Yap_heap_regs->thread_handles_lock);
InitThreadHandles;
#endif
#if USE_DL_MALLOC
#endif
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
#ifndef HeapUsed
#define HeapUsed Yap_givemallinfo()
#endif
#else
#endif
#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;
#endif
InitInvisibleAtoms();
InitWideAtoms();
InitAtoms();
#include "iatoms.h"
#ifdef EUROTRA
Yap_heap_regs->term_dollar_u = MkAtomTerm(AtomDollarU);
#endif
@ -66,7 +126,7 @@
#if defined(YAPOR) || defined(THREADS)
#endif
Yap_heap_regs->preds_in_hash_table = 0;
Yap_heap_regs->creep_code = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomCreep,1),PROLOG_MODULE));
@ -75,7 +135,6 @@
Yap_heap_regs->pred_fail = RepPredProp(PredPropByAtom(AtomFail,PROLOG_MODULE));
Yap_heap_regs->pred_true = RepPredProp(PredPropByAtom(AtomTrue,PROLOG_MODULE));
#ifdef COROUTINING
Yap_heap_regs->num_of_atts = 1;
Yap_heap_regs->wake_up_code = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomWakeUpGoal,2),PROLOG_MODULE));
#endif
Yap_heap_regs->pred_goal_expansion = RepPredProp(PredPropByFunc(FunctorGoalExpansion,USER_MODULE));
@ -89,6 +148,10 @@
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));
#ifdef YAPOR
Yap_heap_regs->pred_getwork = RepPredProp(PredPropByAtom(AtomGetwork,PROLOG_MODULE));
Yap_heap_regs->pred_getwork_seq = RepPredProp(PredPropByAtom(AtomGetworkSeq,PROLOG_MODULE));
#endif /* YAPOR */
#ifdef LOW_LEVEL_TRACER
Yap_heap_regs->yap_do_low_level_trace = FALSE;
@ -115,21 +178,21 @@
InitEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail);
InitOtaplInst(RTRYCODE,_retry_and_mark);
InitOtaplInst(RTRYCODE,_retry_and_mark,PredFail);
#ifdef BEAM
Yap_heap_regs->beam_retry_code->opc = Yap_opcode(_beam_retry_code);
#endif /* BEAM */
#ifdef YAPOR
Yap_heap_regs->seq_def = TRUE;
InitOtaplInst(GETWORK,_getwork);
InitOtaplInst(GETWORK_SEQ,_getwork_seq);
InitOtaplInst(GETWORK,_getwork,PredGetwork);
InitOtaplInst(GETWORK_SEQ,_getwork_seq,PredGetworkSeq);
Yap_heap_regs->getwork_first_time->opc = Yap_opcode(_getwork_first_time);
#endif /* YAPOR */
#ifdef TABLING
InitOtaplInst(LOAD_ANSWER,_table_load_answer);
InitOtaplInst(LOAD_ANSWER,_table_load_answer,PredFail);
InitOtaplInst(TRY_ANSWER,_table_try_answer);
InitOtaplInst(ANSWER_RESOLUTION,_answer_resolution);
InitOtaplInst(COMPLETION,_table_completion);
InitOtaplInst(ANSWER_RESOLUTION,_answer_resolution,PredFail);
InitOtaplInst(COMPLETION,_table_completion,PredFail);
#endif /* TABLING */
@ -190,3 +253,77 @@
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;
#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);
#endif
#ifdef COROUTINING
Yap_heap_regs->num_of_atts = 1;
#endif
Yap_heap_regs->allow_local_expansion = TRUE;
Yap_heap_regs->allow_global_expansion = TRUE;
Yap_heap_regs->allow_trail_expansion = TRUE;
Yap_heap_regs->size_of_overflow = 0;
Yap_heap_regs->global_hold_entry = Yap_InitAtomHold();
Yap_heap_regs->agc_last_call = 0;
Yap_heap_regs->agc_threshold = 10000;
Yap_heap_regs->agc_hook = NULL;
InitFlags();
Yap_heap_regs->op_list = NULL;
Yap_heap_regs->yap_streams = NULL;
Yap_heap_regs->n_of_file_aliases = 0;
Yap_heap_regs->sz_of_file_aliases = 0;
Yap_heap_regs->file_aliases = NULL;
Yap_heap_regs->atprompt = AtomNil;
#if HAVE_LIBREADLINE
Yap_heap_regs->readline_buf = NULL;
Yap_heap_regs->readline_pos = 0L;
#endif
Yap_heap_regs->char_conversion_table = NULL;
Yap_heap_regs->char_conversion_table2 = NULL;
Yap_heap_regs->maxdepth = 0L;
Yap_heap_regs->axlist = 0L;
Yap_heap_regs->maxwriteargs = 0L;
Yap_heap_regs->parser_error_style = EXCEPTION_ON_PARSER_ERROR;
Yap_heap_regs->yap_lib_dir = NULL;
Yap_heap_regs->last_wtime = NULL;
Yap_heap_regs->debugger_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;
#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;

266
H/rheap.h
View File

@ -377,6 +377,47 @@ AdjustSwitchTable(op_numbers op, yamop *table, COUNT i)
}
}
STATIC_PROTO(void RestoreAtomList, (Atom));
STATIC_PROTO(void RestoreAtom, (AtomEntry *));
static void
RestoreAtoms(void)
{
AtomHashEntry *HashPtr;
register int i;
HashPtr = HashChain;
for (i = 0; i < AtomHashTableSize; ++i) {
HashPtr->Entry = AtomAdjust(HashPtr->Entry);
RestoreAtomList(HashPtr->Entry);
HashPtr++;
}
}
static void
RestoreWideAtoms(void)
{
AtomHashEntry *HashPtr;
register int i;
HashPtr = WideHashChain;
for (i = 0; i < WideAtomHashTableSize; ++i) {
HashPtr->Entry = AtomAdjust(HashPtr->Entry);
RestoreAtomList(HashPtr->Entry);
HashPtr++;
}
}
static void
RestoreInvisibleAtoms(void)
{
INVISIBLECHAIN.Entry = AtomAdjust(INVISIBLECHAIN.Entry);
RestoreAtomList(INVISIBLECHAIN.Entry);
RestoreAtom(RepAtom(AtomFoundVar));
RestoreAtom(RepAtom(AtomFreeTerm));
}
#include "rclause.h"
/* adjusts terms stored in the data base, when they have no variables */
@ -622,14 +663,14 @@ RestoreEnvInst(yamop start[2], yamop **instp, op_numbers opc, PredEntry *pred)
}
static void
RestoreOtaplInst(yamop start[1], OPCODE opc)
RestoreOtaplInst(yamop start[1], OPCODE opc, PredEntry *pe)
{
yamop *ipc = start;
/* this is a place holder, it should not really be used */
ipc->opc = Yap_opcode(opc);
ipc->u.Otapl.s = 0;
ipc->u.Otapl.p = PredFail;
ipc->u.Otapl.p = pe;
if (ipc->u.Otapl.d)
ipc->u.Otapl.d = PtoOpAdjust(ipc->u.Otapl.d);
#ifdef YAPOR
@ -768,6 +809,143 @@ RestoreLogDBErasedMarker(void)
INIT_CLREF_COUNT(Yap_heap_regs->logdb_erased_marker);
}
static void
RestoreDeadStaticClauses(void)
{
if (Yap_heap_regs->dead_static_clauses) {
StaticClause *sc = PtoStCAdjust(Yap_heap_regs->dead_static_clauses);
Yap_heap_regs->dead_static_clauses = sc;
while (sc) {
RestoreStaticClause(sc);
sc = sc->ClNext;
}
}
}
static void
RestoreDeadMegaClauses(void)
{
if (Yap_heap_regs->dead_mega_clauses) {
MegaClause *mc = (MegaClause *)AddrAdjust((ADDR)(Yap_heap_regs->dead_mega_clauses));
Yap_heap_regs->dead_mega_clauses = mc;
while (mc) {
RestoreMegaClause(mc);
mc = mc->ClNext;
}
}
}
static void
RestoreDeadStaticIndices(void)
{
if (Yap_heap_regs->dead_static_indices) {
StaticIndex *si = (StaticIndex *)AddrAdjust((ADDR)(Yap_heap_regs->dead_static_indices));
Yap_heap_regs->dead_static_indices = si;
while (si) {
CleanSIndex(si, FALSE);
si = si->SiblingIndex;
}
}
}
static void
RestoreDBErasedList(void)
{
if (Yap_heap_regs->db_erased_list) {
LogUpdClause *lcl = Yap_heap_regs->db_erased_list =
PtoLUCAdjust(Yap_heap_regs->db_erased_list);
while (lcl) {
RestoreLUClause(lcl, FALSE);
lcl = lcl->ClNext;
}
}
}
static void
RestoreDBErasedIList(void)
{
if (Yap_heap_regs->db_erased_ilist) {
LogUpdIndex *icl = Yap_heap_regs->db_erased_ilist =
LUIndexAdjust(Yap_heap_regs->db_erased_ilist);
while (icl) {
CleanLUIndex(icl, FALSE);
icl = icl->SiblingIndex;
}
}
}
static void
RestoreStreams(void)
{
if (Yap_heap_regs->yap_streams != NULL) {
int sno;
Yap_heap_regs->yap_streams =
(struct stream_desc *)AddrAdjust((ADDR)Yap_heap_regs->yap_streams);
for (sno = 0; sno < MaxStreams; ++sno) {
if (Stream[sno].status & Free_Stream_f)
continue;
if (Stream[sno].status & (Socket_Stream_f|Pipe_Stream_f|InMemory_Stream_f))
continue;
Stream[sno].u.file.user_name = AtomTermAdjust(Stream[sno].u.file.user_name);
Stream[sno].u.file.name = AtomAdjust(Stream[sno].u.file.name);
}
}
}
static void
RestoreAliases(void)
{
if (Yap_heap_regs->file_aliases != NULL) {
int i;
Yap_heap_regs->file_aliases =
(struct AliasDescS *)AddrAdjust((ADDR)Yap_heap_regs->file_aliases);
for (i = 0; i < NOfFileAliases; i++)
FileAliases[i].name = AtomAdjust(FileAliases[i].name);
}
}
static void
RestoreForeignCode(void)
{
ForeignObj *f_code;
if (!ForeignCodeLoaded)
return;
if (ForeignCodeLoaded != NULL)
ForeignCodeLoaded = (void *)AddrAdjust((ADDR)ForeignCodeLoaded);
f_code = ForeignCodeLoaded;
while (f_code != NULL) {
StringList objs, libs;
if (f_code->objs != NULL)
f_code->objs = (StringList)AddrAdjust((ADDR)f_code->objs);
objs = f_code->objs;
while (objs != NULL) {
if (objs->next != NULL)
objs->next = (StringList)AddrAdjust((ADDR)objs->next);
if (objs->s != NULL)
objs->s = (char *)AddrAdjust((ADDR)objs->s);
objs = objs->next;
}
if (f_code->libs != NULL)
f_code->libs = (StringList)AddrAdjust((ADDR)f_code->libs);
libs = f_code->libs;
while (libs != NULL) {
if (libs->next != NULL)
libs->next = (StringList)AddrAdjust((ADDR)libs->next);
if (libs->s != NULL)
libs->s = (char *)AddrAdjust((ADDR)libs->s);
libs = libs->next;
}
if (f_code->f != NULL)
f_code->f = (char *)AddrAdjust((ADDR)f_code->f);
if (f_code->next != NULL)
f_code->next = (ForeignObj *)AddrAdjust((ADDR)f_code->next);
f_code = f_code->next;
}
}
/* restore the failcodes */
static void
restore_codes(void)
@ -793,91 +971,7 @@ restore_codes(void)
}
}
#endif
if (Yap_heap_regs->atprompt != NIL) {
Yap_heap_regs->atprompt =
AtomAdjust(Yap_heap_regs->atprompt);
}
if (Yap_heap_regs->char_conversion_table) {
Yap_heap_regs->char_conversion_table = (char *)
AddrAdjust((ADDR)Yap_heap_regs->char_conversion_table);
}
if (Yap_heap_regs->char_conversion_table2) {
Yap_heap_regs->char_conversion_table2 = (char *)
AddrAdjust((ADDR)Yap_heap_regs->char_conversion_table2);
}
if (Yap_heap_regs->op_list) {
Yap_heap_regs->op_list = (struct operator_entry *)
AddrAdjust((ADDR)Yap_heap_regs->op_list);
}
if (Yap_heap_regs->dead_static_clauses) {
StaticClause *sc = PtoStCAdjust(Yap_heap_regs->dead_static_clauses);
Yap_heap_regs->dead_static_clauses = sc;
while (sc) {
RestoreStaticClause(sc);
sc = sc->ClNext;
}
}
if (Yap_heap_regs->dead_mega_clauses) {
MegaClause *mc = (MegaClause *)AddrAdjust((ADDR)(Yap_heap_regs->dead_mega_clauses));
Yap_heap_regs->dead_mega_clauses = mc;
while (mc) {
RestoreMegaClause(mc);
mc = mc->ClNext;
}
}
if (Yap_heap_regs->dead_static_indices) {
StaticIndex *si = (StaticIndex *)AddrAdjust((ADDR)(Yap_heap_regs->dead_static_indices));
Yap_heap_regs->dead_static_indices = si;
while (si) {
CleanSIndex(si, FALSE);
si = si->SiblingIndex;
}
}
if (Yap_heap_regs->db_erased_list) {
LogUpdClause *lcl = Yap_heap_regs->db_erased_list =
PtoLUCAdjust(Yap_heap_regs->db_erased_list);
while (lcl) {
RestoreLUClause(lcl, FALSE);
lcl = lcl->ClNext;
}
}
if (Yap_heap_regs->db_erased_ilist) {
LogUpdIndex *icl = Yap_heap_regs->db_erased_ilist =
LUIndexAdjust(Yap_heap_regs->db_erased_ilist);
while (icl) {
CleanLUIndex(icl, FALSE);
icl = icl->SiblingIndex;
}
}
#include "ratoms.h"
#include "rhstruct.h"
Yap_heap_regs->global_hold_entry = HoldEntryAdjust(Yap_heap_regs->global_hold_entry);
if (Yap_heap_regs->yap_streams != NULL) {
int sno;
Yap_heap_regs->yap_streams =
(struct stream_desc *)AddrAdjust((ADDR)Yap_heap_regs->yap_streams);
for (sno = 0; sno < MaxStreams; ++sno) {
if (Stream[sno].status & Free_Stream_f)
continue;
if (Stream[sno].status & (Socket_Stream_f|Pipe_Stream_f|InMemory_Stream_f))
continue;
Stream[sno].u.file.user_name = AtomTermAdjust(Stream[sno].u.file.user_name);
Stream[sno].u.file.name = AtomAdjust(Stream[sno].u.file.name);
}
}
if (Yap_heap_regs->file_aliases != NULL) {
int i;
Yap_heap_regs->file_aliases =
(struct AliasDescS *)AddrAdjust((ADDR)Yap_heap_regs->file_aliases);
for (i = 0; i < NOfFileAliases; i++)
FileAliases[i].name = AtomAdjust(FileAliases[i].name);
}
if (Yap_heap_regs->yap_lib_dir) {
Yap_heap_regs->yap_lib_dir =
(char *)AddrAdjust((ADDR)Yap_heap_regs->yap_lib_dir);
}
#if !defined(THREADS) && !defined(YAPOR)
if (Yap_heap_regs->wl.scratchpad.ptr) {
Yap_heap_regs->wl.scratchpad.ptr =

View File

@ -24,6 +24,66 @@
#if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_heap_regs->bgl);
#ifndef WL
#define WL wl[worker_id]
#endif
#else
#ifndef WL
#define WL wl
#endif
#endif
#ifdef THREADS
REINIT_LOCK(Yap_heap_regs->thread_handles_lock);
#endif
#if USE_DL_MALLOC
#endif
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
#ifndef HeapUsed
#define HeapUsed Yap_givemallinfo()
#endif
#else
#endif
#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);
#endif
RestoreInvisibleAtoms();
RestoreWideAtoms();
RestoreAtoms();
#include "ratoms.h"
#ifdef EUROTRA
Yap_heap_regs->term_dollar_u = AtomTermAdjust(Yap_heap_regs->term_dollar_u);
#endif
@ -75,7 +135,6 @@
Yap_heap_regs->pred_fail = PtoPredAdjust(Yap_heap_regs->pred_fail);
Yap_heap_regs->pred_true = PtoPredAdjust(Yap_heap_regs->pred_true);
#ifdef COROUTINING
Yap_heap_regs->wake_up_code = PtoPredAdjust(Yap_heap_regs->wake_up_code);
#endif
Yap_heap_regs->pred_goal_expansion = PtoPredAdjust(Yap_heap_regs->pred_goal_expansion);
@ -89,6 +148,10 @@
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);
#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);
#endif /* YAPOR */
#ifdef LOW_LEVEL_TRACER
@ -115,21 +178,21 @@
RestoreEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail);
RestoreOtaplInst(RTRYCODE,_retry_and_mark);
RestoreOtaplInst(RTRYCODE,_retry_and_mark,PredFail);
#ifdef BEAM
Yap_heap_regs->beam_retry_code->opc = Yap_opcode(_beam_retry_code);
#endif /* BEAM */
#ifdef YAPOR
RestoreOtaplInst(GETWORK,_getwork);
RestoreOtaplInst(GETWORK_SEQ,_getwork_seq);
RestoreOtaplInst(GETWORK,_getwork,PredGetwork);
RestoreOtaplInst(GETWORK_SEQ,_getwork_seq,PredGetworkSeq);
Yap_heap_regs->getwork_first_time->opc = Yap_opcode(_getwork_first_time);
#endif /* YAPOR */
#ifdef TABLING
RestoreOtaplInst(LOAD_ANSWER,_table_load_answer);
RestoreOtaplInst(TRY_ANSWER,_table_try_answer);
RestoreOtaplInst(ANSWER_RESOLUTION,_answer_resolution_seq);
RestoreOtaplInst(COMPLETION,_table_completion);
RestoreOtaplInst(TRY_ANSWER,_table_try_answer,PredFail);
RestoreOtaplInst(ANSWER_RESOLUTION,_answer_bresolution_seq,PredFail);
RestoreOtaplInst(COMPLETION,_table_completion,PredFail);
#endif /* TABLING */
@ -190,3 +253,77 @@
RestoreDBErasedMarker();
RestoreLogDBErasedMarker();
RestoreDeadStaticClauses();
RestoreDeadMegaClauses();
RestoreDeadStaticIndices();
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);
#endif
#ifdef COROUTINING
#endif
Yap_heap_regs->global_hold_entry = HoldEntryAdjust(Yap_heap_regs->global_hold_entry);
Yap_heap_regs->op_list = OpListAdjust(Yap_heap_regs->op_list);
RestoreStreams();
RestoreAliases();
Yap_heap_regs->atprompt = AtomAdjust(Yap_heap_regs->atprompt);
#if HAVE_LIBREADLINE
#endif
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);
Yap_heap_regs->yap_lib_dir = CodeCharPAdjust(Yap_heap_regs->yap_lib_dir);
Yap_heap_regs->last_wtime = CodeVoidPAdjust(Yap_heap_regs->last_wtime);
#if LOW_PROF
#endif /* LOW_PROF */
RestoreForeignCode();

View File

@ -582,6 +582,18 @@ inline EXTERN char * CodeCharPAdjust (char *);
inline EXTERN char *
CodeCharPAdjust (char * addr)
{
if (!addr)
return NULL;
return addr + HDiff;
}
inline EXTERN void * CodeVoidPAdjust (void *);
inline EXTERN void *
CodeVoidPAdjust (void * addr)
{
if (!addr)
return NULL;
return addr + HDiff;
}
@ -605,6 +617,16 @@ PtoOpAdjust (yamop * ptr)
return (yamop *) (CharP (ptr) + HDiff);
}
inline EXTERN struct operator_entry *OpListAdjust (struct operator_entry *);
inline EXTERN struct operator_entry *
OpListAdjust (struct operator_entry * ptr)
{
if (!ptr)
return ptr;
return (struct operator_entry *) (CharP (ptr) + HDiff);
}
inline EXTERN struct logic_upd_clause *PtoLUClauseAdjust (struct logic_upd_clause *);

View File

@ -24,6 +24,72 @@
// Init... sets up call to InitFunc
// Restore... sets up call to RestoreFunc
//
/* multi-thread/ORP support */
#if defined(YAPOR) || defined(THREADS)
/* number of threads and processes in system */
UInt n_of_threads NOfThreads =1 void
/* number of threads created since start */
UInt n_of_threads_created NOfThreadsCreated =1 void
/* total run time for dead threads */
UInt threads_total_time ThreadsTotalTime =0L void
/* protect long critical regions */
lockvar bgl BGL MkLock
/* worker local data */
worker_local wl[MAX_AGENTS] WorkerLocal void void
#ifndef WL
#define WL wl[worker_id]
#endif
#else
worker_local wl WorkerLocak void void
#ifndef WL
#define WL wl
#endif
#endif
#ifdef THREADS
lockvar thread_handles_lock ThreadHandlesLock MkLock
struct thandle thread_handle[MAX_THREADS] ThreadHandle InitThreadHandles void
#endif
/* memory management */
UInt hole_size Yap_HoleSize void void
struct malloc_state *av_ Yap_av void void
#if USE_DL_MALLOC
struct memory_hole memory_holes[MAX_DLMALLOC_HOLES] Yap_MemoryHoles void void
UInt nof_memory_holes Yap_NOfMemoryHoles void void
#endif
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
#ifndef HeapUsed
#define HeapUsed Yap_givemallinfo()
#endif
Int heap_used NotHeapUsed void void
#else
Int heap_used HeapUsed void void
#endif
Int heap_max HeapMax void void
ADDR heap_top HeapTop void void
ADDR heap_lim HeapLim void void
struct FREEB *free_blocks FreeBlocks void void
#if defined(YAPOR) || defined(THREADS)
lockvar free_blocks_lock FreeBlocksLock MkLock
lockvar heap_used_lock HeapUsedLock MkLock
lockvar heap_top_lock HeapTopLock MkLock
int heap_top_owner HeapTopOwner =-1 void
#endif
/* atom tables */
UInt n_of_atoms NOfAtoms void void
UInt atom_hash_table_size AtomHashTableSize void void
UInt wide_atom_hash_table_size WideAtomHashTableSize void void
UInt n_of_wide_atoms NOfWideAtoms void void
AtomHashEntry invisiblechain INVISIBLECHAIN InitInvisibleAtoms() RestoreInvisibleAtoms()
AtomHashEntry *wide_hash_chain WideHashChain InitWideAtoms() RestoreWideAtoms()
AtomHashEntry *hash_chain HashChain InitAtoms() RestoreAtoms()
/* use atom defs here */
ATOMS
#ifdef EUROTRA
Term term_dollar_u TermDollarU MkAT AtomDollarU
#endif
@ -71,7 +137,7 @@ struct pred_entry **pred_hash PredHash InitPredHash() RestorePredHash()
#if defined(YAPOR) || defined(THREADS)
rwlock_t pred_hash_rw_lock PredHashRWLock void
#endif
UInt preds_in_hash_table PredsInHashTable void
UInt preds_in_hash_table PredsInHashTable =0 void
UInt pred_hash_table_size PredHashTableSize void
@ -82,7 +148,6 @@ struct pred_entry *spy_code SpyCode MkPred AtomSpy 1 PROLOG_MODULE
struct pred_entry *pred_fail PredFail MkPred AtomFail 0 PROLOG_MODULE
struct pred_entry *pred_true PredTrue MkPred AtomTrue 0 PROLOG_MODULE
#ifdef COROUTINING
int num_of_atts NUM_OF_ATTS =1 void
struct pred_entry *wake_up_code WakeUpCode MkPred AtomWakeUpGoal 2 PROLOG_MODULE
#endif
struct pred_entry *pred_goal_expansion PredGoalExpansion MkPred FunctorGoalExpansion USER_MODULE
@ -96,6 +161,10 @@ struct pred_entry *pred_static_clause PredStaticClause MkPred FunctorDoStaticCla
struct pred_entry *pred_throw PredThrow MkPred FunctorThrow PROLOG_MODULE
struct pred_entry *pred_handle_throw PredHandleThrow MkPred FunctorHandleThrow PROLOG_MODULE
struct pred_entry *pred_is PredIs MkPred FunctorIs PROLOG_MODULE
#ifdef YAPOR
struct pred_entry *pred_getwork PredGetwork MkPred AtomGetwork 0 PROLOG_MODULE
struct pred_entry *pred_getwork_seq PredGetworkSeq MkPred AtomGetworkSeq 0 PROLOG_MODULE
#endif /* YAPOR */
/* low-level tracer */
#ifdef LOW_LEVEL_TRACER
@ -127,22 +196,22 @@ yamop *trustfailcode TRUSTFAILCODE void
yamop env_for_yescode[2] ENV_FOR_YESCODE InitEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail) RestoreEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail)
yamop *yescode YESCODE void
yamop rtrycode[1] RTRYCODE InitOtaplInst(RTRYCODE,_retry_and_mark) RestoreOtaplInst(RTRYCODE,_retry_and_mark)
yamop rtrycode[1] RTRYCODE InitOtaplInst(RTRYCODE,_retry_and_mark,PredFail) RestoreOtaplInst(RTRYCODE,_retry_and_mark,PredFail)
#ifdef BEAM
yamop beam_retry_code[1] BEAM_RETRY_CODE MkInstE _beam_retry_code
#endif /* BEAM */
#ifdef YAPOR
int seq_def SEQUENTIAL_IS_DEFAULT =TRUE void
yamop getwork_code[1] GETWORK InitOtaplInst(GETWORK,_getwork) RestoreOtaplInst(GETWORK,_getwork)
yamop getwork_seq_code[1] GETWORK_SEQ InitOtaplInst(GETWORK_SEQ,_getwork_seq) RestoreOtaplInst(GETWORK_SEQ,_getwork_seq)
yamop getwork_code[1] GETWORK InitOtaplInst(GETWORK,_getwork,PredGetwork) RestoreOtaplInst(GETWORK,_getwork,PredGetwork)
yamop getwork_seq_code[1] GETWORK_SEQ InitOtaplInst(GETWORK_SEQ,_getwork_seq,PredGetworkSeq) RestoreOtaplInst(GETWORK_SEQ,_getwork_seq,PredGetworkSeq)
yamop getwork_first_time[1] GETWORK_FIRST_TIME MkInstE _getwork_first_time
#endif /* YAPOR */
#ifdef TABLING
yamop table_load_answer_code[1] LOAD_ANSWER InitOtaplInst(LOAD_ANSWER,_table_load_answer) RestoreOtaplInst(LOAD_ANSWER,_table_load_answer)
yamop table_try_answer_code[1] TRY_ANSWER InitOtaplInst(TRY_ANSWER,_table_try_answer) RestoreOtaplInst(TRY_ANSWER,_table_try_answer)
yamop table_answer_resolution_code[1] ANSWER_RESOLUTION InitOtaplInst(ANSWER_RESOLUTION,_answer_resolution) RestoreOtaplInst(ANSWER_RESOLUTION,_answer_resolution_seq)
yamop table_completion_code[1] COMPLETION InitOtaplInst(COMPLETION,_table_completion) RestoreOtaplInst(COMPLETION,_table_completion)
yamop table_load_answer_code[1] LOAD_ANSWER InitOtaplInst(LOAD_ANSWER,_table_load_answer,PredFail) RestoreOtaplInst(LOAD_ANSWER,_table_load_answer)
yamop table_try_answer_code[1] TRY_ANSWER InitOtaplInst(TRY_ANSWER,_table_try_answer) RestoreOtaplInst(TRY_ANSWER,_table_try_answer,PredFail)
yamop table_answer_resolution_code[1] ANSWER_RESOLUTION InitOtaplInst(ANSWER_RESOLUTION,_answer_resolution,PredFail) RestoreOtaplInst(ANSWER_RESOLUTION,_answer_bresolution_seq,PredFail)
yamop table_completion_code[1] COMPLETION InitOtaplInst(COMPLETION,_table_completion,PredFail) RestoreOtaplInst(COMPLETION,_table_completion,PredFail)
#endif /* TABLING */
/* */
@ -216,3 +285,93 @@ int update_mode UPDATE_MODE =UPDATE_MODE_LOGICAL void
struct DB_STRUCT *db_erased_marker DBErasedMarker InitDBErasedMarker() RestoreDBErasedMarker()
struct logic_upd_clause *logdb_erased_marker LogDBErasedMarker InitLogDBErasedMarker() RestoreLogDBErasedMarker()
/* Dead clauses and IDB entries */
struct static_clause *dead_static_clauses DeadStaticClauses =NULL RestoreDeadStaticClauses()
struct static_mega_clause *dead_mega_clauses DeadMegaClauses =NULL RestoreDeadMegaClauses()
struct static_index *dead_static_indices DeadStaticIndices =NULL RestoreDeadStaticIndices()
struct logic_upd_clause *db_erased_list DBErasedList =NULL RestoreDBErasedList()
struct logic_upd_index *db_erased_ilist DBErasedIList =NULL RestoreDBErasedIList()
#if defined(YAPOR) || defined(THREADS)
lockvar dead_static_clauses_lock DeadStaticClausesLock MkLock
lockvar dead_mega_clauses_lock DeadMegaClausesLock MkLock
lockvar dead_static_indices_lock DeadStaticIndicesLock MkLock
#endif
#ifdef COROUTINING
/* number of attribute modules */
int num_of_atts NUM_OF_ATTS =1 void
/* initialised by memory allocator */
UInt atts_size Yap_AttsSize void void
#endif
/* stack overflow expansion/gc control */
int allow_local_expansion Yap_AllowLocalExpansion =TRUE void
int allow_global_expansion Yap_AllowGlobalExpansion =TRUE void
int allow_trail_expansion Yap_AllowTrailExpansion =TRUE void
UInt size_of_overflow SizeOfOverflow =0 void
struct hold_entry *global_hold_entry GlobalHoldEntry =Yap_InitAtomHold() HoldEntryAdjust
/* amount of space recovered in all garbage collections */
UInt agc_last_call AGcLastCall =0 void
/* amount of space recovered in all garbage collections */
UInt agc_threshold AGcThreshold =10000 void
Agc_hook agc_hook AGCHook =NULL void
/* YAP control flags */
Int yap_flags_field[NUMBER_OF_YAP_FLAGS] yap_flags InitFlags() void
/* Operators */
struct operator_entry *op_list OpList =NULL OpListAdjust
/* Input/Output */
/* stream array */
struct stream_desc *yap_streams Stream =NULL RestoreStreams()
/* stream aliases */
UInt n_of_file_aliases NOfFileAliases =0 void
UInt sz_of_file_aliases SzOfFileAliases =0 void
struct AliasDescS *file_aliases FileAliases =NULL RestoreAliases()
/* prompting */
Atom atprompt AtPrompt =AtomNil AtomAdjust
char prompt[MAX_PROMPT] Prompt void void
/* readline */
#if HAVE_LIBREADLINE
char *readline_buf ReadlineBuf =NULL void
char *readline_pos ReadlinePos =0L void
#endif
/* ISO char conversion: I will make no comments */
char *char_conversion_table CharConversionTable =NULL CodeCharPAdjust
char *char_conversion_table2 CharConversionTable2 =NULL CodeCharPAdjust
/* write depth */
UInt maxdepth max_depth =0L void
UInt axlist max_list =0L void
UInt maxwriteargs max_write_args =0L void
/* what to do when the parser gives an error: should be thread bound? */
int parser_error_style ParserErrorStyle =EXCEPTION_ON_PARSER_ERROR void
/* library location. */
char *yap_lib_dir Yap_LibDir =NULL CodeCharPAdjust
/* time */
void *last_wtime LastWtimePtr =NULL CodeVoidPAdjust
/* profiling */
int debugger_output_msg output_msg =0L void
#if LOW_PROF
int profiler_on ProfilerOn =FALSE void
int offline_profiler Yap_OffLineProfiler =FALSE void
FILE *f_prof FProf =NULL void
FILE *f_preds FPreds =NULL void
UInt prof_preds ProfPreds =0L void
#endif /* LOW_PROF */
/* foreign code loaded */
void *foreign_code_loaded ForeignCodeLoaded =NULL RestoreForeignCode()
ADDR foreign_code_base ForeignCodeBase =NULL void
ADDR foreign_code_top ForeignCodeTop =NULL void
ADDR foreign_code_max ForeignCodeMax =NULL void

View File

@ -28,6 +28,9 @@ gen_struct(Inp,"") :-
Inp = [0'/,0'*|_], !.
gen_struct(Inp, Out) :-
Inp = [0'#|_], !, Out = Inp. % '
gen_struct(Inp,Out) :-
Inp = "ATOMS", !,
Out = "#include \"tatoms.h\"".
gen_struct(Inp,Out) :-
split(Inp," ",["struct",Type, Field|_]), !,
append([" struct ",Type," ",Field,";"], Out).
@ -46,6 +49,9 @@ gen_dstruct(Inp,"") :-
Inp = [0'/,0'*|_], !.
gen_dstruct(Inp, Out) :-
Inp = [0'#|_], !, Out = Inp. % '
gen_dstruct(Inp,Out) :-
Inp = "ATOMS", !,
Out = "".
gen_dstruct(Inp,"") :-
split(Inp," ",["void","void"|_]), !.
gen_dstruct(Inp,Out) :-
@ -75,6 +81,9 @@ gen_hstruct(Inp,"") :-
Inp = [0'/,0'/|_], !.
gen_hstruct(Inp,"") :-
Inp = [0'/,0'*|_], !.
gen_hstruct(Inp,Out) :-
Inp = "ATOMS", !,
Out = "#include \"ratoms.h\"".
gen_hstruct(Inp, Out) :-
Inp = [0'#|_], !, Out = Inp. % '
gen_hstruct(Inp,Out) :-
@ -124,6 +133,9 @@ gen_init(Inp,"") :-
Inp = [0'/,0'/|_], !.
gen_init(Inp, Out) :-
Inp = [0'#|_], !, Out = Inp. % '
gen_init(Inp,Out) :-
Inp = "ATOMS", !,
Out = "#include \"iatoms.h\"".
gen_init(Inp,Out) :-
split(Inp," ",["struct"|Inp2]), !,
glue(Inp2, " ", Inp3),