various_codes includes all the head pointers to the code space. Try to
centralise everything in a single file (HEAPFIELDS) and generate them from a Prolog script (buildheap).
This commit is contained in:
parent
d373f23b50
commit
d3f969e1b1
5
C/agc.c
5
C/agc.c
@ -115,6 +115,8 @@ AtomAdjust(Atom a)
|
||||
|
||||
#define CharP(X) ((char *)(X))
|
||||
|
||||
#define REINIT_LOCK(P)
|
||||
#define REINIT_RWLOCK(P)
|
||||
#define OrArgAdjust(P)
|
||||
#define TabEntryAdjust(P)
|
||||
#define IntegerAdjust(D) (D)
|
||||
@ -129,6 +131,7 @@ AtomAdjust(Atom a)
|
||||
#define ModuleAdjust(P) (P)
|
||||
#define ExternalFunctionAdjust(P) (P)
|
||||
#define PredEntryAdjust(P) (P)
|
||||
#define ModEntryPtrAdjust(P) (P)
|
||||
#define AtomEntryAdjust(P) (P)
|
||||
#define GlobalEntryAdjust(P) (P)
|
||||
#define BlobTermAdjust(P) (P)
|
||||
@ -163,6 +166,8 @@ AtomAdjust(Atom a)
|
||||
#define PtoLUIndexAdjust(P) (P)
|
||||
#define PtoDBTLAdjust(P) (P)
|
||||
#define PtoPredAdjust(P) (P)
|
||||
#define PtoPtoPredAdjust(P) (P)
|
||||
#define OpRTableAdjust(P) (P)
|
||||
#define PropAdjust(P) (P)
|
||||
#define TrailAddrAdjust(P) (P)
|
||||
#define XAdjust(P) (P)
|
||||
|
190
C/init.c
190
C/init.c
@ -973,91 +973,70 @@ InitFlags(void)
|
||||
yap_flags[QUIET_MODE_FLAG] = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
InitPredHash(void)
|
||||
{
|
||||
UInt i;
|
||||
|
||||
PredHash = (PredEntry **)Yap_AllocAtomSpace(sizeof(PredEntry **) * PredHashInitialSize);
|
||||
PredHashTableSize = PredHashInitialSize;
|
||||
if (PredHash == NULL) {
|
||||
Yap_Error(FATAL_ERROR,MkIntTerm(0),"allocating initial predicate hash table");
|
||||
}
|
||||
for (i = 0; i < PredHashTableSize; ++i) {
|
||||
PredHash[i] = NULL;
|
||||
}
|
||||
INIT_RWLOCK(PredHashRWLock);
|
||||
}
|
||||
|
||||
static void
|
||||
InitEnvInst(yamop start[2], yamop **instp, op_numbers opc, PredEntry *pred)
|
||||
{
|
||||
yamop *ipc = start;
|
||||
|
||||
/* make it look like the instruction is preceeded by a call instruction */
|
||||
ipc->opc = Yap_opcode(_call);
|
||||
ipc->u.Osbpp.s = -Signed(RealEnvSize);
|
||||
ipc->u.Osbpp.bmap = NULL;
|
||||
ipc->u.Osbpp.p = pred;
|
||||
ipc->u.Osbpp.p0 = pred;
|
||||
ipc = NEXTOP(ipc, Osbpp);
|
||||
ipc->opc = Yap_opcode(opc);
|
||||
*instp = ipc;
|
||||
}
|
||||
|
||||
static void
|
||||
InitOtaplInst(yamop start[1], OPCODE opc)
|
||||
{
|
||||
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.d = NULL;
|
||||
#ifdef YAPOR
|
||||
INIT_YAMOP_LTT(ipc, 1);
|
||||
#endif /* YAPOR */
|
||||
#ifdef TABLING
|
||||
ipc->u.Otapl.te = NULL;
|
||||
#endif /* TABLING */
|
||||
}
|
||||
|
||||
static void
|
||||
InitCodes(void)
|
||||
{
|
||||
/* initialise invisible chain */
|
||||
Yap_heap_regs->execution_mode = INTERPRETED;
|
||||
Yap_heap_regs->invisiblechain.Entry = NIL;
|
||||
INIT_RWLOCK(Yap_heap_regs->invisiblechain.AERWLock);
|
||||
#include "iatoms.h"
|
||||
Yap_heap_regs->term_prolog = MkAtomTerm(AtomProlog);
|
||||
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->readutil_module = MkAtomTerm(AtomReadutil);
|
||||
Yap_heap_regs->hacks_module = MkAtomTerm(AtomYapHacks);
|
||||
Yap_heap_regs->globals_module = MkAtomTerm(AtomNb);
|
||||
Yap_heap_regs->arg_module = MkAtomTerm(AtomArg);
|
||||
Yap_heap_regs->swi_module = MkAtomTerm(AtomSwi);
|
||||
#include "ihstruct.h"
|
||||
Yap_InitModules();
|
||||
#ifdef BEAM
|
||||
Yap_heap_regs->beam_retry_code.opc = Yap_opcode(_retry_eam);
|
||||
#endif
|
||||
#ifdef YAPOR
|
||||
Yap_heap_regs->seq_def = TRUE;
|
||||
Yap_heap_regs->getwork_code.opc = Yap_opcode(_getwork);
|
||||
INIT_YAMOP_LTT(&(Yap_heap_regs->getwork_code), 0);
|
||||
Yap_heap_regs->getwork_seq_code.opc = Yap_opcode(_getwork_seq);
|
||||
INIT_YAMOP_LTT(&(Yap_heap_regs->getwork_seq_code), 0);
|
||||
Yap_heap_regs->getwork_first_time_code.opc = Yap_opcode(_getwork_first_time);
|
||||
#endif /* YAPOR */
|
||||
#ifdef TABLING
|
||||
Yap_heap_regs->table_load_answer_code.opc = Yap_opcode(_table_load_answer);
|
||||
Yap_heap_regs->table_try_answer_code.opc = Yap_opcode(_table_try_answer);
|
||||
Yap_heap_regs->table_completion_code.opc = Yap_opcode(_table_completion);
|
||||
Yap_heap_regs->table_answer_resolution_code.opc = Yap_opcode(_table_answer_resolution);
|
||||
#ifdef YAPOR
|
||||
INIT_YAMOP_LTT(&(Yap_heap_regs->table_load_answer_code), 0);
|
||||
INIT_YAMOP_LTT(&(Yap_heap_regs->table_try_answer_code), 0);
|
||||
INIT_YAMOP_LTT(&(Yap_heap_regs->table_completion_code), 0);
|
||||
INIT_YAMOP_LTT(&(Yap_heap_regs->table_answer_resolution_code), 0);
|
||||
#endif /* YAPOR */
|
||||
#endif /* TABLING */
|
||||
Yap_heap_regs->execute_cpred_op_code = Yap_opcode(_execute_cpred);
|
||||
Yap_heap_regs->expand_op_code = Yap_opcode(_expand_index);
|
||||
INIT_LOCK(Yap_heap_regs->expand_clauses_list_lock);
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
Yap_heap_regs->yap_do_low_level_trace = FALSE;
|
||||
INIT_LOCK(Yap_heap_regs->low_level_trace_lock);
|
||||
#endif
|
||||
Yap_heap_regs->expand_clauses_first = NULL;
|
||||
Yap_heap_regs->expand_clauses_last = NULL;
|
||||
Yap_heap_regs->expand_clauses = 0;
|
||||
Yap_heap_regs->failcode->opc = Yap_opcode(_op_fail);
|
||||
Yap_heap_regs->failcode_1 = Yap_opcode(_op_fail);
|
||||
Yap_heap_regs->failcode_2 = Yap_opcode(_op_fail);
|
||||
Yap_heap_regs->failcode_3 = Yap_opcode(_op_fail);
|
||||
Yap_heap_regs->failcode_4 = Yap_opcode(_op_fail);
|
||||
Yap_heap_regs->failcode_5 = Yap_opcode(_op_fail);
|
||||
Yap_heap_regs->failcode_6 = Yap_opcode(_op_fail);
|
||||
|
||||
Yap_heap_regs->env_for_trustfail_code.op = Yap_opcode(_call);
|
||||
Yap_heap_regs->env_for_trustfail_code.s = -Signed(RealEnvSize);
|
||||
Yap_heap_regs->env_for_trustfail_code.l2 = NULL;
|
||||
Yap_heap_regs->trustfailcode->opc = Yap_opcode(_trust_fail);
|
||||
|
||||
Yap_heap_regs->env_for_yes_code.op = Yap_opcode(_call);
|
||||
Yap_heap_regs->env_for_yes_code.s = -Signed(RealEnvSize);
|
||||
Yap_heap_regs->env_for_yes_code.l2 = NULL;
|
||||
Yap_heap_regs->yescode.opc = Yap_opcode(_Ystop);
|
||||
Yap_heap_regs->undef_op = Yap_opcode(_undef_p);
|
||||
Yap_heap_regs->index_op = Yap_opcode(_index_pred);
|
||||
Yap_heap_regs->lockpred_op = Yap_opcode(_lock_pred);
|
||||
Yap_heap_regs->fail_op = Yap_opcode(_op_fail);
|
||||
|
||||
Yap_heap_regs->nocode.opc = Yap_opcode(_Nstop);
|
||||
|
||||
Yap_heap_regs->rtrycode.opc = Yap_opcode(_retry_and_mark);
|
||||
Yap_heap_regs->rtrycode.u.Otapl.s = 0;
|
||||
Yap_heap_regs->rtrycode.u.Otapl.d = NIL;
|
||||
#ifdef YAPOR
|
||||
INIT_YAMOP_LTT(&(Yap_heap_regs->rtrycode), 1);
|
||||
#endif /* YAPOR */
|
||||
|
||||
|
||||
#ifdef THREADS
|
||||
INIT_LOCK(Yap_heap_regs->thread_handles_lock);
|
||||
{
|
||||
@ -1150,27 +1129,6 @@ 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->clausecode->arity = 0;
|
||||
Yap_heap_regs->clausecode->clause = NULL;
|
||||
Yap_heap_regs->clausecode->func = NIL;
|
||||
|
||||
{
|
||||
Atom at;
|
||||
PredEntry *pred;
|
||||
|
||||
at = AtomCreep;
|
||||
pred = RepPredProp(PredPropByFunc(Yap_MkFunctor(at, 1),PROLOG_MODULE));
|
||||
Yap_heap_regs->creep_code = pred;
|
||||
at = AtomUndefp;
|
||||
pred = RepPredProp(PredPropByFunc(Yap_MkFunctor(at, 1),PROLOG_MODULE));
|
||||
Yap_heap_regs->undef_code = pred;
|
||||
at = AtomSpy;
|
||||
pred = RepPredProp(PredPropByFunc(Yap_MkFunctor(at, 1),0));
|
||||
Yap_heap_regs->spy_code = pred;
|
||||
Yap_heap_regs->env_for_trustfail_code.p =
|
||||
Yap_heap_regs->env_for_trustfail_code.p0 =
|
||||
RepPredProp(PredPropByAtom(Yap_FullLookupAtom("fail"),PROLOG_MODULE));
|
||||
}
|
||||
#if DEBUG
|
||||
Yap_heap_regs->new_cps = 0;
|
||||
Yap_heap_regs->live_cps = 0;
|
||||
@ -1190,9 +1148,6 @@ InitCodes(void)
|
||||
Yap_heap_regs->maxwriteargs = 0;
|
||||
|
||||
Yap_heap_regs->atprompt = 0;
|
||||
#ifdef COROUTINING
|
||||
Yap_heap_regs->num_of_atts = 1; /* initially only coroutining is supported */
|
||||
#endif
|
||||
/* system boots in compile mode */
|
||||
Yap_heap_regs->static_predicates_marked = TRUE;
|
||||
/* use Quintus compatible atom_chars and number_chars, not ISO compatible */
|
||||
@ -1209,9 +1164,6 @@ InitCodes(void)
|
||||
don't initialise this here, this is initialised by Yap_InitModules!!!!
|
||||
Yap_heap_regs->no_of_modules = 1;
|
||||
*/
|
||||
#ifdef EUROTRA
|
||||
Yap_heap_regs->term_dollar_u = MkAtomTerm(AtomDollarU);
|
||||
#endif
|
||||
Yap_heap_regs->term_refound_var = MkAtomTerm(AtomRefoundVar);
|
||||
Yap_heap_regs->n_of_file_aliases = 0;
|
||||
Yap_heap_regs->file_aliases = NULL;
|
||||
@ -1233,23 +1185,6 @@ InitCodes(void)
|
||||
Yap_ReleaseAtom(AtomOfTerm(Yap_heap_regs->term_refound_var));
|
||||
/* make sure we have undefp defined */
|
||||
/* predicates can only be defined after this point */
|
||||
Yap_heap_regs->env_for_yes_code.p =
|
||||
Yap_heap_regs->env_for_yes_code.p0 =
|
||||
RepPredProp(PredPropByAtom(AtomTrue,0));
|
||||
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_goal_expansion = RepPredProp(PredPropByFunc(FunctorGoalExpansion,USER_MODULE));
|
||||
Yap_heap_regs->env_for_trustfail_code.p =
|
||||
Yap_heap_regs->env_for_trustfail_code.p0 =
|
||||
RepPredProp(PredPropByAtom(AtomFalse,PROLOG_MODULE));
|
||||
{
|
||||
/* make sure we know about the module predicate */
|
||||
PredEntry *modp = RepPredProp(PredPropByFunc(FunctorModule,PROLOG_MODULE));
|
||||
@ -1360,18 +1295,6 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
|
||||
Yap_InitMemory (Trail, Heap, Stack+Atts);
|
||||
#endif /* YAPOR */
|
||||
Yap_AttsSize = Atts;
|
||||
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;
|
||||
#if USE_THREADED_CODE
|
||||
Yap_heap_regs->op_rtable = NULL;
|
||||
#endif
|
||||
#if defined(YAPOR) || defined(TABLING)
|
||||
Yap_init_global(max_table_size, n_workers, sch_loop, delay_load);
|
||||
#endif /* YAPOR || TABLING */
|
||||
@ -1395,15 +1318,6 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
|
||||
INIT_RWLOCK(WideHashChain[i].AERWLock);
|
||||
WideHashChain[i].Entry = NIL;
|
||||
}
|
||||
PredHash = (PredEntry **)Yap_AllocAtomSpace(sizeof(PredEntry **) * PredHashInitialSize);
|
||||
PredHashTableSize = PredHashInitialSize;
|
||||
if (PredHash == NULL) {
|
||||
Yap_Error(FATAL_ERROR,MkIntTerm(0),"allocating initial predicate hash table");
|
||||
}
|
||||
for (i = 0; i < PredHashTableSize; ++i) {
|
||||
PredHash[i] = NULL;
|
||||
}
|
||||
INIT_RWLOCK(PredHashRWLock);
|
||||
NOfAtoms = 0;
|
||||
NOfWideAtoms = 0;
|
||||
PredsInHashTable = 0;
|
||||
|
2
C/save.c
2
C/save.c
@ -1285,7 +1285,7 @@ RestoreHashPreds(void)
|
||||
int malloced = FALSE;
|
||||
PredEntry **np;
|
||||
UInt i;
|
||||
PredEntry **oldp = PredHash = (PredEntry **)AddrAdjust((ADDR)PredHash);
|
||||
PredEntry **oldp = PredHash;
|
||||
|
||||
np = (PredEntry **) Yap_AllocAtomSpace(sizeof(PredEntry **)*size);
|
||||
if (!np) {
|
||||
|
242
H/YapHeap.h
242
H/YapHeap.h
@ -267,150 +267,8 @@ typedef struct various_codes {
|
||||
AtomHashEntry *hash_chain;
|
||||
#include "tatoms.h"
|
||||
|
||||
/* Well-Known Terms, mostly modules */
|
||||
#ifdef EUROTRA
|
||||
Term term_dollar_u;
|
||||
#endif
|
||||
Term term_prolog;
|
||||
Term term_refound_var;
|
||||
Term user_module;
|
||||
Term idb_module;
|
||||
Term attributes_module;
|
||||
Term charsio_module;
|
||||
Term terms_module;
|
||||
Term system_module;
|
||||
Term readutil_module;
|
||||
Term hacks_module;
|
||||
Term arg_module;
|
||||
Term globals_module;
|
||||
Term swi_module;
|
||||
|
||||
/* Module List */
|
||||
struct mod_entry *current_modules;
|
||||
|
||||
/* The Predicate Hash Table: fast access to predicates. */
|
||||
struct pred_entry **pred_hash;
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
rwlock_t pred_hash_rw_lock;
|
||||
#endif
|
||||
UInt preds_in_hash_table, pred_hash_table_size;
|
||||
|
||||
/* Well-Known Predicates */
|
||||
struct pred_entry *creep_code;
|
||||
struct pred_entry *undef_code;
|
||||
struct pred_entry *spy_code;
|
||||
#ifdef COROUTINING
|
||||
int num_of_atts; /* max. number of attributes we have for a variable */
|
||||
struct pred_entry *wake_up_code;
|
||||
#endif
|
||||
struct pred_entry *pred_goal_expansion;
|
||||
struct pred_entry *pred_meta_call;
|
||||
struct pred_entry *pred_dollar_catch;
|
||||
struct pred_entry *pred_recorded_with_key;
|
||||
struct pred_entry *pred_log_upd_clause;
|
||||
struct pred_entry *pred_log_upd_clause_erase;
|
||||
struct pred_entry *pred_log_upd_clause0;
|
||||
struct pred_entry *pred_static_clause;
|
||||
struct pred_entry *pred_throw;
|
||||
struct pred_entry *pred_handle_throw;
|
||||
struct pred_entry *pred_is;
|
||||
|
||||
/* execution info */
|
||||
/* OPCODE TABLE */
|
||||
#if USE_THREADED_CODE
|
||||
opentry *op_rtable;
|
||||
#endif
|
||||
|
||||
/* Anderson's JIT */
|
||||
yap_exec_mode execution_mode;
|
||||
|
||||
/* low-level tracer */
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
int yap_do_low_level_trace;
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
lockvar low_level_trace_lock;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* code management info */
|
||||
UInt clause_space, index_space_Tree, index_space_EXT, index_space_SW;
|
||||
UInt lu_clause_space, lu_index_space_Tree, lu_index_space_CP, lu_index_space_EXT, lu_index_space_SW;
|
||||
|
||||
/* popular opcodes */
|
||||
OPCODE execute_cpred_op_code;
|
||||
OPCODE expand_op_code;
|
||||
OPCODE undef_op;
|
||||
OPCODE index_op;
|
||||
OPCODE lockpred_op;
|
||||
OPCODE fail_op;
|
||||
|
||||
/* static code: may be shared by many predicate or may be used for meta-execution */
|
||||
yamop comma_code[5];
|
||||
yamop failcode[1];
|
||||
OPCODE failcode_1;
|
||||
OPCODE failcode_2;
|
||||
OPCODE failcode_3;
|
||||
OPCODE failcode_4;
|
||||
OPCODE failcode_5;
|
||||
OPCODE failcode_6;
|
||||
OPCODE dummycode[1];
|
||||
struct {
|
||||
OPCODE op;
|
||||
#ifdef YAPOR
|
||||
COUNT ltt;
|
||||
COUNT cut;
|
||||
COUNT seq;
|
||||
#endif /* YAPOR */
|
||||
COUNT s;
|
||||
CELL *l2;
|
||||
struct pred_entry *p;
|
||||
struct pred_entry *p0;
|
||||
} env_for_trustfail_code; /* sla */
|
||||
yamop trustfailcode[1];
|
||||
struct {
|
||||
OPCODE op;
|
||||
#ifdef YAPOR
|
||||
COUNT ltt;
|
||||
COUNT cut;
|
||||
COUNT seq;
|
||||
#endif /* YAPOR */
|
||||
COUNT s;
|
||||
CELL *l2;
|
||||
struct pred_entry *p;
|
||||
struct pred_entry *p0;
|
||||
} env_for_yes_code; /* sla */
|
||||
struct yami yescode;
|
||||
struct yami nocode;
|
||||
struct yami rtrycode;
|
||||
struct {
|
||||
OPREG arity;
|
||||
struct yami *clause;
|
||||
Functor func;
|
||||
} clausecode[1];
|
||||
/*
|
||||
PREG just before we enter $spy. We use that to find out the clause which
|
||||
was calling the debugged goal.
|
||||
*/
|
||||
yamop *debugger_p_before_spy;
|
||||
#ifdef BEAM
|
||||
yamop beam_retry_code;
|
||||
#endif /* BEAM */
|
||||
#ifdef YAPOR
|
||||
int seq_def;
|
||||
yamop getwork_code;
|
||||
yamop getwork_seq_code;
|
||||
yamop getwork_first_time_code;
|
||||
#endif /* YAPOR */
|
||||
#ifdef TABLING
|
||||
yamop table_load_answer_code;
|
||||
yamop table_try_answer_code;
|
||||
yamop table_answer_resolution_code;
|
||||
yamop table_completion_code;
|
||||
#endif /* TABLING */
|
||||
|
||||
/* support recorded_k */
|
||||
yamop *retry_recorded_k_code,
|
||||
*retry_c_recordedp_code;
|
||||
/* Terms multiply used */
|
||||
#include "hstruct.h"
|
||||
|
||||
/* compiler flags */
|
||||
int system_profiling;
|
||||
@ -486,7 +344,9 @@ typedef struct various_codes {
|
||||
UInt atts_size;
|
||||
|
||||
/* stack overflow expansion/gc control */
|
||||
int allow_local_expansion, allow_global_expansion, allow_trail_expansion;
|
||||
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 */
|
||||
@ -563,20 +423,7 @@ extern struct various_codes *Yap_heap_regs;
|
||||
|
||||
#define Yap_HoleSize Yap_heap_regs->hole_size
|
||||
#define Yap_av Yap_heap_regs->av_
|
||||
#if defined(LOW_LEVEL_TRACER)
|
||||
#define Yap_do_low_level_trace Yap_heap_regs->yap_do_low_level_trace
|
||||
#endif
|
||||
#define Yap_ExecutionMode Yap_heap_regs->execution_mode
|
||||
#define Yap_AttsSize Yap_heap_regs->atts_size
|
||||
#define Yap_ClauseSpace Yap_heap_regs->clause_space
|
||||
#define Yap_IndexSpace_Tree Yap_heap_regs->index_space_Tree
|
||||
#define Yap_IndexSpace_EXT Yap_heap_regs->index_space_EXT
|
||||
#define Yap_IndexSpace_SW Yap_heap_regs->index_space_SW
|
||||
#define Yap_LUClauseSpace Yap_heap_regs->lu_clause_space
|
||||
#define Yap_LUIndexSpace_Tree Yap_heap_regs->lu_index_space_Tree
|
||||
#define Yap_LUIndexSpace_CP Yap_heap_regs->lu_index_space_CP
|
||||
#define Yap_LUIndexSpace_EXT Yap_heap_regs->lu_index_space_EXT
|
||||
#define Yap_LUIndexSpace_SW Yap_heap_regs->lu_index_space_SW
|
||||
#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)
|
||||
@ -591,45 +438,17 @@ extern struct various_codes *Yap_heap_regs;
|
||||
#define HeapMax Yap_heap_regs->heap_max
|
||||
#define HeapTop Yap_heap_regs->heap_top
|
||||
#define HeapLim Yap_heap_regs->heap_lim
|
||||
#ifdef YAPOR
|
||||
#define SEQUENTIAL_IS_DEFAULT Yap_heap_regs->seq_def
|
||||
#define GETWORK (&(Yap_heap_regs->getwork_code))
|
||||
#define GETWORK_SEQ (&(Yap_heap_regs->getwork_seq_code))
|
||||
#define GETWORK_FIRST_TIME (&(Yap_heap_regs->getwork_first_time_code))
|
||||
#endif /* YAPOR */
|
||||
#ifdef BEAM
|
||||
#define BEAM_RETRY_CODE ((yamop *)&(Yap_heap_regs->beam_retry_code))
|
||||
#endif /* BEAM */
|
||||
#ifdef TABLING
|
||||
#define LOAD_ANSWER ((yamop *)&(Yap_heap_regs->table_load_answer_code))
|
||||
#define TRY_ANSWER ((yamop *)&(Yap_heap_regs->table_try_answer_code))
|
||||
#define ANSWER_RESOLUTION ((yamop *)&(Yap_heap_regs->table_answer_resolution_code))
|
||||
#define COMPLETION ((yamop *)&(Yap_heap_regs->table_completion_code))
|
||||
#endif /* TABLING */
|
||||
#define EXECUTE_CPRED_OP_CODE Yap_heap_regs->execute_cpred_op_code
|
||||
#define EXPAND_OP_CODE Yap_heap_regs->expand_op_code
|
||||
#define ExpandClausesFirst Yap_heap_regs->expand_clauses_first
|
||||
#define ExpandClausesLast Yap_heap_regs->expand_clauses_last
|
||||
#define ExpandClausesListLock Yap_heap_regs->expand_clauses_list_lock
|
||||
#define Yap_ExpandClauses Yap_heap_regs->expand_clauses
|
||||
#define OpListLock Yap_heap_regs->op_list_lock
|
||||
#define COMMA_CODE Yap_heap_regs->comma_code
|
||||
#define FAILCODE Yap_heap_regs->failcode
|
||||
#define TRUSTFAILCODE Yap_heap_regs->trustfailcode
|
||||
#define YESCODE (&Yap_heap_regs->yescode)
|
||||
#define NOCODE (&Yap_heap_regs->nocode)
|
||||
#define RTRYCODE (&Yap_heap_regs->rtrycode)
|
||||
#define DUMMYCODE Yap_heap_regs->dummycode
|
||||
#define CLAUSECODE Yap_heap_regs->clausecode
|
||||
#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
|
||||
#if USE_THREADED_CODE
|
||||
#define OP_RTABLE Yap_heap_regs->op_rtable
|
||||
#endif
|
||||
#define UdiControlBlocks Yap_heap_regs->udi_control_blocks
|
||||
#define PROFILING Yap_heap_regs->system_profiling
|
||||
#define CALL_COUNTING Yap_heap_regs->system_call_counting
|
||||
@ -637,15 +456,8 @@ extern struct various_codes *Yap_heap_regs;
|
||||
#define PRED_GOAL_EXPANSION_FUNC Yap_heap_regs->system_pred_goal_expansion_func
|
||||
#define PRED_GOAL_EXPANSION_ON Yap_heap_regs->system_pred_goal_expansion_on
|
||||
#define UPDATE_MODE Yap_heap_regs->update_mode
|
||||
#define RETRY_C_RECORDED_CODE Yap_heap_regs->retry_recorded_code
|
||||
#define RETRY_C_RECORDED_K_CODE Yap_heap_regs->retry_recorded_k_code
|
||||
#define RETRY_C_RECORDEDP_CODE Yap_heap_regs->retry_c_recordedp_code
|
||||
#define STATIC_PREDICATES_MARKED Yap_heap_regs->static_predicates_marked
|
||||
#define yap_flags Yap_heap_regs->yap_flags_field
|
||||
#define UNDEF_OPCODE Yap_heap_regs->undef_op
|
||||
#define INDEX_OPCODE Yap_heap_regs->index_op
|
||||
#define LOCKPRED_OPCODE Yap_heap_regs->lockpred_op
|
||||
#define FAIL_OPCODE Yap_heap_regs->fail_op
|
||||
#ifdef THREADS
|
||||
#define ThreadHandlesLock Yap_heap_regs->thread_handles_lock
|
||||
#define ThreadHandle Yap_heap_regs->thread_handle
|
||||
@ -666,35 +478,10 @@ extern struct various_codes *Yap_heap_regs;
|
||||
#define INT_BB_KEYS Yap_heap_regs->IntBBKeys
|
||||
#define CharConversionTable Yap_heap_regs->char_conversion_table
|
||||
#define CharConversionTable2 Yap_heap_regs->char_conversion_table2
|
||||
#define CurrentModules Yap_heap_regs->current_modules
|
||||
#define OpList Yap_heap_regs->op_list
|
||||
#define FloatFormat Yap_heap_regs->float_format
|
||||
#define TermDollarU Yap_heap_regs->term_dollar_u
|
||||
#define TermProlog Yap_heap_regs->term_prolog
|
||||
#define TermReFoundVar Yap_heap_regs->term_refound_var
|
||||
#define PROLOG_MODULE 0
|
||||
#define USER_MODULE Yap_heap_regs->user_module
|
||||
#define IDB_MODULE Yap_heap_regs->idb_module
|
||||
#define ATTRIBUTES_MODULE Yap_heap_regs->attributes_module
|
||||
#define CHARSIO_MODULE Yap_heap_regs->charsio_module
|
||||
#define TERMS_MODULE Yap_heap_regs->terms_module
|
||||
#define SYSTEM_MODULE Yap_heap_regs->system_module
|
||||
#define READUTIL_MODULE Yap_heap_regs->readutil_module
|
||||
#define HACKS_MODULE Yap_heap_regs->hacks_module
|
||||
#define GLOBALS_MODULE Yap_heap_regs->globals_module
|
||||
#define ARG_MODULE Yap_heap_regs->arg_module
|
||||
#define SWI_MODULE Yap_heap_regs->swi_module
|
||||
#define PredGoalExpansion Yap_heap_regs->pred_goal_expansion
|
||||
#define PredMetaCall Yap_heap_regs->pred_meta_call
|
||||
#define PredDollarCatch Yap_heap_regs->pred_dollar_catch
|
||||
#define PredRecordedWithKey Yap_heap_regs->pred_recorded_with_key
|
||||
#define PredLogUpdClause Yap_heap_regs->pred_log_upd_clause
|
||||
#define PredLogUpdClauseErase Yap_heap_regs->pred_log_upd_clause_erase
|
||||
#define PredLogUpdClause0 Yap_heap_regs->pred_log_upd_clause0
|
||||
#define PredStaticClause Yap_heap_regs->pred_static_clause
|
||||
#define PredThrow Yap_heap_regs->pred_throw
|
||||
#define PredHandleThrow Yap_heap_regs->pred_handle_throw
|
||||
#define PredIs Yap_heap_regs->pred_is
|
||||
#include "dhstruct.h"
|
||||
#define DBErasedMarker Yap_heap_regs->db_erased_marker
|
||||
#define LogDBErasedMarker Yap_heap_regs->logdb_erased_marker
|
||||
#define DBErasedList Yap_heap_regs->db_erased_list
|
||||
@ -723,9 +510,6 @@ extern struct various_codes *Yap_heap_regs;
|
||||
#define AGcThreshold Yap_heap_regs->agc_threshold
|
||||
#define AGCHook Yap_heap_regs->agc_hook
|
||||
#define ParserErrorStyle Yap_heap_regs->parser_error_style
|
||||
#ifdef COROUTINING
|
||||
#define WakeUpCode Yap_heap_regs->wake_up_code
|
||||
#endif
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
#define SignalLock Yap_heap_regs->wl[worker_id].signal_lock
|
||||
#define WPP Yap_heap_regs->wl[worker_id].wpp
|
||||
@ -832,17 +616,14 @@ extern struct various_codes *Yap_heap_regs;
|
||||
#define compile_arrays Yap_heap_regs->compiler_compile_arrays
|
||||
#define optimizer_on Yap_heap_regs->compiler_optimizer_on
|
||||
#define compile_mode Yap_heap_regs->compiler_compile_mode
|
||||
#define P_before_spy Yap_heap_regs->debugger_p_before_spy
|
||||
#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 PredHash Yap_heap_regs->pred_hash
|
||||
#define PredHashRWLock Yap_heap_regs->pred_hash_rw_lock
|
||||
#define PredsInHashTable Yap_heap_regs->preds_in_hash_table
|
||||
#define PredHashTableSize Yap_heap_regs->pred_hash_table_size
|
||||
|
||||
#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
|
||||
@ -869,9 +650,6 @@ extern struct various_codes *Yap_heap_regs;
|
||||
#define DeadStaticIndicesLock Yap_heap_regs->dead_static_indices_lock
|
||||
#define ModulesLock Yap_heap_regs->modules_lock
|
||||
#endif
|
||||
#define CreepCode Yap_heap_regs->creep_code
|
||||
#define UndefCode Yap_heap_regs->undef_code
|
||||
#define SpyCode Yap_heap_regs->spy_code
|
||||
#ifdef DEBUG
|
||||
#define Yap_NewCps Yap_heap_regs->new_cps
|
||||
#define Yap_LiveCps Yap_heap_regs->live_cps
|
||||
@ -888,10 +666,6 @@ extern struct various_codes *Yap_heap_regs;
|
||||
#define UPDATE_MODE_LOGICAL_ASSERT 2
|
||||
|
||||
|
||||
#ifdef COROUTINING
|
||||
#define NUM_OF_ATTS Yap_heap_regs->num_of_atts
|
||||
#endif
|
||||
|
||||
/* initially allow for files with up to 1024 predicates. This number
|
||||
is extended whenever needed */
|
||||
#define InitialConsultCapacity 1024
|
||||
|
141
H/dhstruct.h
Normal file
141
H/dhstruct.h
Normal file
@ -0,0 +1,141 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef EUROTRA
|
||||
#define TermDollarU Yap_heap_regs->term_dollar_u
|
||||
#endif
|
||||
#define TermProlog Yap_heap_regs->term_prolog
|
||||
#define TermReFoundVar Yap_heap_regs->term_refound_var
|
||||
#define USER_MODULE Yap_heap_regs->user_module
|
||||
#define IDB_MODULE Yap_heap_regs->idb_module
|
||||
#define ATTRIBUTES_MODULE Yap_heap_regs->attributes_module
|
||||
#define CHARSIO_MODULE Yap_heap_regs->charsio_module
|
||||
#define TERMS_MODULE Yap_heap_regs->terms_module
|
||||
#define SYSTEM_MODULE Yap_heap_regs->system_module
|
||||
#define READUTIL_MODULE Yap_heap_regs->readutil_module
|
||||
#define HACKS_MODULE Yap_heap_regs->hacks_module
|
||||
#define ARG_MODULE Yap_heap_regs->arg_module
|
||||
#define GLOBALS_MODULE Yap_heap_regs->globals_module
|
||||
#define SWI_MODULE Yap_heap_regs->swi_module
|
||||
|
||||
|
||||
|
||||
#define CurrentModules Yap_heap_regs->current_modules
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if USE_THREADED_CODE
|
||||
#define OP_RTABLE Yap_heap_regs->op_rtable
|
||||
#endif
|
||||
|
||||
#define Yap_ExecutionMode Yap_heap_regs->execution_mode
|
||||
|
||||
#define EXECUTE_CPRED_OP_CODE Yap_heap_regs->execute_cpred_op_code
|
||||
#define EXPAND_OP_CODE Yap_heap_regs->expand_op_code
|
||||
#define FAIL_OPCODE Yap_heap_regs->fail_op
|
||||
#define INDEX_OPCODE Yap_heap_regs->index_op
|
||||
#define LOCKPRED_OPCODE Yap_heap_regs->lockpred_op
|
||||
#define UNDEF_OPCODE Yap_heap_regs->undef_op
|
||||
|
||||
#define PredHash Yap_heap_regs->pred_hash
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
#define PredHashRWLock Yap_heap_regs->pred_hash_rw_lock
|
||||
#endif
|
||||
#define PredsInHashTable Yap_heap_regs->preds_in_hash_table
|
||||
#define PredHashTableSize Yap_heap_regs->pred_hash_table_size
|
||||
|
||||
#define CreepCode Yap_heap_regs->creep_code
|
||||
#define UndefCode Yap_heap_regs->undef_code
|
||||
#define SpyCode Yap_heap_regs->spy_code
|
||||
#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
|
||||
#define PredMetaCall Yap_heap_regs->pred_meta_call
|
||||
#define PredDollarCatch Yap_heap_regs->pred_dollar_catch
|
||||
#define PredRecordedWithKey Yap_heap_regs->pred_recorded_with_key
|
||||
#define PredLogUpdClause Yap_heap_regs->pred_log_upd_clause
|
||||
#define PredLogUpdClauseErase Yap_heap_regs->pred_log_upd_clause_erase
|
||||
#define PredLogUpdClause0 Yap_heap_regs->pred_log_upd_clause0
|
||||
#define PredStaticClause Yap_heap_regs->pred_static_clause
|
||||
#define PredThrow Yap_heap_regs->pred_throw
|
||||
#define PredHandleThrow Yap_heap_regs->pred_handle_throw
|
||||
#define PredIs Yap_heap_regs->pred_is
|
||||
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
#define Yap_do_low_level_trace Yap_heap_regs->yap_do_low_level_trace
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
#define Yap_low_level_trace_lock Yap_heap_regs->low_level_trace_lock
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define Yap_ClauseSpace Yap_heap_regs->clause_space
|
||||
#define Yap_IndexSpace_Tree Yap_heap_regs->index_space_Tree
|
||||
#define Yap_IndexSpace_EXT Yap_heap_regs->index_space_EXT
|
||||
#define Yap_IndexSpace_SW Yap_heap_regs->index_space_SW
|
||||
#define Yap_LUClauseSpace Yap_heap_regs->lu_clause_space
|
||||
#define Yap_LUIndexSpace_Tree Yap_heap_regs->lu_index_space_Tree
|
||||
#define Yap_LUIndexSpace_CP Yap_heap_regs->lu_index_space_CP
|
||||
#define Yap_LUIndexSpace_EXT Yap_heap_regs->lu_index_space_EXT
|
||||
#define Yap_LUIndexSpace_SW Yap_heap_regs->lu_index_space_SW
|
||||
|
||||
#define COMMA_CODE Yap_heap_regs->comma_code
|
||||
#define DUMMYCODE Yap_heap_regs->dummycode
|
||||
#define FAILCODE Yap_heap_regs->failcode
|
||||
#define NOCODE Yap_heap_regs->nocode
|
||||
#define ENV_FOR_TRUSTFAIL Yap_heap_regs->env_for_trustfail
|
||||
#define TRUSTFAILCODE Yap_heap_regs->trustfailcode
|
||||
#define ENV_FOR_YESCODE Yap_heap_regs->env_for_yescode
|
||||
#define YESCODE Yap_heap_regs->yescode
|
||||
#define RTRYCODE Yap_heap_regs->rtrycode
|
||||
#ifdef BEAM
|
||||
#define BEAM_RETRY_CODE Yap_heap_regs->beam_retry_code
|
||||
#endif /* BEAM */
|
||||
#ifdef YAPOR
|
||||
#define SEQUENTIAL_IS_DEFAULT Yap_heap_regs->seq_def
|
||||
#define GETWORK Yap_heap_regs->getwork_code
|
||||
#define GETWORK_SEQ Yap_heap_regs->getwork_seq_code
|
||||
#define GETWORK_FIRST_TIME Yap_heap_regs->getwork_first_time
|
||||
#endif /* YAPOR */
|
||||
#ifdef TABLING
|
||||
#define LOAD_ANSWER Yap_heap_regs->table_load_answer_code
|
||||
#define TRY_ANSWER Yap_heap_regs->table_try_answer_code
|
||||
#define ANSWER_RESOLUTION Yap_heap_regs->table_answer_resolution_code
|
||||
#define COMPLETION Yap_heap_regs->table_completion_code
|
||||
#endif /* TABLING */
|
||||
|
||||
|
||||
|
||||
|
||||
#define P_before_spy Yap_heap_regs->debugger_p_before_spy
|
||||
|
||||
#define RETRY_C_RECORDEDP_CODE Yap_heap_regs->retry_recordedp_code
|
||||
#define RETRY_C_RECORDED_K_CODE Yap_heap_regs->retry_recorded_k_code
|
141
H/hstruct.h
Normal file
141
H/hstruct.h
Normal file
@ -0,0 +1,141 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef EUROTRA
|
||||
Term term_dollar_u;
|
||||
#endif
|
||||
Term term_prolog;
|
||||
Term term_refound_var;
|
||||
Term user_module;
|
||||
Term idb_module;
|
||||
Term attributes_module;
|
||||
Term charsio_module;
|
||||
Term terms_module;
|
||||
Term system_module;
|
||||
Term readutil_module;
|
||||
Term hacks_module;
|
||||
Term arg_module;
|
||||
Term globals_module;
|
||||
Term swi_module;
|
||||
|
||||
|
||||
|
||||
struct mod_entry *current_modules;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if USE_THREADED_CODE
|
||||
opentry *op_rtable;
|
||||
#endif
|
||||
|
||||
yap_exec_mode execution_mode;
|
||||
|
||||
OPCODE execute_cpred_op_code;
|
||||
OPCODE expand_op_code;
|
||||
OPCODE fail_op;
|
||||
OPCODE index_op;
|
||||
OPCODE lockpred_op;
|
||||
OPCODE undef_op;
|
||||
|
||||
struct pred_entry **pred_hash;
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
rwlock_t pred_hash_rw_lock;
|
||||
#endif
|
||||
UInt preds_in_hash_table;
|
||||
UInt pred_hash_table_size;
|
||||
|
||||
struct pred_entry *creep_code;
|
||||
struct pred_entry *undef_code;
|
||||
struct pred_entry *spy_code;
|
||||
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;
|
||||
struct pred_entry *pred_meta_call;
|
||||
struct pred_entry *pred_dollar_catch;
|
||||
struct pred_entry *pred_recorded_with_key;
|
||||
struct pred_entry *pred_log_upd_clause;
|
||||
struct pred_entry *pred_log_upd_clause_erase;
|
||||
struct pred_entry *pred_log_upd_clause0;
|
||||
struct pred_entry *pred_static_clause;
|
||||
struct pred_entry *pred_throw;
|
||||
struct pred_entry *pred_handle_throw;
|
||||
struct pred_entry *pred_is;
|
||||
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
int yap_do_low_level_trace;
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
lockvar low_level_trace_lock;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
UInt clause_space;
|
||||
UInt index_space_Tree;
|
||||
UInt index_space_EXT;
|
||||
UInt index_space_SW;
|
||||
UInt lu_clause_space;
|
||||
UInt lu_index_space_Tree;
|
||||
UInt lu_index_space_CP;
|
||||
UInt lu_index_space_EXT;
|
||||
UInt lu_index_space_SW;
|
||||
|
||||
yamop comma_code[5];
|
||||
yamop dummycode[1];
|
||||
yamop failcode[1];
|
||||
yamop nocode[1];
|
||||
yamop env_for_trustfail[2];
|
||||
yamop *trustfailcode;
|
||||
yamop env_for_yescode[2];
|
||||
yamop *yescode;
|
||||
yamop rtrycode[1];
|
||||
#ifdef BEAM
|
||||
yamop beam_retry_code[1];
|
||||
#endif /* BEAM */
|
||||
#ifdef YAPOR
|
||||
int seq_def;
|
||||
yamop getwork_code[1];
|
||||
yamop getwork_seq_code[1];
|
||||
yamop getwork_first_time[1];
|
||||
#endif /* YAPOR */
|
||||
#ifdef TABLING
|
||||
yamop table_load_answer_code[1];
|
||||
yamop table_try_answer_code[1];
|
||||
yamop table_answer_resolution_code[1];
|
||||
yamop table_completion_code[1];
|
||||
#endif /* TABLING */
|
||||
|
||||
|
||||
|
||||
|
||||
yamop *debugger_p_before_spy;
|
||||
|
||||
yamop *retry_recordedp_code;
|
||||
yamop *retry_recorded_k_code;
|
141
H/ihstruct.h
Normal file
141
H/ihstruct.h
Normal file
@ -0,0 +1,141 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef EUROTRA
|
||||
Yap_heap_regs->term_dollar_u = 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->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->current_modules = NULL;
|
||||
|
||||
|
||||
Yap_InitModules();
|
||||
|
||||
|
||||
#if USE_THREADED_CODE
|
||||
|
||||
#endif
|
||||
|
||||
Yap_heap_regs->execution_mode = INTERPRETED;
|
||||
|
||||
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->undef_op = Yap_opcode(_undef_p);
|
||||
|
||||
InitPredHash();
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
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));
|
||||
#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));
|
||||
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));
|
||||
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
Yap_heap_regs->yap_do_low_level_trace = FALSE;
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
INIT_LOCK(Yap_heap_regs->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_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);
|
||||
InitEnvInst(ENV_FOR_TRUSTFAIL,&TRUSTFAILCODE,_trust_fail,PredFail);
|
||||
|
||||
InitEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail);
|
||||
|
||||
InitOtaplInst(RTRYCODE,_retry_and_mark);
|
||||
#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);
|
||||
Yap_heap_regs->getwork_first_time->opc = Yap_opcode(_getwork_first_time);
|
||||
#endif /* YAPOR */
|
||||
#ifdef TABLING
|
||||
InitOtaplInst(LOAD_ANSWER,_table_load_answer);
|
||||
InitOtaplInst(TRY_ANSWER,_table_try_answer);
|
||||
InitOtaplInst(ANSWER_RESOLUTION,_answer_resolution);
|
||||
InitOtaplInst(COMPLETION,_table_completion);
|
||||
#endif /* TABLING */
|
||||
|
||||
|
||||
|
||||
|
||||
Yap_heap_regs->debugger_p_before_spy = NULL;
|
||||
|
||||
Yap_heap_regs->retry_recordedp_code = NULL;
|
||||
Yap_heap_regs->retry_recorded_k_code = NULL;
|
166
H/rheap.h
166
H/rheap.h
@ -597,34 +597,54 @@ CleanSIndex(StaticIndex *idx, int recurse)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
RestorePredHash(void)
|
||||
{
|
||||
PredHash = PtoPtoPredAdjust(PredHash);
|
||||
if (PredHash == NULL) {
|
||||
Yap_Error(FATAL_ERROR,MkIntTerm(0),"restore should find predicate hash table");
|
||||
}
|
||||
REINIT_RWLOCK(PredHashRWLock);
|
||||
/* RestoreHashPreds() does most of the work */
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreEnvInst(yamop start[2], yamop **instp, op_numbers opc, PredEntry *pred)
|
||||
{
|
||||
yamop *ipc = start;
|
||||
|
||||
ipc->opc = Yap_opcode(_call);
|
||||
ipc->u.Osbpp.p = pred;
|
||||
ipc->u.Osbpp.p0 = pred;
|
||||
ipc = NEXTOP(ipc, Osbpp);
|
||||
ipc->opc = Yap_opcode(opc);
|
||||
*instp = ipc;
|
||||
}
|
||||
|
||||
static void
|
||||
RestoreOtaplInst(yamop start[1], OPCODE opc)
|
||||
{
|
||||
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;
|
||||
if (ipc->u.Otapl.d)
|
||||
ipc->u.Otapl.d = PtoOpAdjust(ipc->u.Otapl.d);
|
||||
#ifdef YAPOR
|
||||
INIT_YAMOP_LTT(ipc, 1);
|
||||
#endif /* YAPOR */
|
||||
#ifdef TABLING
|
||||
ipc->u.Otapl.te = NULL;
|
||||
#endif /* TABLING */
|
||||
}
|
||||
|
||||
/* restore the failcodes */
|
||||
static void
|
||||
restore_codes(void)
|
||||
{
|
||||
Yap_heap_regs->heap_top = AddrAdjust(OldHeapTop);
|
||||
#ifdef YAPOR
|
||||
/* ricroc: if in use overrides startup file settings
|
||||
Yap_heap_regs->seq_def = TRUE; */
|
||||
Yap_heap_regs->getwork_code.opc = Yap_opcode(_getwork);
|
||||
INIT_YAMOP_LTT(&(Yap_heap_regs->getwork_code), 0);
|
||||
Yap_heap_regs->getwork_seq_code.opc = Yap_opcode(_getwork_seq);
|
||||
INIT_YAMOP_LTT(&(Yap_heap_regs->getwork_seq_code), 0);
|
||||
Yap_heap_regs->getwork_first_time_code.opc = Yap_opcode(_getwork_first_time);
|
||||
#endif /* YAPOR */
|
||||
#ifdef TABLING
|
||||
Yap_heap_regs->table_load_answer_code.opc = Yap_opcode(_table_load_answer);
|
||||
Yap_heap_regs->table_try_answer_code.opc = Yap_opcode(_table_try_answer);
|
||||
Yap_heap_regs->table_answer_resolution_code.opc = Yap_opcode(_table_answer_resolution);
|
||||
Yap_heap_regs->table_completion_code.opc = Yap_opcode(_table_completion);
|
||||
#ifdef YAPOR
|
||||
INIT_YAMOP_LTT(&(Yap_heap_regs->table_load_answer_code), 0);
|
||||
INIT_YAMOP_LTT(&(Yap_heap_regs->table_try_answer_code), 0);
|
||||
INIT_YAMOP_LTT(&(Yap_heap_regs->table_completion_code), 0);
|
||||
INIT_YAMOP_LTT(&(Yap_heap_regs->table_answer_resolution_code), 0);
|
||||
#endif /* YAPOR */
|
||||
#endif /* TABLING */
|
||||
Yap_heap_regs->execute_cpred_op_code = Yap_opcode(_execute_cpred);
|
||||
Yap_heap_regs->expand_op_code = Yap_opcode(_expand_index);
|
||||
if (Yap_heap_regs->expand_clauses_first)
|
||||
Yap_heap_regs->expand_clauses_first = PtoOpAdjust(Yap_heap_regs->expand_clauses_first);
|
||||
if (Yap_heap_regs->expand_clauses_last)
|
||||
@ -636,47 +656,6 @@ restore_codes(void)
|
||||
ptr = ptr->u.sssllp.snext;
|
||||
}
|
||||
}
|
||||
Yap_heap_regs->failcode->opc = Yap_opcode(_op_fail);
|
||||
Yap_heap_regs->failcode_1 = Yap_opcode(_op_fail);
|
||||
Yap_heap_regs->failcode_2 = Yap_opcode(_op_fail);
|
||||
Yap_heap_regs->failcode_3 = Yap_opcode(_op_fail);
|
||||
Yap_heap_regs->failcode_4 = Yap_opcode(_op_fail);
|
||||
Yap_heap_regs->failcode_5 = Yap_opcode(_op_fail);
|
||||
Yap_heap_regs->failcode_6 = Yap_opcode(_op_fail);
|
||||
|
||||
Yap_heap_regs->env_for_trustfail_code.op = Yap_opcode(_call);
|
||||
Yap_heap_regs->trustfailcode->opc = Yap_opcode(_trust_fail);
|
||||
|
||||
Yap_heap_regs->env_for_yes_code.op = Yap_opcode(_call);
|
||||
Yap_heap_regs->yescode.opc = Yap_opcode(_Ystop);
|
||||
Yap_heap_regs->undef_op = Yap_opcode(_undef_p);
|
||||
Yap_heap_regs->index_op = Yap_opcode(_index_pred);
|
||||
Yap_heap_regs->lockpred_op = Yap_opcode(_lock_pred);
|
||||
Yap_heap_regs->fail_op = Yap_opcode(_op_fail);
|
||||
Yap_heap_regs->nocode.opc = Yap_opcode(_Nstop);
|
||||
Yap_heap_regs->rtrycode.opc = Yap_opcode(_retry_and_mark);
|
||||
#ifdef YAPOR
|
||||
INIT_YAMOP_LTT(&(Yap_heap_regs->nocode), 1);
|
||||
INIT_YAMOP_LTT(&(Yap_heap_regs->rtrycode), 1);
|
||||
#endif /* YAPOR */
|
||||
if (((yamop *)(&Yap_heap_regs->rtrycode))->u.Otapl.d != NIL)
|
||||
((yamop *)(&Yap_heap_regs->rtrycode))->u.Otapl.d =
|
||||
PtoOpAdjust(((yamop *)(&Yap_heap_regs->rtrycode))->u.Otapl.d);
|
||||
{
|
||||
int arity;
|
||||
arity = Yap_heap_regs->clausecode->arity;
|
||||
if (Yap_heap_regs->clausecode->clause != NIL)
|
||||
Yap_heap_regs->clausecode->clause =
|
||||
PtoOpAdjust(Yap_heap_regs->clausecode->clause);
|
||||
if (arity) {
|
||||
Yap_heap_regs->clausecode->func =
|
||||
FuncAdjust(Yap_heap_regs->clausecode->func);
|
||||
} else {
|
||||
/* an atom */
|
||||
Yap_heap_regs->clausecode->func =
|
||||
(Functor)AtomAdjust((Atom)(Yap_heap_regs->clausecode->func));
|
||||
}
|
||||
}
|
||||
#if !defined(THREADS) && !defined(YAPOR)
|
||||
/* restore consult stack. It consists of heap pointers, so it
|
||||
is easy to fix.
|
||||
@ -696,19 +675,11 @@ restore_codes(void)
|
||||
pt ++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if USE_THREADED_CODE
|
||||
Yap_heap_regs->op_rtable = (opentry *)
|
||||
CodeAddrAdjust((CODEADDR)(Yap_heap_regs->op_rtable));
|
||||
#endif
|
||||
if (Yap_heap_regs->atprompt != NIL) {
|
||||
Yap_heap_regs->atprompt =
|
||||
AtomAdjust(Yap_heap_regs->atprompt);
|
||||
}
|
||||
if (Yap_heap_regs->current_modules) {
|
||||
Yap_heap_regs->current_modules = (struct mod_entry *)
|
||||
AddrAdjust((ADDR)Yap_heap_regs->current_modules);
|
||||
}
|
||||
if (Yap_heap_regs->char_conversion_table) {
|
||||
Yap_heap_regs->char_conversion_table = (char *)
|
||||
AddrAdjust((ADDR)Yap_heap_regs->char_conversion_table);
|
||||
@ -753,10 +724,6 @@ restore_codes(void)
|
||||
si = si->SiblingIndex;
|
||||
}
|
||||
}
|
||||
Yap_heap_regs->retry_recorded_k_code =
|
||||
PtoOpAdjust(Yap_heap_regs->retry_recorded_k_code);
|
||||
Yap_heap_regs->retry_c_recordedp_code =
|
||||
PtoOpAdjust(Yap_heap_regs->retry_c_recordedp_code);
|
||||
if (Yap_heap_regs->IntKeys != NULL) {
|
||||
Yap_heap_regs->IntKeys = (Prop *)AddrAdjust((ADDR)(Yap_heap_regs->IntKeys));
|
||||
{
|
||||
@ -818,22 +785,7 @@ restore_codes(void)
|
||||
}
|
||||
}
|
||||
#include "ratoms.h"
|
||||
#ifdef EUROTRA
|
||||
Yap_heap_regs->term_dollar_u = AtomTermAdjust(Yap_heap_regs->term_dollar_u);
|
||||
#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->readutil_module = AtomTermAdjust(Yap_heap_regs->readutil_module);
|
||||
Yap_heap_regs->hacks_module = AtomTermAdjust(Yap_heap_regs->hacks_module);
|
||||
Yap_heap_regs->globals_module = AtomTermAdjust(Yap_heap_regs->globals_module);
|
||||
Yap_heap_regs->arg_module = AtomTermAdjust(Yap_heap_regs->arg_module);
|
||||
Yap_heap_regs->swi_module = AtomTermAdjust(Yap_heap_regs->swi_module);
|
||||
#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;
|
||||
@ -861,34 +813,6 @@ restore_codes(void)
|
||||
Yap_heap_regs->yap_lib_dir =
|
||||
(char *)AddrAdjust((ADDR)Yap_heap_regs->yap_lib_dir);
|
||||
}
|
||||
Yap_heap_regs->pred_goal_expansion =
|
||||
PredEntryAdjust(Yap_heap_regs->pred_goal_expansion);
|
||||
Yap_heap_regs->pred_meta_call =
|
||||
PredEntryAdjust(Yap_heap_regs->pred_meta_call);
|
||||
Yap_heap_regs->pred_dollar_catch =
|
||||
PredEntryAdjust(Yap_heap_regs->pred_dollar_catch);
|
||||
Yap_heap_regs->pred_recorded_with_key =
|
||||
PredEntryAdjust(Yap_heap_regs->pred_recorded_with_key);
|
||||
Yap_heap_regs->pred_log_upd_clause =
|
||||
PredEntryAdjust(Yap_heap_regs->pred_log_upd_clause);
|
||||
Yap_heap_regs->pred_log_upd_clause_erase =
|
||||
PredEntryAdjust(Yap_heap_regs->pred_log_upd_clause_erase);
|
||||
Yap_heap_regs->pred_log_upd_clause0 =
|
||||
PredEntryAdjust(Yap_heap_regs->pred_log_upd_clause0);
|
||||
Yap_heap_regs->pred_static_clause =
|
||||
PredEntryAdjust(Yap_heap_regs->pred_static_clause);
|
||||
Yap_heap_regs->pred_throw =
|
||||
PredEntryAdjust(Yap_heap_regs->pred_throw);
|
||||
Yap_heap_regs->pred_handle_throw =
|
||||
PredEntryAdjust(Yap_heap_regs->pred_handle_throw);
|
||||
Yap_heap_regs->pred_is =
|
||||
PredEntryAdjust(Yap_heap_regs->pred_is);
|
||||
if (Yap_heap_regs->undef_code != NULL)
|
||||
Yap_heap_regs->undef_code = (PredEntry *)PtoHeapCellAdjust((CELL *)(Yap_heap_regs->undef_code));
|
||||
if (Yap_heap_regs->creep_code != NULL)
|
||||
Yap_heap_regs->creep_code = (PredEntry *)PtoHeapCellAdjust((CELL *)(Yap_heap_regs->creep_code));
|
||||
if (Yap_heap_regs->spy_code != NULL)
|
||||
Yap_heap_regs->spy_code = (PredEntry *)PtoHeapCellAdjust((CELL *)(Yap_heap_regs->spy_code));
|
||||
#if !defined(THREADS) && !defined(YAPOR)
|
||||
if (Yap_heap_regs->wl.scratchpad.ptr) {
|
||||
Yap_heap_regs->wl.scratchpad.ptr =
|
||||
@ -901,8 +825,6 @@ restore_codes(void)
|
||||
/* current phase is an integer */
|
||||
#endif
|
||||
#ifdef COROUTINING
|
||||
if (Yap_heap_regs->wake_up_code != NULL)
|
||||
Yap_heap_regs->wake_up_code = (PredEntry *)PtoHeapCellAdjust((CELL *)(Yap_heap_regs->wake_up_code));
|
||||
#if !defined(THREADS) && !defined(YAPOR)
|
||||
Yap_heap_regs->wl.atts_mutable_list =
|
||||
AbsAppl(PtoGloAdjust(RepAppl(Yap_heap_regs->wl.atts_mutable_list)));
|
||||
|
141
H/rhstruct.h
Normal file
141
H/rhstruct.h
Normal file
@ -0,0 +1,141 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef EUROTRA
|
||||
Yap_heap_regs->term_dollar_u = AtomTermAdjust(Yap_heap_regs->term_dollar_u);
|
||||
#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->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->current_modules = ModEntryPtrAdjust(Yap_heap_regs->current_modules);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if USE_THREADED_CODE
|
||||
Yap_heap_regs->op_rtable = OpRTableAdjust(Yap_heap_regs->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->undef_op = Yap_opcode(_undef_p);
|
||||
|
||||
RestorePredHash();
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
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);
|
||||
#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);
|
||||
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);
|
||||
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
REINIT_LOCK(Yap_heap_regs->low_level_trace_lock);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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);
|
||||
RestoreEnvInst(ENV_FOR_TRUSTFAIL,&TRUSTFAILCODE,_trust_fail,PredFail);
|
||||
|
||||
RestoreEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail);
|
||||
|
||||
RestoreOtaplInst(RTRYCODE,_retry_and_mark);
|
||||
#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);
|
||||
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);
|
||||
#endif /* TABLING */
|
||||
|
||||
|
||||
|
||||
|
||||
Yap_heap_regs->debugger_p_before_spy = PtoOpAdjust(Yap_heap_regs->debugger_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);
|
36
H/sshift.h
36
H/sshift.h
@ -1,10 +1,3 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog %W% %G%
|
||||
@ -22,6 +15,9 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#define REINIT_LOCK(P) INIT_LOCK(P)
|
||||
#define REINIT_RWLOCK(P) INIT_RWLOCK(P)
|
||||
|
||||
|
||||
#define CharP(ptr) ((char *) (ptr))
|
||||
|
||||
@ -357,6 +353,14 @@ PredEntryAdjust (PredEntry *p)
|
||||
return (PredEntry *) ((p == NULL ? (p) : (PredEntry *) (CharP (p) + HDiff)));
|
||||
}
|
||||
|
||||
inline EXTERN struct mod_entry *ModEntryPtrAdjust (struct mod_entry *);
|
||||
|
||||
inline EXTERN struct mod_entry *
|
||||
ModEntryPtrAdjust (struct mod_entry *p)
|
||||
{
|
||||
return (struct mod_entry *) ((p == NULL ? (p) : (struct mod_entry *) (CharP (p) + HDiff)));
|
||||
}
|
||||
|
||||
inline EXTERN COUNT ConstantAdjust (COUNT);
|
||||
|
||||
inline EXTERN COUNT
|
||||
@ -638,6 +642,14 @@ PtoAtomHashEntryAdjust (AtomHashEntry * ptr)
|
||||
|
||||
|
||||
|
||||
inline EXTERN opentry *OpRTableAdjust (opentry *);
|
||||
|
||||
inline EXTERN opentry *
|
||||
OpRTableAdjust (opentry * ptr)
|
||||
{
|
||||
return (opentry *) (((opentry *) (CharP (ptr) + HDiff)));
|
||||
}
|
||||
|
||||
inline EXTERN PredEntry *PtoPredAdjust (PredEntry *);
|
||||
|
||||
inline EXTERN PredEntry *
|
||||
@ -646,6 +658,16 @@ PtoPredAdjust (PredEntry * ptr)
|
||||
return (PredEntry *) (((PredEntry *) (CharP (ptr) + HDiff)));
|
||||
}
|
||||
|
||||
inline EXTERN PredEntry **PtoPtoPredAdjust (PredEntry **);
|
||||
|
||||
inline EXTERN PredEntry **
|
||||
PtoPtoPredAdjust (PredEntry **ptr)
|
||||
{
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
return (PredEntry **) (((PredEntry **) (CharP (ptr) + HDiff)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN ArrayEntry *PtoArrayEAdjust (ArrayEntry *);
|
||||
|
157
misc/HEAPFIELDS
Normal file
157
misc/HEAPFIELDS
Normal file
@ -0,0 +1,157 @@
|
||||
//
|
||||
// File defining fields in the Yap_heap_codes global structure
|
||||
//
|
||||
// these fields used to spread all over the place, because they must be used in 4 ways:
|
||||
// - they must be defined somewhere
|
||||
// - they have an #ifdef to get a shorter name
|
||||
// - they must be initialised somewhere
|
||||
// - they must be restorable and collectable (from the atom gc).
|
||||
//
|
||||
//
|
||||
// The defs include 4+ components:
|
||||
// Type
|
||||
// name in structured
|
||||
// global name
|
||||
// init code and restore code (optional)
|
||||
//
|
||||
//
|
||||
//
|
||||
// MkAT (MkAtomTerm) cvts from a predefined atom to a term
|
||||
// MkPred constructs a pred_entry
|
||||
// MkOp gets an opcode
|
||||
// void does nothing
|
||||
// =VALUE inits as VALUE
|
||||
// Init... sets up call to InitFunc
|
||||
// Restore... sets up call to RestoreFunc
|
||||
//
|
||||
#ifdef EUROTRA
|
||||
Term term_dollar_u TermDollarU MkAT AtomDollarU
|
||||
#endif
|
||||
Term term_prolog TermProlog MkAT AtomProlog
|
||||
Term term_refound_var TermReFoundVar MkAT AtomRefoundVar
|
||||
Term user_module USER_MODULE MkAT AtomUser
|
||||
Term idb_module IDB_MODULE MkAT AtomIDB
|
||||
Term attributes_module ATTRIBUTES_MODULE MkAT AtomAttributes
|
||||
Term charsio_module CHARSIO_MODULE MkAT AtomCharsio
|
||||
Term terms_module TERMS_MODULE MkAT AtomTerms
|
||||
Term system_module SYSTEM_MODULE MkAT AtomSystem
|
||||
Term readutil_module READUTIL_MODULE MkAT AtomReadutil
|
||||
Term hacks_module HACKS_MODULE MkAT AtomYapHacks
|
||||
Term arg_module ARG_MODULE MkAT AtomArg
|
||||
Term globals_module GLOBALS_MODULE MkAT AtomNb
|
||||
Term swi_module SWI_MODULE MkAT AtomSwi
|
||||
|
||||
//
|
||||
// Module list
|
||||
//
|
||||
struct mod_entry *current_modules CurrentModules =NULL ModEntryPtrAdjust
|
||||
// make sure we have the modules set at this point.
|
||||
// don't actually want to define a field
|
||||
void void void Yap_InitModules() void
|
||||
|
||||
/* execution info */
|
||||
/* OPCODE TABLE */
|
||||
#if USE_THREADED_CODE
|
||||
opentry *op_rtable OP_RTABLE void OpRTableAdjust
|
||||
#endif
|
||||
|
||||
/* Anderson's JIT */
|
||||
yap_exec_mode execution_mode Yap_ExecutionMode =INTERPRETED void
|
||||
|
||||
/* popular opcodes */
|
||||
OPCODE execute_cpred_op_code EXECUTE_CPRED_OP_CODE MkOp _execute_cpred
|
||||
OPCODE expand_op_code EXPAND_OP_CODE MkOp _expand_index
|
||||
OPCODE fail_op FAIL_OPCODE MkOp _op_fail
|
||||
OPCODE index_op INDEX_OPCODE MkOp _index_pred
|
||||
OPCODE lockpred_op LOCKPRED_OPCODE MkOp _lock_pred
|
||||
OPCODE undef_op UNDEF_OPCODE MkOp _undef_p
|
||||
|
||||
/* The Predicate Hash Table: fast access to predicates. */
|
||||
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 pred_hash_table_size PredHashTableSize void
|
||||
|
||||
|
||||
/* Well-Known Predicates */
|
||||
struct pred_entry *creep_code CreepCode MkPred AtomCreep 1 PROLOG_MODULE
|
||||
struct pred_entry *undef_code UndefCode MkPred AtomUndefp 1 PROLOG_MODULE
|
||||
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
|
||||
struct pred_entry *pred_meta_call PredMetaCall MkPred FunctorMetaCall PROLOG_MODULE
|
||||
struct pred_entry *pred_dollar_catch PredDollarCatch MkPred FunctorCatch PROLOG_MODULE
|
||||
struct pred_entry *pred_recorded_with_key PredRecordedWithKey MkPred FunctorRecordedWithKey PROLOG_MODULE
|
||||
struct pred_entry *pred_log_upd_clause PredLogUpdClause MkPred FunctorDoLogUpdClause PROLOG_MODULE
|
||||
struct pred_entry *pred_log_upd_clause_erase PredLogUpdClauseErase MkPred FunctorDoLogUpdClauseErase PROLOG_MODULE
|
||||
struct pred_entry *pred_log_upd_clause0 PredLogUpdClause0 MkPred FunctorDoLogUpdClause PROLOG_MODULE
|
||||
struct pred_entry *pred_static_clause PredStaticClause MkPred FunctorDoStaticClause PROLOG_MODULE
|
||||
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
|
||||
|
||||
/* low-level tracer */
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
int yap_do_low_level_trace Yap_do_low_level_trace =FALSE void
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
lockvar low_level_trace_lock Yap_low_level_trace_lock MkLock
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* code management info */
|
||||
UInt clause_space Yap_ClauseSpace =0 void
|
||||
UInt index_space_Tree Yap_IndexSpace_Tree =0 void
|
||||
UInt index_space_EXT Yap_IndexSpace_EXT =0 void
|
||||
UInt index_space_SW Yap_IndexSpace_SW =0 void
|
||||
UInt lu_clause_space Yap_LUClauseSpace =0 void
|
||||
UInt lu_index_space_Tree Yap_LUIndexSpace_Tree =0 void
|
||||
UInt lu_index_space_CP Yap_LUIndexSpace_CP =0 void
|
||||
UInt lu_index_space_EXT Yap_LUIndexSpace_EXT =0 void
|
||||
UInt lu_index_space_SW Yap_LUIndexSpace_SW =0 void
|
||||
|
||||
/* static code: may be shared by many predicate or may be used for meta-execution */
|
||||
yamop comma_code[5] COMMA_CODE void void
|
||||
yamop dummycode[1] DUMMYCODE MkInstE _op_fail
|
||||
yamop failcode[1] FAILCODE MkInstE _op_fail
|
||||
yamop nocode[1] NOCODE MkInstE _Nstop
|
||||
|
||||
yamop env_for_trustfail[2] ENV_FOR_TRUSTFAIL InitEnvInst(ENV_FOR_TRUSTFAIL,&TRUSTFAILCODE,_trust_fail,PredFail) RestoreEnvInst(ENV_FOR_TRUSTFAIL,&TRUSTFAILCODE,_trust_fail,PredFail)
|
||||
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)
|
||||
|
||||
#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_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)
|
||||
#endif /* TABLING */
|
||||
|
||||
/* */
|
||||
/* PREG just before we enter $spy. We use that to find out the clause which */
|
||||
/* was calling the debugged goal. */
|
||||
/* */
|
||||
yamop *debugger_p_before_spy P_before_spy =NULL PtoOpAdjust
|
||||
|
||||
/* support recorded_k */
|
||||
yamop *retry_recordedp_code RETRY_C_RECORDEDP_CODE =NULL PtoOpAdjust
|
||||
yamop *retry_recorded_k_code RETRY_C_RECORDED_K_CODE =NULL PtoOpAdjust
|
||||
|
178
misc/buildheap
Normal file
178
misc/buildheap
Normal file
@ -0,0 +1,178 @@
|
||||
|
||||
:- use_module(library(lineutils),
|
||||
[file_filter/3,
|
||||
split/3,
|
||||
glue/3]).
|
||||
|
||||
:- use_module(library(lists),
|
||||
[append/2,
|
||||
append/3]).
|
||||
|
||||
:- initialization(main).
|
||||
|
||||
:- yap_flag(write_strings,on).
|
||||
|
||||
:- style_check(all).
|
||||
|
||||
main :-
|
||||
file_filter('misc/HEAPFIELDS','H/hstruct.h',gen_struct),
|
||||
file_filter('misc/HEAPFIELDS','H/dhstruct.h',gen_dstruct),
|
||||
file_filter('misc/HEAPFIELDS','H/rhstruct.h',gen_hstruct),
|
||||
file_filter('misc/HEAPFIELDS','H/ihstruct.h',gen_init).
|
||||
|
||||
|
||||
/* define the field */
|
||||
gen_struct(Inp,"") :-
|
||||
Inp = [0'/,0'/|_], !.
|
||||
gen_struct(Inp,"") :-
|
||||
Inp = [0'/,0'*|_], !.
|
||||
gen_struct(Inp, Out) :-
|
||||
Inp = [0'#|_], !, Out = Inp. % '
|
||||
gen_struct(Inp,Out) :-
|
||||
split(Inp," ",["struct",Type, Field|_]), !,
|
||||
append([" struct ",Type," ",Field,";"], Out).
|
||||
gen_struct(Inp,"") :-
|
||||
split(Inp," ",["void","void"|_]), !.
|
||||
gen_struct(Inp,Out) :-
|
||||
split(Inp," ",[Type, Field|_]), !,
|
||||
append([" ",Type," ",Field,";"], Out).
|
||||
gen_struct(Inp,_) :-
|
||||
split(Inp," ",[_, _, _| _]),
|
||||
format(user_error,"OOPS: could not gen_struct for ~s~n",[Inp]).
|
||||
|
||||
gen_dstruct(Inp,"") :-
|
||||
Inp = [0'/,0'/|_], !.
|
||||
gen_dstruct(Inp,"") :-
|
||||
Inp = [0'/,0'*|_], !.
|
||||
gen_dstruct(Inp, Out) :-
|
||||
Inp = [0'#|_], !, Out = Inp. % '
|
||||
gen_dstruct(Inp,"") :-
|
||||
split(Inp," ",["void","void"|_]), !.
|
||||
gen_dstruct(Inp,Out) :-
|
||||
split(Inp," ",["struct"|Inp2]), !,
|
||||
glue(Inp2, " ", Inp3),
|
||||
gen_dstruct(Inp3, Out).
|
||||
gen_dstruct(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, Name|_]), !,
|
||||
cut_c_stuff(Field, RField),
|
||||
append(["#define ",Name," Yap_heap_regs->",RField], Out).
|
||||
gen_dstruct(Inp,_) :-
|
||||
split(Inp," ",[_, _, _| _]),
|
||||
format(user_error,"OOPS: could not gen_dstruct for ~s~n",[Inp]).
|
||||
|
||||
% handle *field[4]
|
||||
cut_c_stuff([0'*|Name], RName) :- !, % 'cut *
|
||||
cut_c_stuff(Name, RName).
|
||||
cut_c_stuff(Name, RName) :-
|
||||
cut_mat(Name, RName).
|
||||
|
||||
cut_mat([], []).
|
||||
cut_mat([0'[|_], []) :- !. %'
|
||||
cut_mat(H.Name, H.RName) :-
|
||||
cut_mat(Name, RName).
|
||||
|
||||
gen_hstruct(Inp,"") :-
|
||||
Inp = [0'/,0'/|_], !.
|
||||
gen_hstruct(Inp,"") :-
|
||||
Inp = [0'/,0'*|_], !.
|
||||
gen_hstruct(Inp, Out) :-
|
||||
Inp = [0'#|_], !, Out = Inp. % '
|
||||
gen_hstruct(Inp,Out) :-
|
||||
split(Inp," ",["struct"|Inp2]), !,
|
||||
glue(Inp2, " ", Inp3),
|
||||
gen_hstruct(Inp3,Out).
|
||||
gen_hstruct(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, _, "MkAT", _]), !,
|
||||
append([" Yap_heap_regs->",Field," = AtomTermAdjust(Yap_heap_regs->",Field,");"], Out).
|
||||
gen_hstruct(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, _, "MkPred"| _]), !,
|
||||
cut_c_stuff(Field, RField),
|
||||
append([" Yap_heap_regs->",RField," = PtoPredAdjust(Yap_heap_regs->",RField,");"], Out).
|
||||
gen_hstruct(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, _, "MkOp", Name]), !,
|
||||
append([" Yap_heap_regs->",Field," = Yap_opcode(",Name,");"], Out).
|
||||
gen_hstruct(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, _, "MkLock"]), !,
|
||||
append([" REINIT_LOCK(Yap_heap_regs->",Field,");"], Out).
|
||||
gen_hstruct(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, _, "MkRWLock"]), !,
|
||||
append([" REINIT_RWLOCK(Yap_heap_regs->",Field,");"], Out).
|
||||
gen_hstruct(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, _, "MkInstE",OP]), !,
|
||||
cut_c_stuff(Field, RField),
|
||||
append([" Yap_heap_regs->",RField,"->opc = Yap_opcode(",OP,");"], Out).
|
||||
gen_hstruct(Inp,"") :-
|
||||
split(Inp," ",[_, _, _, "void"]), !.
|
||||
gen_hstruct(Inp,"") :-
|
||||
split(Inp," ",[_, _, _, _, "void"]), !.
|
||||
gen_hstruct(Inp,Restore) :-
|
||||
split(Inp," ",[_, _, _, _, Restore0]),
|
||||
append("Restore",_,Restore0), !,
|
||||
append([" ",Restore0,";"],Restore). %'
|
||||
gen_hstruct(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, _, _, Adjust]),
|
||||
append(Adjust,"Adjust",_), !,
|
||||
cut_c_stuff(Field, RField),
|
||||
append([" Yap_heap_regs->",RField," = ",Adjust,"(Yap_heap_regs->",RField,");"], Out).
|
||||
gen_hstruct(Inp,_) :-
|
||||
split(Inp," ",[_, _, _| _]),
|
||||
format(user_error,"OOPS: could not gen_hstruct for ~s~n",[Inp]).
|
||||
|
||||
gen_init(Inp,"") :-
|
||||
Inp = [0'/,0'*|_], !.
|
||||
gen_init(Inp,"") :-
|
||||
Inp = [0'/,0'/|_], !.
|
||||
gen_init(Inp, Out) :-
|
||||
Inp = [0'#|_], !, Out = Inp. % '
|
||||
gen_init(Inp,Out) :-
|
||||
split(Inp," ",["struct"|Inp2]), !,
|
||||
glue(Inp2, " ", Inp3),
|
||||
gen_init(Inp3, Out).
|
||||
gen_init(Inp,"") :-
|
||||
split(Inp," ",[_, _, _, "void"|_]), !.
|
||||
gen_init(Inp,Init) :-
|
||||
split(Inp," ",[_, _, _, Init0| _]),
|
||||
append("Init",_,Init0), !,
|
||||
append([" ",Init0,";"],Init).
|
||||
gen_init(Inp,Init) :-
|
||||
split(Inp," ",[_, _, _, Init0| _]),
|
||||
append("Yap_Init",_,Init0), !,
|
||||
append([" ",Init0,";"],Init).
|
||||
gen_init(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, _, "MkAT", AtomName]), !,
|
||||
cut_c_stuff(Field, RField),
|
||||
append([" Yap_heap_regs->",RField," = MkAtomTerm(",AtomName,");"], Out).
|
||||
gen_init(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, _, "MkOp", Name]), !,
|
||||
append([" Yap_heap_regs->",Field," = Yap_opcode(",Name,");"], Out).
|
||||
gen_init(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, _, "MkLock"]), !,
|
||||
append([" INIT_LOCK(Yap_heap_regs->",Field,");"], Out).
|
||||
gen_init(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, _, "MkRWLock"]), !,
|
||||
append([" INIT_RWLOCK(Yap_heap_regs->",Field,");"], Out).
|
||||
gen_init(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, _, "MkInstE",OP]), !,
|
||||
cut_c_stuff(Field, RField),
|
||||
append([" Yap_heap_regs->",RField,"->opc = Yap_opcode(",OP,");"], Out).
|
||||
gen_init(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, _, "MkPred", Atom, "0", Module]), !,
|
||||
cut_c_stuff(Field, RField),
|
||||
append([" Yap_heap_regs->",RField," = RepPredProp(PredPropByAtom(",Atom,",",Module,"));"], Out).
|
||||
gen_init(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, _, "MkPred", Atom, Arity, Module]), !,
|
||||
cut_c_stuff(Field, RField),
|
||||
append([" Yap_heap_regs->",RField," = RepPredProp(PredPropByFunc(Yap_MkFunctor(",Atom,",",Arity,"),",Module,"));"], Out).
|
||||
gen_init(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, _, "MkPred", Fun, Module]), !,
|
||||
cut_c_stuff(Field, RField),
|
||||
append([" Yap_heap_regs->",RField," = RepPredProp(PredPropByFunc(",Fun,",",Module,"));"], Out).
|
||||
gen_init(Inp,Out) :-
|
||||
split(Inp," ",[_, Field, _, F0|_]),
|
||||
append("=",F,F0), !,
|
||||
cut_c_stuff(Field, RField),
|
||||
append([" Yap_heap_regs->",RField," = ",F,";"], Out).
|
||||
gen_init(Inp,_) :-
|
||||
split(Inp," ",[_, _, _| _]),
|
||||
format(user_error,"OOPS: could not gen_init for ~s~n",[Inp]).
|
||||
|
Reference in New Issue
Block a user