2002-06-04 19:21:55 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* *
|
|
|
|
* YAP Prolog *
|
|
|
|
* *
|
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
2004-03-19 11:35:42 +00:00
|
|
|
* File: rheap.h *
|
2002-06-04 19:21:55 +01:00
|
|
|
* comments: walk through heap code *
|
|
|
|
* *
|
2006-03-22 20:07:28 +00:00
|
|
|
* Last rev: $Date: 2006-03-22 20:07:28 $,$Author: vsc $ *
|
2004-03-31 02:03:10 +01:00
|
|
|
* $Log: not supported by cvs2svn $
|
2006-03-22 20:07:28 +00:00
|
|
|
* Revision 1.63 2006/03/06 14:04:56 vsc
|
|
|
|
* fixes to garbage collector
|
|
|
|
* fixes to debugger
|
|
|
|
*
|
2006-03-06 14:04:57 +00:00
|
|
|
* Revision 1.62 2006/02/24 14:03:42 vsc
|
|
|
|
* fix refs to old LogUpd implementation (pre 5).
|
|
|
|
*
|
2006-02-24 14:03:42 +00:00
|
|
|
* Revision 1.61 2006/01/02 02:16:18 vsc
|
|
|
|
* support new interface between YAP and GMP, so that we don't rely on our own
|
|
|
|
* allocation routines.
|
|
|
|
* Several big fixes.
|
|
|
|
*
|
2006-01-02 02:16:19 +00:00
|
|
|
* Revision 1.60 2005/12/17 03:25:39 vsc
|
|
|
|
* major changes to support online event-based profiling
|
|
|
|
* improve error discovery and restart on scanner.
|
|
|
|
*
|
2005-12-17 03:25:39 +00:00
|
|
|
* Revision 1.59 2005/12/05 17:16:11 vsc
|
|
|
|
* write_depth/3
|
|
|
|
* overflow handlings and garbage collection
|
|
|
|
* Several ipdates to CLPBN
|
|
|
|
* dif/2 could be broken in the presence of attributed variables.
|
|
|
|
*
|
2005-12-05 17:16:12 +00:00
|
|
|
* Revision 1.58 2005/11/23 03:01:33 vsc
|
|
|
|
* fix several bugs in save/restore.b
|
|
|
|
*
|
2005-11-23 03:01:33 +00:00
|
|
|
* Revision 1.57 2005/10/28 17:38:50 vsc
|
|
|
|
* sveral updates
|
|
|
|
*
|
2005-10-28 18:38:50 +01:00
|
|
|
* Revision 1.56 2005/10/21 16:09:03 vsc
|
|
|
|
* SWI compatible module only operators
|
|
|
|
*
|
2005-10-21 17:09:03 +01:00
|
|
|
* Revision 1.55 2005/10/19 19:00:48 vsc
|
|
|
|
* extend arrays with nb_terms so that we can implement nb_ builtins
|
|
|
|
* correctly.
|
|
|
|
*
|
2005-10-19 20:00:48 +01:00
|
|
|
* Revision 1.54 2005/09/09 17:24:39 vsc
|
|
|
|
* a new and hopefully much better implementation of atts.
|
|
|
|
*
|
2005-09-09 18:24:39 +01:00
|
|
|
* Revision 1.53 2005/08/01 15:40:38 ricroc
|
|
|
|
* TABLING NEW: better support for incomplete tabling
|
|
|
|
*
|
2005-08-01 16:40:39 +01:00
|
|
|
* Revision 1.52 2005/07/06 19:34:11 ricroc
|
|
|
|
* TABLING: answers for completed calls can now be obtained by loading (new option) or executing (default) them from the trie data structure.
|
|
|
|
*
|
2005-07-06 20:34:12 +01:00
|
|
|
* Revision 1.51 2005/07/06 15:10:15 vsc
|
|
|
|
* improvements to compiler: merged instructions and fixes for ->
|
|
|
|
*
|
2005-07-06 16:10:18 +01:00
|
|
|
* Revision 1.50 2005/06/01 13:53:46 vsc
|
|
|
|
* improve bb routines to use the DB efficiently
|
|
|
|
* change interface between DB and BB.
|
|
|
|
*
|
2005-06-01 14:53:46 +01:00
|
|
|
* Revision 1.49 2005/05/30 03:26:37 vsc
|
|
|
|
* add some atom gc fixes
|
|
|
|
*
|
2005-05-30 04:26:37 +01:00
|
|
|
* Revision 1.48 2005/01/04 02:50:21 vsc
|
|
|
|
* - allow MegaClauses with blobs
|
|
|
|
* - change Diffs to be thread specific
|
|
|
|
* - include Christian's updates
|
|
|
|
*
|
2005-01-04 02:50:23 +00:00
|
|
|
* Revision 1.47 2004/12/02 06:06:47 vsc
|
|
|
|
* fix threads so that they at least start
|
|
|
|
* allow error handling to work with threads
|
|
|
|
* replace heap_base by Yap_heap_base, according to Yap's convention for globals.
|
|
|
|
*
|
2004-12-02 06:06:47 +00:00
|
|
|
* Revision 1.46 2004/11/23 21:16:21 vsc
|
|
|
|
* A few extra fixes for saved states.
|
|
|
|
*
|
2004-11-23 21:16:21 +00:00
|
|
|
* Revision 1.45 2004/10/26 20:16:18 vsc
|
|
|
|
* More bug fixes for overflow handling
|
|
|
|
*
|
2004-10-26 21:16:18 +01:00
|
|
|
* Revision 1.44 2004/10/06 16:55:47 vsc
|
|
|
|
* change configure to support big mem configs
|
|
|
|
* get rid of extra globals
|
|
|
|
* fix trouble with multifile preds
|
|
|
|
*
|
2004-10-06 17:55:48 +01:00
|
|
|
* Revision 1.43 2004/09/27 20:45:04 vsc
|
|
|
|
* Mega clauses
|
|
|
|
* Fixes to sizeof(expand_clauses) which was being overestimated
|
|
|
|
* Fixes to profiling+indexing
|
|
|
|
* Fixes to reallocation of memory after restoring
|
|
|
|
* Make sure all clauses, even for C, end in _Ystop
|
|
|
|
* Don't reuse space for Streams
|
|
|
|
* Fix Stream_F on StreaNo+1
|
|
|
|
*
|
2004-09-27 21:45:04 +01:00
|
|
|
* Revision 1.42 2004/06/05 03:37:00 vsc
|
|
|
|
* coroutining is now a part of attvars.
|
|
|
|
* some more fixes.
|
|
|
|
*
|
2004-06-05 04:37:01 +01:00
|
|
|
* Revision 1.41 2004/04/29 03:45:50 vsc
|
|
|
|
* fix garbage collection in execute_tail
|
|
|
|
*
|
2004-04-29 04:45:50 +01:00
|
|
|
* Revision 1.40 2004/03/31 01:03:10 vsc
|
|
|
|
* support expand group of clauses
|
|
|
|
*
|
2004-03-31 02:03:10 +01:00
|
|
|
* Revision 1.39 2004/03/19 11:35:42 vsc
|
|
|
|
* trim_trail for default machine
|
|
|
|
* be more aggressive about try-retry-trust chains.
|
|
|
|
* - handle cases where block starts with a wait
|
|
|
|
* - don't use _killed instructions, just let the thing rot by itself.
|
|
|
|
* *
|
2004-03-19 11:35:42 +00:00
|
|
|
* *
|
2002-06-04 19:21:55 +01:00
|
|
|
*************************************************************************/
|
|
|
|
#ifdef SCCS
|
|
|
|
static char SccsId[] = "@(#)rheap.c 1.3 3/15/90";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define Atomics 0
|
|
|
|
#define Funcs 1
|
|
|
|
|
|
|
|
/* Now, everything on its place so you must adjust the pointers */
|
|
|
|
|
2004-09-27 21:45:04 +01:00
|
|
|
static void
|
|
|
|
do_clean_susp_clauses(yamop *ipc) {
|
|
|
|
COUNT i;
|
|
|
|
yamop **st = (yamop **)NEXTOP(ipc,sp);
|
|
|
|
|
|
|
|
ipc->opc = Yap_opcode(_expand_clauses);
|
|
|
|
ipc->u.sp.p = PtoPredAdjust(ipc->u.sp.p);
|
|
|
|
if (ipc->u.sp.sprev) {
|
|
|
|
ipc->u.sp.sprev = PtoOpAdjust(ipc->u.sp.sprev);
|
|
|
|
}
|
|
|
|
if (ipc->u.sp.snext) {
|
|
|
|
ipc->u.sp.snext = PtoOpAdjust(ipc->u.sp.snext);
|
|
|
|
}
|
|
|
|
for (i = 0; i < ipc->u.sp.s1; i++, st++) {
|
|
|
|
if (*st) {
|
|
|
|
*st = PtoOpAdjust(*st);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-22 20:07:28 +00:00
|
|
|
#include "rclause.h"
|
|
|
|
|
|
|
|
/* Restoring the heap */
|
|
|
|
|
|
|
|
/* adjusts terms stored in the data base, when they have no variables */
|
|
|
|
static Term
|
|
|
|
AdjustDBTerm(Term trm, Term *p_base)
|
|
|
|
{
|
|
|
|
if (IsAtomTerm(trm))
|
|
|
|
return AtomTermAdjust(trm);
|
|
|
|
if (IsPairTerm(trm)) {
|
|
|
|
Term *p;
|
|
|
|
|
|
|
|
p = PtoHeapCellAdjust(RepPair(trm));
|
|
|
|
if (p >= p_base) {
|
|
|
|
p[0] = AdjustDBTerm(p[0], p);
|
|
|
|
p[1] = AdjustDBTerm(p[1], p);
|
|
|
|
}
|
|
|
|
return AbsPair(p);
|
|
|
|
}
|
|
|
|
if (IsApplTerm(trm)) {
|
|
|
|
Term *p;
|
|
|
|
Functor f;
|
|
|
|
Term *p0 = p = PtoHeapCellAdjust(RepAppl(trm));
|
|
|
|
/* if it is before the current position, then we are looking
|
|
|
|
at old code */
|
|
|
|
if (p >= p_base) {
|
|
|
|
f = (Functor)p[0];
|
|
|
|
if (!IsExtensionFunctor(f)) {
|
|
|
|
UInt Arity, i;
|
|
|
|
|
|
|
|
f = FuncAdjust(f);
|
|
|
|
*p++ = (Term)f;
|
|
|
|
Arity = ArityOfFunctor(f);
|
|
|
|
for (i = 0; i < Arity; ++i) {
|
|
|
|
*p = AdjustDBTerm(*p, p0);
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return AbsAppl(p0);
|
|
|
|
}
|
|
|
|
return trm;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
RestoreDBTerm(DBTerm *dbr)
|
|
|
|
{
|
|
|
|
#ifdef COROUTINING
|
|
|
|
if (dbr->attachments)
|
|
|
|
dbr->attachments = AdjustDBTerm(dbr->attachments, dbr->Contents);
|
|
|
|
#endif
|
|
|
|
if (dbr->DBRefs != NULL) {
|
|
|
|
DBRef *cp;
|
|
|
|
DBRef tm;
|
|
|
|
|
|
|
|
dbr->DBRefs = DBRefPAdjust(dbr->DBRefs);
|
|
|
|
cp = dbr->DBRefs;
|
|
|
|
while ((tm = *--cp) != 0)
|
|
|
|
*cp = DBRefAdjust(tm);
|
|
|
|
}
|
|
|
|
dbr->Entry = AdjustDBTerm(dbr->Entry, dbr->Contents);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restores a prolog clause, in its compiled form */
|
|
|
|
static void
|
|
|
|
RestoreStaticClause(StaticClause *cl)
|
|
|
|
/*
|
|
|
|
* Cl points to the start of the code, IsolFlag tells if we have a single
|
|
|
|
* clause for this predicate or not
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
if (cl->ClFlags & FactMask) {
|
|
|
|
cl->usc.ClPred = PtoPredAdjust(cl->usc.ClPred);
|
|
|
|
} else {
|
|
|
|
cl->usc.ClSource = DBTermAdjust(cl->usc.ClSource);
|
|
|
|
}
|
|
|
|
if (cl->ClNext) {
|
|
|
|
cl->ClNext = PtoStCAdjust(cl->ClNext);
|
|
|
|
}
|
|
|
|
restore_opcodes(cl->ClCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restores a prolog clause, in its compiled form */
|
|
|
|
static void
|
|
|
|
RestoreMegaClause(MegaClause *cl)
|
|
|
|
/*
|
|
|
|
* Cl points to the start of the code, IsolFlag tells if we have a single
|
|
|
|
* clause for this predicate or not
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
cl->ClPred = PtoPredAdjust(cl->ClPred);
|
|
|
|
if (cl->ClNext) {
|
|
|
|
cl->ClNext = (MegaClause *)AddrAdjust((ADDR)(cl->ClNext));
|
|
|
|
}
|
|
|
|
restore_opcodes(cl->ClCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restores a prolog clause, in its compiled form */
|
|
|
|
static void
|
|
|
|
RestoreDynamicClause(DynamicClause *cl, PredEntry *pp)
|
|
|
|
/*
|
|
|
|
* Cl points to the start of the code, IsolFlag tells if we have a single
|
|
|
|
* clause for this predicate or not
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
if (cl->ClPrevious != NULL) {
|
|
|
|
cl->ClPrevious = PtoOpAdjust(cl->ClPrevious);
|
|
|
|
}
|
|
|
|
INIT_LOCK(cl->ClLock);
|
|
|
|
restore_opcodes(cl->ClCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restores a prolog clause, in its compiled form */
|
|
|
|
static void
|
|
|
|
RestoreLUClause(LogUpdClause *cl, PredEntry *pp)
|
|
|
|
/*
|
|
|
|
* Cl points to the start of the code, IsolFlag tells if we have a single
|
|
|
|
* clause for this predicate or not
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
INIT_LOCK(cl->ClLock);
|
|
|
|
if (cl->ClFlags & LogUpdRuleMask) {
|
|
|
|
cl->ClExt = PtoOpAdjust(cl->ClExt);
|
|
|
|
}
|
|
|
|
if (cl->ClSource) {
|
|
|
|
cl->ClSource = DBTermAdjust(cl->ClSource);
|
|
|
|
RestoreDBTerm(cl->ClSource);
|
|
|
|
}
|
|
|
|
if (cl->ClPrev) {
|
|
|
|
cl->ClPrev = PtoLUCAdjust(cl->ClPrev);
|
|
|
|
}
|
|
|
|
if (cl->ClNext) {
|
|
|
|
cl->ClNext = PtoLUCAdjust(cl->ClNext);
|
|
|
|
}
|
|
|
|
cl->ClPred = PtoPredAdjust(cl->ClPred);
|
|
|
|
restore_opcodes(cl->ClCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CleanLUIndex(LogUpdIndex *idx)
|
|
|
|
{
|
|
|
|
idx->ClRefCount = 0;
|
|
|
|
INIT_LOCK(idx->ClLock);
|
|
|
|
idx->ClPred = PtoPredAdjust(idx->ClPred);
|
|
|
|
if (idx->ParentIndex)
|
|
|
|
idx->ParentIndex = LUIndexAdjust(idx->ParentIndex);
|
|
|
|
if (idx->SiblingIndex) {
|
|
|
|
idx->SiblingIndex = LUIndexAdjust(idx->SiblingIndex);
|
|
|
|
CleanLUIndex(idx->SiblingIndex);
|
|
|
|
}
|
|
|
|
if (idx->ChildIndex) {
|
|
|
|
idx->ChildIndex = LUIndexAdjust(idx->ChildIndex);
|
|
|
|
CleanLUIndex(idx->ChildIndex);
|
|
|
|
}
|
|
|
|
if (!(idx->ClFlags & SwitchTableMask)) {
|
|
|
|
restore_opcodes(idx->ClCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CleanSIndex(StaticIndex *idx)
|
|
|
|
{
|
|
|
|
idx->ClPred = PtoPredAdjust(idx->ClPred);
|
|
|
|
if (idx->SiblingIndex) {
|
|
|
|
idx->SiblingIndex = SIndexAdjust(idx->SiblingIndex);
|
|
|
|
CleanSIndex(idx->SiblingIndex);
|
|
|
|
}
|
|
|
|
if (idx->ChildIndex) {
|
|
|
|
idx->ChildIndex = SIndexAdjust(idx->ChildIndex);
|
|
|
|
CleanSIndex(idx->ChildIndex);
|
|
|
|
}
|
|
|
|
if (!(idx->ClFlags & SwitchTableMask)) {
|
|
|
|
restore_opcodes(idx->ClCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-04 19:21:55 +01:00
|
|
|
/* restore the failcodes */
|
|
|
|
static void
|
|
|
|
restore_codes(void)
|
|
|
|
{
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->heap_top = AddrAdjust(OldHeapTop);
|
2005-11-23 03:01:33 +00:00
|
|
|
if (Yap_heap_regs->heap_lim) {
|
|
|
|
Yap_heap_regs->heap_lim = AddrAdjust(Yap_heap_regs->heap_lim);
|
|
|
|
}
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef YAPOR
|
2005-07-06 20:34:12 +01:00
|
|
|
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);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif /* YAPOR */
|
|
|
|
#ifdef TABLING
|
2005-08-01 16:40:39 +01:00
|
|
|
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);
|
2005-07-06 20:34:12 +01:00
|
|
|
Yap_heap_regs->table_answer_resolution_code.opc = Yap_opcode(_table_answer_resolution);
|
|
|
|
Yap_heap_regs->table_completion_code.opc = Yap_opcode(_table_completion);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef YAPOR
|
2005-08-01 16:40:39 +01:00
|
|
|
INIT_YAMOP_LTT(&(Yap_heap_regs->table_load_answer_code), 0);
|
|
|
|
INIT_YAMOP_LTT(&(Yap_heap_regs->table_try_answer_code), 0);
|
2005-07-06 20:34:12 +01:00
|
|
|
INIT_YAMOP_LTT(&(Yap_heap_regs->table_completion_code), 0);
|
|
|
|
INIT_YAMOP_LTT(&(Yap_heap_regs->table_answer_resolution_code), 0);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif /* YAPOR */
|
|
|
|
#endif /* TABLING */
|
2004-12-02 06:06:47 +00:00
|
|
|
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)
|
|
|
|
Yap_heap_regs->expand_clauses_last = PtoOpAdjust(Yap_heap_regs->expand_clauses_last);
|
2004-09-27 21:45:04 +01:00
|
|
|
{
|
2004-12-02 06:06:47 +00:00
|
|
|
yamop *ptr = Yap_heap_regs->expand_clauses_first;
|
2004-09-27 21:45:04 +01:00
|
|
|
while (ptr) {
|
|
|
|
do_clean_susp_clauses(ptr);
|
|
|
|
ptr = ptr->u.sp.snext;
|
|
|
|
}
|
|
|
|
}
|
2004-12-02 06:06:47 +00:00
|
|
|
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);
|
2002-06-04 19:21:55 +01:00
|
|
|
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->env_for_trustfail_code.op = Yap_opcode(_call);
|
|
|
|
Yap_heap_regs->trustfailcode->opc = Yap_opcode(_trust_fail);
|
2002-06-04 19:21:55 +01:00
|
|
|
|
2004-12-02 06:06:47 +00:00
|
|
|
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->fail_op = Yap_opcode(_op_fail);
|
|
|
|
Yap_heap_regs->nocode->opc = Yap_opcode(_Nstop);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef YAPOR
|
2004-12-02 06:06:47 +00:00
|
|
|
INIT_YAMOP_LTT(&(Yap_heap_regs->nocode), 1);
|
|
|
|
INIT_YAMOP_LTT(&(Yap_heap_regs->rtrycode), 1);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif /* YAPOR */
|
2004-12-02 06:06:47 +00:00
|
|
|
((yamop *)(&Yap_heap_regs->rtrycode))->opc = Yap_opcode(_retry_and_mark);
|
|
|
|
if (((yamop *)(&Yap_heap_regs->rtrycode))->u.ld.d != NIL)
|
|
|
|
((yamop *)(&Yap_heap_regs->rtrycode))->u.ld.d =
|
|
|
|
PtoOpAdjust(((yamop *)(&Yap_heap_regs->rtrycode))->u.ld.d);
|
2002-06-04 19:21:55 +01:00
|
|
|
{
|
|
|
|
int arity;
|
2004-12-02 06:06:47 +00:00
|
|
|
arity = Yap_heap_regs->clausecode->arity;
|
|
|
|
if (Yap_heap_regs->clausecode->clause != NIL)
|
|
|
|
Yap_heap_regs->clausecode->clause =
|
|
|
|
PtoOpAdjust(Yap_heap_regs->clausecode->clause);
|
2002-06-04 19:21:55 +01:00
|
|
|
if (arity) {
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->clausecode->func =
|
|
|
|
FuncAdjust(Yap_heap_regs->clausecode->func);
|
2002-06-04 19:21:55 +01:00
|
|
|
} else {
|
|
|
|
/* an atom */
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->clausecode->func =
|
|
|
|
(Functor)AtomAdjust((Atom)(Yap_heap_regs->clausecode->func));
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* restore consult stack. It consists of heap pointers, so it
|
|
|
|
is easy to fix.
|
|
|
|
*/
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->consultlow =
|
|
|
|
ConsultObjAdjust(Yap_heap_regs->consultlow);
|
|
|
|
Yap_heap_regs->consultbase =
|
|
|
|
ConsultObjAdjust(Yap_heap_regs->consultbase);
|
|
|
|
Yap_heap_regs->consultsp =
|
|
|
|
ConsultObjAdjust(Yap_heap_regs->consultsp);
|
2002-06-04 19:21:55 +01:00
|
|
|
{
|
|
|
|
/* we assume all pointers have the same size */
|
2004-12-02 06:06:47 +00:00
|
|
|
register consult_obj *pt = Yap_heap_regs->consultsp;
|
2002-06-04 19:21:55 +01:00
|
|
|
while (pt <
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->consultlow+Yap_heap_regs->consultcapacity) {
|
2002-06-04 19:21:55 +01:00
|
|
|
pt->p = PropAdjust(pt->p);
|
|
|
|
pt ++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if USE_THREADED_CODE
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->op_rtable = (opentry *)
|
|
|
|
CodeAddrAdjust((CODEADDR)(Yap_heap_regs->op_rtable));
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
if (Yap_heap_regs->atprompt != NIL) {
|
|
|
|
Yap_heap_regs->atprompt =
|
|
|
|
AtomAdjust(Yap_heap_regs->atprompt);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
2006-03-22 20:07:28 +00:00
|
|
|
if (Yap_heap_regs->char_conversion_table) {
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->char_conversion_table = (char *)
|
|
|
|
AddrAdjust((ADDR)Yap_heap_regs->char_conversion_table);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
2006-03-22 20:07:28 +00:00
|
|
|
if (Yap_heap_regs->char_conversion_table2) {
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->char_conversion_table2 = (char *)
|
|
|
|
AddrAdjust((ADDR)Yap_heap_regs->char_conversion_table2);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
2006-03-22 20:07:28 +00:00
|
|
|
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);
|
|
|
|
si = si->SiblingIndex;
|
|
|
|
}
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
2004-12-02 06:06:47 +00:00
|
|
|
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));
|
2002-06-04 19:21:55 +01:00
|
|
|
{
|
|
|
|
UInt i;
|
2004-12-02 06:06:47 +00:00
|
|
|
for (i = 0; i < Yap_heap_regs->int_keys_size; i++) {
|
|
|
|
if (Yap_heap_regs->IntKeys[i] != NIL) {
|
|
|
|
Prop p0 = Yap_heap_regs->IntKeys[i] = PropAdjust(Yap_heap_regs->IntKeys[i]);
|
2002-06-04 19:21:55 +01:00
|
|
|
RestoreEntries(RepProp(p0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-12-02 06:06:47 +00:00
|
|
|
if (Yap_heap_regs->IntLUKeys != NULL) {
|
|
|
|
Yap_heap_regs->IntLUKeys = (Prop *)AddrAdjust((ADDR)(Yap_heap_regs->IntLUKeys));
|
2004-02-06 10:19:49 +00:00
|
|
|
{
|
|
|
|
Int i;
|
|
|
|
for (i = 0; i < INT_KEYS_SIZE; i++) {
|
|
|
|
Prop p0 = INT_LU_KEYS[i];
|
|
|
|
if (p0) {
|
|
|
|
p0 = PropAdjust(p0);
|
|
|
|
INT_LU_KEYS[i] = p0;
|
|
|
|
while (p0) {
|
|
|
|
PredEntry *pe = RepPredProp(p0);
|
|
|
|
pe->NextOfPE =
|
|
|
|
PropAdjust(pe->NextOfPE);
|
|
|
|
CleanCode(pe);
|
|
|
|
p0 = RepProp(pe->NextOfPE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-12-02 06:06:47 +00:00
|
|
|
if (Yap_heap_regs->IntBBKeys != NULL) {
|
|
|
|
Yap_heap_regs->IntBBKeys = (Prop *)AddrAdjust((ADDR)(Yap_heap_regs->IntBBKeys));
|
2002-06-04 19:21:55 +01:00
|
|
|
{
|
|
|
|
UInt i;
|
2004-12-02 06:06:47 +00:00
|
|
|
for (i = 0; i < Yap_heap_regs->int_bb_keys_size; i++) {
|
|
|
|
if (Yap_heap_regs->IntBBKeys[i] != NIL) {
|
|
|
|
Prop p0 = Yap_heap_regs->IntBBKeys[i] = PropAdjust(Yap_heap_regs->IntBBKeys[i]);
|
2002-06-04 19:21:55 +01:00
|
|
|
RestoreEntries(RepProp(p0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
/* adjust atoms in atom table */
|
|
|
|
unsigned int i = 0;
|
|
|
|
|
2004-12-02 06:06:47 +00:00
|
|
|
for (i = 0; i < Yap_heap_regs->no_of_modules; i++) {
|
|
|
|
Yap_heap_regs->module_name[i] = AtomTermAdjust(Yap_heap_regs->module_name[i]);
|
|
|
|
if (Yap_heap_regs->module_pred[i]) {
|
|
|
|
Yap_heap_regs->module_pred[i] = PtoPredAdjust(Yap_heap_regs->module_pred[i]);
|
2002-10-02 18:07:45 +01:00
|
|
|
}
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
}
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->atom_abol = AtomAdjust(Yap_heap_regs->atom_abol);
|
|
|
|
Yap_heap_regs->atom_append = AtomAdjust(Yap_heap_regs->atom_append);
|
|
|
|
Yap_heap_regs->atom_array = AtomAdjust(Yap_heap_regs->atom_array);
|
|
|
|
Yap_heap_regs->atom_assert = AtomAdjust(Yap_heap_regs->atom_assert);
|
|
|
|
Yap_heap_regs->atom_alarm = AtomAdjust(Yap_heap_regs->atom_alarm);
|
2005-09-09 18:24:39 +01:00
|
|
|
#ifdef COROUTINING
|
|
|
|
Yap_heap_regs->atom_att = AtomAdjust(Yap_heap_regs->atom_att);
|
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->atom_b = AtomAdjust(Yap_heap_regs->atom_b);
|
|
|
|
Yap_heap_regs->atom_break = AtomAdjust(Yap_heap_regs->atom_break);
|
|
|
|
Yap_heap_regs->atom_call = AtomAdjust(Yap_heap_regs->atom_call);
|
|
|
|
Yap_heap_regs->atom_catch = AtomAdjust(Yap_heap_regs->atom_catch);
|
|
|
|
Yap_heap_regs->atom_comma = AtomAdjust(Yap_heap_regs->atom_comma);
|
|
|
|
Yap_heap_regs->atom_cpu_time = AtomAdjust(Yap_heap_regs->atom_cpu_time);
|
|
|
|
Yap_heap_regs->atom_csult = AtomAdjust(Yap_heap_regs->atom_csult);
|
|
|
|
Yap_heap_regs->atom_cut = AtomAdjust(Yap_heap_regs->atom_cut);
|
|
|
|
Yap_heap_regs->atom_cut_by = AtomAdjust(Yap_heap_regs->atom_cut_by);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef EUROTRA
|
|
|
|
#ifdef SFUNC
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->atom_dollar_undef = AtomAdjust(Yap_heap_regs->atom_dollar_undef);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->atom_dbref = AtomAdjust(Yap_heap_regs->atom_dbref);
|
|
|
|
Yap_heap_regs->atom_e = AtomAdjust(Yap_heap_regs->atom_e);
|
|
|
|
Yap_heap_regs->atom_e_q = AtomAdjust(Yap_heap_regs->atom_e_q);
|
|
|
|
Yap_heap_regs->atom_eof = AtomAdjust(Yap_heap_regs->atom_eof);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef EUROTRA
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->atom_f_b = AtomAdjust(Yap_heap_regs->atom_f_b);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->atom_fail = AtomAdjust(Yap_heap_regs->atom_fail);
|
|
|
|
Yap_heap_regs->atom_false = AtomAdjust(Yap_heap_regs->atom_false);
|
|
|
|
Yap_heap_regs->atom_fast = AtomAdjust(Yap_heap_regs->atom_fast);
|
|
|
|
Yap_heap_regs->atom_g_t = AtomAdjust(Yap_heap_regs->atom_g_t);
|
|
|
|
Yap_heap_regs->atom_gc = AtomAdjust(Yap_heap_regs->atom_gc);
|
|
|
|
Yap_heap_regs->atom_gc_margin = AtomAdjust(Yap_heap_regs->atom_gc_margin);
|
|
|
|
Yap_heap_regs->atom_gc_trace = AtomAdjust(Yap_heap_regs->atom_gc_trace);
|
|
|
|
Yap_heap_regs->atom_gc_verbose = AtomAdjust(Yap_heap_regs->atom_gc_verbose);
|
|
|
|
Yap_heap_regs->atom_gc_very_verbose = AtomAdjust(Yap_heap_regs->atom_gc_very_verbose);
|
|
|
|
Yap_heap_regs->atom_global = AtomAdjust(Yap_heap_regs->atom_global);
|
|
|
|
Yap_heap_regs->atom_heap_used = AtomAdjust(Yap_heap_regs->atom_heap_used);
|
|
|
|
Yap_heap_regs->atom_inf = AtomAdjust(Yap_heap_regs->atom_inf);
|
|
|
|
Yap_heap_regs->atom_l_t = AtomAdjust(Yap_heap_regs->atom_l_t);
|
|
|
|
Yap_heap_regs->atom_local = AtomAdjust(Yap_heap_regs->atom_local);
|
|
|
|
Yap_heap_regs->atom_meta_call = AtomAdjust(Yap_heap_regs->atom_meta_call);
|
|
|
|
Yap_heap_regs->atom_minus = AtomAdjust(Yap_heap_regs->atom_minus);
|
|
|
|
Yap_heap_regs->atom_multi_file = AtomAdjust(Yap_heap_regs->atom_multi_file);
|
|
|
|
Yap_heap_regs->atom_nan = AtomAdjust(Yap_heap_regs->atom_nan);
|
|
|
|
Yap_heap_regs->atom_otherwise = AtomAdjust(Yap_heap_regs->atom_otherwise);
|
|
|
|
Yap_heap_regs->atom_pi = AtomAdjust(Yap_heap_regs->atom_pi);
|
|
|
|
Yap_heap_regs->atom_plus = AtomAdjust(Yap_heap_regs->atom_plus);
|
|
|
|
Yap_heap_regs->atom_portray = AtomAdjust(Yap_heap_regs->atom_portray);
|
|
|
|
Yap_heap_regs->atom_profile = AtomAdjust(Yap_heap_regs->atom_profile);
|
|
|
|
Yap_heap_regs->atom_random = AtomAdjust(Yap_heap_regs->atom_random);
|
|
|
|
Yap_heap_regs->atom_read = AtomAdjust(Yap_heap_regs->atom_read);
|
|
|
|
Yap_heap_regs->atom_repeat = AtomAdjust(Yap_heap_regs->atom_repeat);
|
|
|
|
Yap_heap_regs->atom_restore_regs = AtomAdjust(Yap_heap_regs->atom_restore_regs);
|
2002-06-04 19:21:55 +01:00
|
|
|
#if HAVE_SIGACTION
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->atom_sig_pending = AtomAdjust(Yap_heap_regs->atom_sig_pending);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->atom_stack_free = AtomAdjust(Yap_heap_regs->atom_stack_free);
|
|
|
|
Yap_heap_regs->atom_true = AtomAdjust(Yap_heap_regs->atom_true);
|
|
|
|
Yap_heap_regs->atom_user = AtomAdjust(Yap_heap_regs->atom_user);
|
|
|
|
Yap_heap_regs->atom_usr_err = AtomAdjust(Yap_heap_regs->atom_usr_err);
|
|
|
|
Yap_heap_regs->atom_usr_in = AtomAdjust(Yap_heap_regs->atom_usr_in);
|
|
|
|
Yap_heap_regs->atom_usr_out = AtomAdjust(Yap_heap_regs->atom_usr_out);
|
|
|
|
Yap_heap_regs->atom_version_number = AtomAdjust(Yap_heap_regs->atom_version_number);
|
|
|
|
Yap_heap_regs->atom_write = AtomAdjust(Yap_heap_regs->atom_write);
|
2006-01-02 02:16:19 +00:00
|
|
|
Yap_heap_regs->float_format = AtomAdjust(Yap_heap_regs->float_format);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef USE_SOCKET
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->functor_af_inet = FuncAdjust(Yap_heap_regs->functor_af_inet);
|
|
|
|
Yap_heap_regs->functor_af_local = FuncAdjust(Yap_heap_regs->functor_af_local);
|
|
|
|
Yap_heap_regs->functor_af_unix = FuncAdjust(Yap_heap_regs->functor_af_unix);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->functor_alt_not = FuncAdjust(Yap_heap_regs->functor_alt_not);
|
|
|
|
Yap_heap_regs->functor_arrow = FuncAdjust(Yap_heap_regs->functor_arrow);
|
|
|
|
Yap_heap_regs->functor_assert = FuncAdjust(Yap_heap_regs->functor_assert);
|
2005-10-28 18:38:50 +01:00
|
|
|
Yap_heap_regs->functor_at_found_one = FuncAdjust(Yap_heap_regs->functor_at_found_one);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef COROUTINING
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->functor_att_goal = FuncAdjust(Yap_heap_regs->functor_att_goal);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->functor_braces = FuncAdjust(Yap_heap_regs->functor_braces);
|
|
|
|
Yap_heap_regs->functor_call = FuncAdjust(Yap_heap_regs->functor_call);
|
|
|
|
Yap_heap_regs->functor_cut_by = FuncAdjust(Yap_heap_regs->functor_cut_by);
|
|
|
|
Yap_heap_regs->functor_comma = FuncAdjust(Yap_heap_regs->functor_comma);
|
|
|
|
Yap_heap_regs->functor_creep = FuncAdjust(Yap_heap_regs->functor_creep);
|
|
|
|
Yap_heap_regs->functor_csult = FuncAdjust(Yap_heap_regs->functor_csult);
|
|
|
|
Yap_heap_regs->functor_eq = FuncAdjust(Yap_heap_regs->functor_eq);
|
|
|
|
Yap_heap_regs->functor_execute_in_mod = FuncAdjust(Yap_heap_regs->functor_execute_in_mod);
|
|
|
|
Yap_heap_regs->functor_execute_within = FuncAdjust(Yap_heap_regs->functor_execute_within);
|
|
|
|
Yap_heap_regs->functor_g_atom = FuncAdjust(Yap_heap_regs->functor_g_atom);
|
|
|
|
Yap_heap_regs->functor_g_atomic = FuncAdjust(Yap_heap_regs->functor_g_atomic);
|
|
|
|
Yap_heap_regs->functor_g_compound = FuncAdjust(Yap_heap_regs->functor_g_compound);
|
|
|
|
Yap_heap_regs->functor_g_float = FuncAdjust(Yap_heap_regs->functor_g_float);
|
2005-10-28 18:38:50 +01:00
|
|
|
Yap_heap_regs->functor_g_format_at = FuncAdjust(Yap_heap_regs->functor_g_format_at);
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->functor_g_integer = FuncAdjust(Yap_heap_regs->functor_g_integer);
|
|
|
|
Yap_heap_regs->functor_g_number = FuncAdjust(Yap_heap_regs->functor_g_number);
|
|
|
|
Yap_heap_regs->functor_g_primitive = FuncAdjust(Yap_heap_regs->functor_g_primitive);
|
|
|
|
Yap_heap_regs->functor_g_var = FuncAdjust(Yap_heap_regs->functor_g_var);
|
|
|
|
Yap_heap_regs->functor_last_execute_within = FuncAdjust(Yap_heap_regs->functor_last_execute_within);
|
|
|
|
Yap_heap_regs->functor_list = FuncAdjust(Yap_heap_regs->functor_list);
|
|
|
|
Yap_heap_regs->functor_mega_clause = FuncAdjust(Yap_heap_regs->functor_mega_clause);
|
|
|
|
Yap_heap_regs->functor_module = FuncAdjust(Yap_heap_regs->functor_module);
|
|
|
|
Yap_heap_regs->functor_multi_file_clause = FuncAdjust(Yap_heap_regs->functor_multi_file_clause);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->functor_mutable = FuncAdjust(Yap_heap_regs->functor_mutable);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->functor_not = FuncAdjust(Yap_heap_regs->functor_not);
|
|
|
|
Yap_heap_regs->functor_or = FuncAdjust(Yap_heap_regs->functor_or);
|
|
|
|
Yap_heap_regs->functor_portray = FuncAdjust(Yap_heap_regs->functor_portray);
|
|
|
|
Yap_heap_regs->functor_query = FuncAdjust(Yap_heap_regs->functor_query);
|
|
|
|
Yap_heap_regs->functor_static_clause = FuncAdjust(Yap_heap_regs->functor_static_clause);
|
|
|
|
Yap_heap_regs->functor_stream = FuncAdjust(Yap_heap_regs->functor_stream);
|
|
|
|
Yap_heap_regs->functor_stream_pos = FuncAdjust(Yap_heap_regs->functor_stream_pos);
|
|
|
|
Yap_heap_regs->functor_stream_eOS = FuncAdjust(Yap_heap_regs->functor_stream_eOS);
|
|
|
|
Yap_heap_regs->functor_change_module = FuncAdjust(Yap_heap_regs->functor_change_module);
|
|
|
|
Yap_heap_regs->functor_current_module = FuncAdjust(Yap_heap_regs->functor_current_module);
|
|
|
|
Yap_heap_regs->functor_u_minus = FuncAdjust(Yap_heap_regs->functor_u_minus);
|
|
|
|
Yap_heap_regs->functor_u_plus = FuncAdjust(Yap_heap_regs->functor_u_plus);
|
|
|
|
Yap_heap_regs->functor_v_bar = FuncAdjust(Yap_heap_regs->functor_v_bar);
|
|
|
|
Yap_heap_regs->functor_var = FuncAdjust(Yap_heap_regs->functor_var);
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef EUROTRA
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->term_dollar_u = AtomTermAdjust(Yap_heap_regs->term_dollar_u);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
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);
|
|
|
|
if (Yap_heap_regs->file_aliases != NULL) {
|
|
|
|
Yap_heap_regs->yap_streams =
|
|
|
|
(struct stream_desc *)AddrAdjust((ADDR)Yap_heap_regs->yap_streams);
|
2002-11-11 17:38:10 +00:00
|
|
|
}
|
2004-12-02 06:06:47 +00:00
|
|
|
if (Yap_heap_regs->file_aliases != NULL) {
|
|
|
|
Yap_heap_regs->file_aliases =
|
|
|
|
(struct AliasDescS *)AddrAdjust((ADDR)Yap_heap_regs->file_aliases);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->yap_lib_dir =
|
|
|
|
(char *)AddrAdjust((ADDR)Yap_heap_regs->yap_lib_dir);
|
|
|
|
Yap_heap_regs->pred_goal_expansion =
|
|
|
|
(PredEntry *)AddrAdjust((ADDR)Yap_heap_regs->pred_goal_expansion);
|
|
|
|
Yap_heap_regs->pred_meta_call =
|
|
|
|
(PredEntry *)AddrAdjust((ADDR)Yap_heap_regs->pred_meta_call);
|
|
|
|
Yap_heap_regs->pred_dollar_catch =
|
|
|
|
(PredEntry *)AddrAdjust((ADDR)Yap_heap_regs->pred_dollar_catch);
|
|
|
|
Yap_heap_regs->pred_recorded_with_key =
|
|
|
|
(PredEntry *)AddrAdjust((ADDR)Yap_heap_regs->pred_recorded_with_key);
|
|
|
|
Yap_heap_regs->pred_log_upd_clause =
|
|
|
|
(PredEntry *)AddrAdjust((ADDR)Yap_heap_regs->pred_log_upd_clause);
|
|
|
|
Yap_heap_regs->pred_log_upd_clause0 =
|
|
|
|
(PredEntry *)AddrAdjust((ADDR)Yap_heap_regs->pred_log_upd_clause0);
|
|
|
|
Yap_heap_regs->pred_static_clause =
|
|
|
|
(PredEntry *)AddrAdjust((ADDR)Yap_heap_regs->pred_static_clause);
|
|
|
|
Yap_heap_regs->pred_throw =
|
|
|
|
(PredEntry *)AddrAdjust((ADDR)Yap_heap_regs->pred_throw);
|
|
|
|
Yap_heap_regs->pred_handle_throw =
|
|
|
|
(PredEntry *)AddrAdjust((ADDR)Yap_heap_regs->pred_handle_throw);
|
2005-11-23 03:01:33 +00:00
|
|
|
#if DEBUG
|
|
|
|
if (Yap_heap_regs->db_erased_list) {
|
|
|
|
Yap_heap_regs->db_erased_list =
|
|
|
|
PtoLUCAdjust(Yap_heap_regs->db_erased_list);
|
|
|
|
}
|
|
|
|
if (Yap_heap_regs->db_erased_ilist) {
|
|
|
|
Yap_heap_regs->db_erased_ilist =
|
|
|
|
LUIndexAdjust(Yap_heap_regs->db_erased_ilist);
|
|
|
|
}
|
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
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));
|
2005-11-23 03:01:33 +00:00
|
|
|
#if !defined(THREADS)
|
|
|
|
if (Yap_heap_regs->wl.scratchpad.ptr) {
|
|
|
|
Yap_heap_regs->wl.scratchpad.ptr =
|
|
|
|
(char *)AddrAdjust((ADDR)Yap_heap_regs->wl.scratchpad.ptr);
|
|
|
|
}
|
2006-03-06 14:04:57 +00:00
|
|
|
Yap_heap_regs->wl.gc_generation =
|
|
|
|
AbsAppl(PtoGloAdjust(RepAppl(Yap_heap_regs->wl.gc_generation)));
|
|
|
|
Yap_heap_regs->wl.gc_phase =
|
|
|
|
AbsAppl(PtoGloAdjust(RepAppl(Yap_heap_regs->wl.gc_phase)));
|
|
|
|
/* current phase is an integer */
|
2005-11-23 03:01:33 +00:00
|
|
|
#endif
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef COROUTINING
|
2004-12-02 06:06:47 +00:00
|
|
|
if (Yap_heap_regs->wake_up_code != NULL)
|
|
|
|
Yap_heap_regs->wake_up_code = (PredEntry *)PtoHeapCellAdjust((CELL *)(Yap_heap_regs->wake_up_code));
|
2004-01-23 02:23:51 +00:00
|
|
|
#if !defined(THREADS)
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->wl.atts_mutable_list =
|
|
|
|
AbsAppl(PtoGloAdjust(RepAppl(Yap_heap_regs->wl.atts_mutable_list)));
|
2005-10-28 18:38:50 +01:00
|
|
|
if (Yap_heap_regs->wl.dynamic_arrays) {
|
|
|
|
Yap_heap_regs->wl.dynamic_arrays =
|
|
|
|
PtoArrayEAdjust(Yap_heap_regs->wl.dynamic_arrays);
|
|
|
|
}
|
|
|
|
if (Yap_heap_regs->wl.static_arrays) {
|
|
|
|
Yap_heap_regs->wl.static_arrays =
|
|
|
|
PtoArraySAdjust(Yap_heap_regs->wl.static_arrays);
|
|
|
|
}
|
2004-01-23 02:23:51 +00:00
|
|
|
#endif
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-12-02 06:06:47 +00:00
|
|
|
if (Yap_heap_regs->last_wtime != NULL)
|
|
|
|
Yap_heap_regs->last_wtime = (void *)PtoHeapCellAdjust((CELL *)(Yap_heap_regs->last_wtime));
|
|
|
|
Yap_heap_regs->db_erased_marker =
|
|
|
|
DBRefAdjust(Yap_heap_regs->db_erased_marker);
|
2006-02-24 14:03:42 +00:00
|
|
|
Yap_heap_regs->logdb_erased_marker =
|
|
|
|
PtoLUCAdjust(Yap_heap_regs->logdb_erased_marker);
|
|
|
|
Yap_heap_regs->logdb_erased_marker->Id = FunctorDBRef;
|
|
|
|
Yap_heap_regs->logdb_erased_marker->ClCode->opc = Yap_opcode(_op_fail);
|
|
|
|
Yap_heap_regs->logdb_erased_marker->ClPred =
|
|
|
|
PtoPredAdjust(Yap_heap_regs->logdb_erased_marker->ClPred);
|
2004-12-02 06:06:47 +00:00
|
|
|
Yap_heap_regs->hash_chain =
|
|
|
|
(AtomHashEntry *)PtoHeapCellAdjust((CELL *)(Yap_heap_regs->hash_chain));
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
RestoreDBEntry(DBRef dbr)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_RESTORE
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, "Restoring at %x", dbr);
|
2002-06-04 19:21:55 +01:00
|
|
|
if (dbr->Flags & DBAtomic)
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, " an atomic term\n");
|
2002-06-04 19:21:55 +01:00
|
|
|
else if (dbr->Flags & DBNoVars)
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, " with no vars\n");
|
2002-06-04 19:21:55 +01:00
|
|
|
else if (dbr->Flags & DBComplex)
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, " complex term\n");
|
2002-06-04 19:21:55 +01:00
|
|
|
else if (dbr->Flags & DBIsRef)
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, " a ref\n");
|
2002-06-04 19:21:55 +01:00
|
|
|
else
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, " a var\n");
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-02-06 02:26:23 +00:00
|
|
|
RestoreDBTerm(&(dbr->DBT));
|
2005-10-19 20:00:48 +01:00
|
|
|
if (dbr->Parent) {
|
|
|
|
dbr->Parent = (DBProp)AddrAdjust((ADDR)(dbr->Parent));
|
|
|
|
}
|
2003-02-12 13:20:52 +00:00
|
|
|
if (dbr->Code != NULL)
|
|
|
|
dbr->Code = PtoOpAdjust(dbr->Code);
|
2002-06-04 19:21:55 +01:00
|
|
|
if (dbr->Prev != NULL)
|
|
|
|
dbr->Prev = DBRefAdjust(dbr->Prev);
|
|
|
|
if (dbr->Next != NULL)
|
|
|
|
dbr->Next = DBRefAdjust(dbr->Next);
|
|
|
|
#ifdef DEBUG_RESTORE2
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, "Recomputing masks\n");
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
|
|
|
recompute_mask(dbr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restores a DB structure, as it was saved in the heap */
|
|
|
|
static void
|
|
|
|
RestoreDB(DBEntry *pp)
|
|
|
|
{
|
|
|
|
register DBRef dbr;
|
|
|
|
|
|
|
|
if (pp->First != NULL)
|
|
|
|
pp->First = DBRefAdjust(pp->First);
|
|
|
|
if (pp->Last != NULL)
|
|
|
|
pp->Last = DBRefAdjust(pp->Last);
|
|
|
|
if (pp->ArityOfDB)
|
|
|
|
pp->FunctorOfDB = FuncAdjust(pp->FunctorOfDB);
|
|
|
|
else
|
|
|
|
pp->FunctorOfDB = (Functor) AtomAdjust((Atom)(pp->FunctorOfDB));
|
2006-02-24 14:03:42 +00:00
|
|
|
if (pp->F0 != NULL)
|
|
|
|
pp->F0 = DBRefAdjust(pp->F0);
|
|
|
|
if (pp->L0 != NULL)
|
|
|
|
pp->L0 = DBRefAdjust(pp->L0);
|
|
|
|
/* immediate update semantics */
|
|
|
|
dbr = pp->F0;
|
|
|
|
/* While we have something in the data base, even if erased, restore it */
|
|
|
|
while (dbr) {
|
|
|
|
RestoreDBEntry(dbr);
|
|
|
|
if (dbr->n != NULL)
|
|
|
|
dbr->n = DBRefAdjust(dbr->n);
|
|
|
|
if (dbr->p != NULL)
|
|
|
|
dbr->p = DBRefAdjust(dbr->p);
|
|
|
|
dbr = dbr->n;
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restores a group of clauses for the same predicate, starting with First
|
|
|
|
* and ending with Last, First may be equal to Last
|
|
|
|
*/
|
|
|
|
static void
|
2003-04-30 18:46:05 +01:00
|
|
|
CleanClauses(yamop *First, yamop *Last, PredEntry *pp)
|
2002-06-04 19:21:55 +01:00
|
|
|
{
|
2003-08-27 14:37:10 +01:00
|
|
|
if (pp->PredFlags & LogUpdatePredFlag) {
|
|
|
|
LogUpdClause *cl = ClauseCodeToLogUpdClause(First);
|
|
|
|
|
|
|
|
while (cl != NULL) {
|
2004-02-06 02:26:23 +00:00
|
|
|
RestoreLUClause(cl, pp);
|
2003-08-27 14:37:10 +01:00
|
|
|
cl = cl->ClNext;
|
|
|
|
}
|
2004-09-27 21:45:04 +01:00
|
|
|
} else if (pp->PredFlags & MegaClausePredFlag) {
|
|
|
|
MegaClause *cl = ClauseCodeToMegaClause(First);
|
|
|
|
|
2006-03-22 20:07:28 +00:00
|
|
|
RestoreMegaClause(cl);
|
2003-11-26 18:36:35 +00:00
|
|
|
} else if (pp->PredFlags & DynamicPredFlag) {
|
|
|
|
yamop *cl = First;
|
|
|
|
|
|
|
|
do {
|
2004-02-06 02:26:23 +00:00
|
|
|
RestoreDynamicClause(ClauseCodeToDynamicClause(cl), pp);
|
2003-11-26 18:36:35 +00:00
|
|
|
if (cl == Last) return;
|
|
|
|
cl = NextDynamicClause(cl);
|
|
|
|
} while (TRUE);
|
2003-08-27 14:37:10 +01:00
|
|
|
} else {
|
2004-02-06 02:26:23 +00:00
|
|
|
StaticClause *cl = ClauseCodeToStaticClause(First);
|
2003-08-27 14:37:10 +01:00
|
|
|
|
|
|
|
do {
|
2006-03-22 20:07:28 +00:00
|
|
|
RestoreStaticClause(cl);
|
2004-02-06 02:26:23 +00:00
|
|
|
if (cl->ClCode == Last) return;
|
|
|
|
cl = cl->ClNext;
|
2003-08-27 14:37:10 +01:00
|
|
|
} while (TRUE);
|
|
|
|
}
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-06 02:26:23 +00:00
|
|
|
|
2005-06-01 14:53:46 +01:00
|
|
|
/* Restores a DB structure, as it was saved in the heap */
|
|
|
|
static void
|
|
|
|
RestoreBB(BlackBoardEntry *pp)
|
|
|
|
{
|
|
|
|
Term t = pp->Element;
|
|
|
|
if (t) {
|
|
|
|
if (!IsVarTerm(t) && !IsAtomicTerm(t)) {
|
|
|
|
RestoreLUClause((LogUpdClause *)DBRefOfTerm(t),NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pp->KeyOfBB = AtomAdjust(pp->KeyOfBB);
|
|
|
|
}
|
|
|
|
|
2002-06-04 19:21:55 +01:00
|
|
|
static void
|
|
|
|
restore_static_array(StaticArrayEntry *ae)
|
|
|
|
{
|
|
|
|
Int sz = -ae->ArrayEArity;
|
|
|
|
switch (ae->ArrayType) {
|
|
|
|
case array_of_ints:
|
|
|
|
case array_of_doubles:
|
|
|
|
case array_of_chars:
|
|
|
|
case array_of_uchars:
|
|
|
|
return;
|
|
|
|
case array_of_ptrs:
|
|
|
|
{
|
|
|
|
AtomEntry **base = (AtomEntry **)AddrAdjust((ADDR)(ae->ValueOfVE.ptrs));
|
|
|
|
Int i;
|
|
|
|
ae->ValueOfVE.ptrs = base;
|
|
|
|
if (ae != NULL) {
|
|
|
|
for (i=0; i<sz; i++) {
|
|
|
|
AtomEntry *reg = *base;
|
|
|
|
if (reg == NULL) {
|
|
|
|
base++;
|
|
|
|
} else if (IsOldCode((CELL)reg)) {
|
|
|
|
*base++ = AtomEntryAdjust(reg);
|
|
|
|
} else if (IsOldLocalInTR((CELL)reg)) {
|
|
|
|
*base++ = (AtomEntry *)LocalAddrAdjust((ADDR)reg);
|
|
|
|
} else if (IsOldGlobal((CELL)reg)) {
|
|
|
|
*base++ = (AtomEntry *)GlobalAddrAdjust((ADDR)reg);
|
|
|
|
} else if (IsOldDelay((CELL)reg)) {
|
|
|
|
*base++ = (AtomEntry *)DelayAddrAdjust((ADDR)reg);
|
|
|
|
} else if (IsOldTrail((CELL)reg)) {
|
|
|
|
*base++ = (AtomEntry *)TrailAddrAdjust((ADDR)reg);
|
|
|
|
} else {
|
|
|
|
/* oops */
|
|
|
|
base++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case array_of_atoms:
|
|
|
|
{
|
|
|
|
Term *base = (Term *)AddrAdjust((ADDR)(ae->ValueOfVE.atoms));
|
|
|
|
Int i;
|
|
|
|
ae->ValueOfVE.atoms = base;
|
|
|
|
if (ae != 0L) {
|
|
|
|
for (i=0; i<sz; i++) {
|
|
|
|
Term reg = *base;
|
|
|
|
if (reg == 0L) {
|
|
|
|
base++;
|
|
|
|
} else {
|
|
|
|
*base++ = AtomTermAdjust(reg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case array_of_dbrefs:
|
|
|
|
{
|
|
|
|
Term *base = (Term *)AddrAdjust((ADDR)(ae->ValueOfVE.dbrefs));
|
|
|
|
Int i;
|
|
|
|
|
|
|
|
ae->ValueOfVE.dbrefs = base;
|
|
|
|
if (ae != 0L) {
|
|
|
|
for (i=0; i<sz; i++) {
|
|
|
|
Term reg = *base;
|
|
|
|
if (reg == 0L) {
|
|
|
|
base++;
|
|
|
|
} else {
|
|
|
|
*base++ = AbsAppl(PtoHeapCellAdjust(RepAppl(reg)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
2005-10-19 20:00:48 +01:00
|
|
|
case array_of_nb_terms:
|
|
|
|
{
|
|
|
|
live_term *base = (live_term *)AddrAdjust((ADDR)(ae->ValueOfVE.lterms));
|
|
|
|
Int i;
|
|
|
|
|
|
|
|
ae->ValueOfVE.lterms = base;
|
|
|
|
if (ae != 0L) {
|
|
|
|
for (i=0; i < sz; i++,base++) {
|
|
|
|
Term reg = base->tlive;
|
|
|
|
if (IsVarTerm(reg)) {
|
|
|
|
CELL *var = (CELL *)reg;
|
|
|
|
|
|
|
|
if (IsOldGlobalPtr(var)) {
|
|
|
|
base->tlive = (CELL)PtoGloAdjust(var);
|
|
|
|
} else {
|
|
|
|
base->tlive = (CELL)PtoHeapCellAdjust(var);
|
|
|
|
}
|
|
|
|
} else if (IsAtomTerm(reg)) {
|
|
|
|
base->tlive = AtomTermAdjust(reg);
|
|
|
|
} else if (IsApplTerm(reg)) {
|
|
|
|
CELL *db = RepAppl(reg);
|
|
|
|
db = PtoGloAdjust(db);
|
|
|
|
base->tlive = AbsAppl(db);
|
|
|
|
} else if (IsApplTerm(reg)) {
|
|
|
|
CELL *db = RepPair(reg);
|
|
|
|
db = PtoGloAdjust(db);
|
|
|
|
base->tlive = AbsPair(db);
|
|
|
|
}
|
|
|
|
|
|
|
|
reg = base->tstore;
|
|
|
|
if (IsVarTerm(reg)) {
|
|
|
|
base->tstore = (Term)GlobalAddrAdjust((ADDR)reg);
|
|
|
|
} else if (IsAtomTerm(reg)) {
|
|
|
|
base->tstore = AtomTermAdjust(reg);
|
|
|
|
} else {
|
|
|
|
DBTerm *db = (DBTerm *)RepAppl(reg);
|
|
|
|
db = DBTermAdjust(db);
|
|
|
|
RestoreDBTerm(db);
|
|
|
|
base->tstore = AbsAppl((CELL *)db);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-06-04 19:21:55 +01:00
|
|
|
case array_of_terms:
|
|
|
|
{
|
2003-08-27 14:37:10 +01:00
|
|
|
DBTerm **base = (DBTerm **)AddrAdjust((ADDR)(ae->ValueOfVE.terms));
|
2002-06-04 19:21:55 +01:00
|
|
|
Int i;
|
|
|
|
|
|
|
|
ae->ValueOfVE.terms = base;
|
|
|
|
if (ae != 0L) {
|
|
|
|
for (i=0; i<sz; i++) {
|
2003-08-27 14:37:10 +01:00
|
|
|
DBTerm *reg = *base;
|
2002-06-04 19:21:55 +01:00
|
|
|
if (reg == NULL) {
|
|
|
|
base++;
|
|
|
|
} else {
|
2004-02-06 02:26:23 +00:00
|
|
|
*base++ = reg = DBTermAdjust(reg);
|
2003-08-27 14:37:10 +01:00
|
|
|
RestoreDBTerm(reg);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clean all the code for a particular predicate, this can get a bit tricky,
|
|
|
|
* because of the indexing code
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
CleanCode(PredEntry *pp)
|
|
|
|
{
|
|
|
|
CELL flag;
|
|
|
|
|
|
|
|
|
|
|
|
/* Init takes care of the first 2 cases */
|
2004-02-12 17:09:17 +00:00
|
|
|
if (pp->ModuleOfPred) {
|
|
|
|
pp->ModuleOfPred = AtomTermAdjust(pp->ModuleOfPred);
|
|
|
|
}
|
2005-05-30 04:26:37 +01:00
|
|
|
if (pp->ArityOfPE) {
|
|
|
|
if (pp->ModuleOfPred == IDB_MODULE) {
|
|
|
|
if (pp->PredFlags & AtomDBPredFlag) {
|
|
|
|
pp->FunctorOfPred = (Functor)AtomAdjust((Atom)(pp->FunctorOfPred));
|
|
|
|
} else {
|
|
|
|
pp->FunctorOfPred = FuncAdjust(pp->FunctorOfPred);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pp->FunctorOfPred = FuncAdjust(pp->FunctorOfPred);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pp->FunctorOfPred = (Functor)AtomAdjust((Atom)(pp->FunctorOfPred));
|
|
|
|
}
|
2004-02-12 12:37:12 +00:00
|
|
|
if (pp->ModuleOfPred != IDB_MODULE) {
|
|
|
|
if (pp->src.OwnerFile && pp->ModuleOfPred != IDB_MODULE)
|
2003-08-27 14:37:10 +01:00
|
|
|
pp->src.OwnerFile = AtomAdjust(pp->src.OwnerFile);
|
|
|
|
}
|
2004-02-06 10:19:49 +00:00
|
|
|
if (!(pp->PredFlags & NumberDBPredFlag)) {
|
|
|
|
pp->src.OwnerFile = AtomAdjust(pp->src.OwnerFile);
|
|
|
|
}
|
2002-11-18 18:18:05 +00:00
|
|
|
pp->OpcodeOfPred = Yap_opcode(Yap_op_from_opcode(pp->OpcodeOfPred));
|
2002-12-27 16:53:09 +00:00
|
|
|
if (pp->PredFlags & (AsmPredFlag|CPredFlag)) {
|
2002-06-04 19:21:55 +01:00
|
|
|
/* assembly */
|
2002-12-27 16:53:09 +00:00
|
|
|
if (pp->CodeOfPred) {
|
|
|
|
pp->CodeOfPred = PtoOpAdjust(pp->CodeOfPred);
|
2003-04-30 18:46:05 +01:00
|
|
|
CleanClauses(pp->CodeOfPred, pp->CodeOfPred, pp);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
} else {
|
2002-12-27 16:53:09 +00:00
|
|
|
yamop *FirstC, *LastC;
|
|
|
|
/* Prolog code */
|
|
|
|
if (pp->cs.p_code.FirstClause)
|
|
|
|
pp->cs.p_code.FirstClause = PtoOpAdjust(pp->cs.p_code.FirstClause);
|
|
|
|
if (pp->cs.p_code.LastClause)
|
|
|
|
pp->cs.p_code.LastClause = PtoOpAdjust(pp->cs.p_code.LastClause);
|
|
|
|
pp->CodeOfPred =PtoOpAdjust(pp->CodeOfPred);
|
|
|
|
pp->cs.p_code.TrueCodeOfPred = PtoOpAdjust(pp->cs.p_code.TrueCodeOfPred);
|
2003-08-27 14:37:10 +01:00
|
|
|
pp->cs.p_code.ExpandCode = Yap_opcode(_expand_index);
|
2002-06-04 19:21:55 +01:00
|
|
|
if (pp->NextPredOfModule)
|
|
|
|
pp->NextPredOfModule = PtoPredAdjust(pp->NextPredOfModule);
|
|
|
|
flag = pp->PredFlags;
|
2002-12-27 16:53:09 +00:00
|
|
|
FirstC = pp->cs.p_code.FirstClause;
|
|
|
|
LastC = pp->cs.p_code.LastClause;
|
2002-06-04 19:21:55 +01:00
|
|
|
/* We just have a fail here */
|
2004-02-06 10:19:49 +00:00
|
|
|
if (FirstC == NULL && LastC == NULL) {
|
2002-06-04 19:21:55 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#ifdef DEBUG_RESTORE2
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, "at %ux Correcting clauses from %p to %p\n", *(OPCODE *) FirstC, FirstC, LastC);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2003-04-30 18:46:05 +01:00
|
|
|
CleanClauses(FirstC, LastC, pp);
|
2004-02-06 02:26:23 +00:00
|
|
|
if (flag & IndexedPredFlag) {
|
|
|
|
#ifdef DEBUG_RESTORE2
|
|
|
|
fprintf(stderr, "Correcting indexed code\n");
|
|
|
|
#endif
|
|
|
|
if (flag & LogUpdatePredFlag) {
|
|
|
|
CleanLUIndex(ClauseCodeToLogUpdIndex(pp->cs.p_code.TrueCodeOfPred));
|
|
|
|
} else {
|
|
|
|
CleanSIndex(ClauseCodeToStaticIndex(pp->cs.p_code.TrueCodeOfPred));
|
|
|
|
}
|
|
|
|
} else if (flag & DynamicPredFlag) {
|
2002-06-04 19:21:55 +01:00
|
|
|
#ifdef DEBUG_RESTORE2
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, "Correcting dynamic code\n");
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
2004-02-06 02:26:23 +00:00
|
|
|
RestoreDynamicClause(ClauseCodeToDynamicClause(pp->cs.p_code.TrueCodeOfPred),pp);
|
2002-06-04 19:21:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* we are pointing at ourselves */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restores all of the entries, for a particular atom, we only have problems
|
|
|
|
* if we find code or data bases
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
RestoreEntries(PropEntry *pp)
|
|
|
|
{
|
|
|
|
while (!EndOfPAEntr(pp)) {
|
|
|
|
switch(pp->KindOfPE) {
|
|
|
|
case FunctorProperty:
|
|
|
|
{
|
|
|
|
FunctorEntry *fe = (FunctorEntry *)pp;
|
|
|
|
Prop p0;
|
|
|
|
fe->NextOfPE =
|
|
|
|
PropAdjust(fe->NextOfPE);
|
|
|
|
fe->NameOfFE =
|
|
|
|
AtomAdjust(fe->NameOfFE);
|
|
|
|
p0 = fe->PropsOfFE =
|
|
|
|
PropAdjust(fe->PropsOfFE);
|
|
|
|
while (!EndOfPAEntr(p0)) {
|
|
|
|
CleanCode(RepPredProp(p0));
|
|
|
|
p0 = RepPredProp(p0)->NextOfPE =
|
|
|
|
PropAdjust(RepPredProp(p0)->NextOfPE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ValProperty:
|
|
|
|
{
|
|
|
|
ValEntry *ve = (ValEntry *)pp;
|
|
|
|
Term tv = ve->ValueOfVE;
|
|
|
|
ve->NextOfPE =
|
|
|
|
PropAdjust(ve->NextOfPE);
|
|
|
|
if (IsAtomTerm(tv))
|
|
|
|
ve->ValueOfVE = AtomTermAdjust(tv);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ArrayProperty:
|
|
|
|
{
|
|
|
|
ArrayEntry *ae = (ArrayEntry *)pp;
|
|
|
|
ae->NextOfPE =
|
|
|
|
PropAdjust(ae->NextOfPE);
|
|
|
|
if (ae->ArrayEArity < 0) {
|
2005-10-28 18:38:50 +01:00
|
|
|
/* static array entry */
|
|
|
|
StaticArrayEntry *sae = (StaticArrayEntry *)ae;
|
|
|
|
if (sae->NextAE)
|
|
|
|
sae->NextAE = PtoArraySAdjust(sae->NextAE);
|
|
|
|
restore_static_array(sae);
|
2002-06-04 19:21:55 +01:00
|
|
|
} else {
|
2005-10-28 18:38:50 +01:00
|
|
|
if (ae->NextAE)
|
|
|
|
ae->NextAE = PtoArrayEAdjust(ae->NextAE);
|
2002-06-04 19:21:55 +01:00
|
|
|
if (IsVarTerm(ae->ValueOfVE))
|
|
|
|
RESET_VARIABLE(&(ae->ValueOfVE));
|
|
|
|
else {
|
|
|
|
CELL *ptr = RepAppl(ae->ValueOfVE);
|
|
|
|
/* in fact it should just be a pointer to the global,
|
|
|
|
but we'll be conservative.
|
|
|
|
Notice that the variable should have been reset in restore_program mode.
|
|
|
|
*/
|
|
|
|
if (IsOldGlobalPtr(ptr)) {
|
|
|
|
ae->ValueOfVE = AbsAppl(PtoGloAdjust(ptr));
|
|
|
|
} else if (IsOldCodeCellPtr(ptr)) {
|
|
|
|
ae->ValueOfVE = AbsAppl(PtoHeapCellAdjust(ptr));
|
|
|
|
} else if (IsOldLocalInTRPtr(ptr)) {
|
|
|
|
ae->ValueOfVE = AbsAppl(PtoLocAdjust(ptr));
|
|
|
|
} else if (IsOldDelayPtr(ptr)) {
|
|
|
|
ae->ValueOfVE = AbsAppl(PtoDelayAdjust(ptr));
|
|
|
|
} else if (IsOldTrailPtr(ptr)) {
|
|
|
|
ae->ValueOfVE = AbsAppl(CellPtoTRAdjust(ptr));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PEProp:
|
|
|
|
{
|
|
|
|
PredEntry *pe = (PredEntry *) pp;
|
|
|
|
pe->NextOfPE =
|
|
|
|
PropAdjust(pe->NextOfPE);
|
|
|
|
CleanCode(pe);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DBProperty:
|
|
|
|
case CodeDBProperty:
|
|
|
|
#ifdef DEBUG_RESTORE2
|
2004-02-06 02:26:23 +00:00
|
|
|
fprintf(stderr, "Correcting data base clause at %p\n", pp);
|
2002-06-04 19:21:55 +01:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
DBEntry *de = (DBEntry *) pp;
|
|
|
|
de->NextOfPE =
|
|
|
|
PropAdjust(de->NextOfPE);
|
|
|
|
if (HDiff)
|
|
|
|
RestoreDB(de);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BBProperty:
|
|
|
|
{
|
|
|
|
BlackBoardEntry *bb = (BlackBoardEntry *) pp;
|
|
|
|
bb->NextOfPE =
|
|
|
|
PropAdjust(bb->NextOfPE);
|
|
|
|
if (HDiff)
|
|
|
|
RestoreBB(bb);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OpProperty:
|
2005-10-21 17:09:03 +01:00
|
|
|
{
|
|
|
|
OpEntry *opp = (OpEntry *)pp;
|
|
|
|
if (opp->OpModule) {
|
|
|
|
opp->OpModule = AtomTermAdjust(opp->OpModule);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case ExpProperty:
|
2002-06-04 19:21:55 +01:00
|
|
|
case ModProperty:
|
|
|
|
pp->NextOfPE =
|
|
|
|
PropAdjust(pp->NextOfPE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* OOPS */
|
2002-11-18 18:18:05 +00:00
|
|
|
Yap_Error(SYSTEM_ERROR, TermNil,
|
2002-06-04 19:21:55 +01:00
|
|
|
"Invalid Atom Property %d at %p", pp->KindOfPE, pp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pp = RepProp(pp->NextOfPE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|