From af931c6e6df9c5cdd6d106868f7a1ee8670e1c93 Mon Sep 17 00:00:00 2001 From: vsc Date: Tue, 4 Jan 2005 02:50:23 +0000 Subject: [PATCH] - allow MegaClauses with blobs - change Diffs to be thread specific - include Christian's updates git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1222 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/agc.c | 4 - C/cdmgr.c | 38 +- C/compiler.c | 9 +- C/computils.c | 9 +- C/grow.c | 15 - C/heapgc.c | 4 +- C/init.c | 8 + H/Heap.h | 61 ++- H/rclause.h | 1014 ++++++++++++++++++++++++++++++++++++++++++++++++ H/rheap.h | 961 +-------------------------------------------- Makefile.in | 1 + m4/Yap.h.m4 | 4 +- m4/sshift.h.m4 | 15 - 13 files changed, 1138 insertions(+), 1005 deletions(-) create mode 100644 H/rclause.h diff --git a/C/agc.c b/C/agc.c index dfc518caa..189392a9c 100644 --- a/C/agc.c +++ b/C/agc.c @@ -96,10 +96,6 @@ AtomAdjust(Atom a) return(a); } -#define HDiff TRUE - -#define OldHeapTop HeapTop - #define IsOldCode(P) FALSE #define IsOldCodeCellPtr(P) FALSE #define IsOldDelay(P) FALSE diff --git a/C/cdmgr.c b/C/cdmgr.c index 0a7ee124a..bc8de7847 100644 --- a/C/cdmgr.c +++ b/C/cdmgr.c @@ -11,8 +11,12 @@ * File: cdmgr.c * * comments: Code manager * * * -* Last rev: $Date: 2004-12-28 22:20:35 $,$Author: vsc $ * +* Last rev: $Date: 2005-01-04 02:50:21 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.147 2004/12/28 22:20:35 vsc +* some extra bug fixes for trail overflows: some cannot be recovered that easily, +* some can. +* * Revision 1.146 2004/12/20 21:44:57 vsc * more fixes to CLPBN * fix some Yap overflows. @@ -336,6 +340,26 @@ static_in_use(PredEntry *p, int check_everything) ******************************************************************/ +#define PtoPredAdjust(X) (X) +#define PtoOpAdjust(X) (X) +#define XAdjust(X) (X) +#define YAdjust(X) (X) +#define AtomTermAdjust(X) (X) +#define CellPtoHeapAdjust(X) (X) +#define FuncAdjust(X) (X) +#define CodeAddrAdjust(X) (X) +#define rehash(A,B,C) +static Term BlobTermAdjust(Term t) +{ +#if TAGS_FAST_OPS + return t-ClDiff; +#else + return t+ClDiff; +#endif +} + +#include "rclause.h" + void Yap_BuildMegaClause(PredEntry *ap) { @@ -366,12 +390,16 @@ Yap_BuildMegaClause(PredEntry *ap) has_blobs |= (cl->ClFlags & HasBlobsMask); cl = cl->ClNext; } + if (ap->cs.p_code.NOfClauses > 1000000) { + extern long long int vsc_count; + vsc_count++; + } /* ok, we got the chance for a mega clause */ if (has_blobs) { sz -= sizeof(StaticClause); - return; - } else + } else { sz -= (UInt)NEXTOP((yamop *)NULL,e) + sizeof(StaticClause); + } required = sz*ap->cs.p_code.NOfClauses+sizeof(MegaClause)+(UInt)NEXTOP((yamop *)NULL,e); while (!(mcl = (MegaClause *)Yap_AllocCodeSpace(required))) { if (!Yap_growheap(FALSE, sizeof(consult_obj)*ConsultCapacity, NULL)) { @@ -389,6 +417,10 @@ Yap_BuildMegaClause(PredEntry *ap) ptr = mcl->ClCode; while (TRUE) { memcpy((void *)ptr, (void *)cl->ClCode, sz); + if (has_blobs) { + ClDiff = (char *)(ptr)-(char *)cl->ClCode; + restore_opcodes(ptr); + } ptr = (yamop *)((char *)ptr + sz); if (cl->ClCode == ap->cs.p_code.LastClause) break; diff --git a/C/compiler.c b/C/compiler.c index e3ce3818c..04c446c18 100644 --- a/C/compiler.c +++ b/C/compiler.c @@ -11,8 +11,11 @@ * File: compiler.c * * comments: Clause compiler * * * -* Last rev: $Date: 2005-01-03 17:06:03 $,$Author: vsc $ * +* Last rev: $Date: 2005-01-04 02:50:21 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.58 2005/01/03 17:06:03 vsc +* fix discontiguous stack overflows in parser +* * Revision 1.57 2004/12/20 21:44:57 vsc * more fixes to CLPBN * fix some Yap overflows. @@ -358,10 +361,10 @@ optimize_ce(Term t, unsigned int arity, unsigned int level, compiler_struct *cgl if (IsApplTerm(t) && IsExtensionFunctor(FunctorOfTerm(t))) return (t); while (p != NULL) { - CELL *OldH = H; + CELL *oldH = H; H = (CELL *)cglobs->cint.freep; cmp = Yap_compare_terms(t, (p->TermOfCE)); - H = OldH; + H = oldH; if (cmp > 0) { parent = p; diff --git a/C/computils.c b/C/computils.c index 1faf0d572..4ced7ad75 100644 --- a/C/computils.c +++ b/C/computils.c @@ -11,8 +11,11 @@ * File: computils.c * * comments: some useful routines for YAP's compiler * * * -* Last rev: $Date: 2004-11-19 17:14:13 $ * +* Last rev: $Date: 2005-01-04 02:50:21 $ * * $Log: not supported by cvs2svn $ +* Revision 1.25 2004/11/19 17:14:13 vsc +* a few fixes for 64 bit compiling. +* * Revision 1.24 2004/04/16 19:27:31 vsc * more bug fixes * @@ -672,7 +675,7 @@ static char *opformat[] = void Yap_ShowCode (struct intermediates *cint) { - CELL *OldH = H; + CELL *oldH = H; struct PSEUDO *cpc; cpc = cint->CodeStart; @@ -686,7 +689,7 @@ Yap_ShowCode (struct intermediates *cint) cpc = cpc->nextInst; } Yap_DebugPutc (Yap_c_error_stream,'\n'); - H = OldH; + H = oldH; } #endif /* DEBUG */ diff --git a/C/grow.c b/C/grow.c index 49b107a9d..9aa69eb3f 100644 --- a/C/grow.c +++ b/C/grow.c @@ -83,21 +83,6 @@ cpcellsd(register CELL *Dest, register CELL *Org, CELL NOf) } -/* The old stack pointers */ -CELL *OldASP, *OldLCL0; -tr_fr_ptr OldTR; -CELL *OldGlobalBase, *OldH, *OldH0; -ADDR OldTrailBase, OldTrailTop; -ADDR OldHeapBase, OldHeapTop; - -Int - GDiff, - HDiff, - LDiff, - TrDiff, - XDiff, - DelayDiff; - static void SetHeapRegs(void) { diff --git a/C/heapgc.c b/C/heapgc.c index 986a2163e..60beb30aa 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -100,7 +100,7 @@ static void gc_growtrail(int committed) { #if USE_SYSTEM_MALLOC - TR = Yap_old_TR; + TR = OldTR; #endif if (!Yap_growtrail(64 * 1024L, TRUE)) { /* could not find more trail */ @@ -3438,7 +3438,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop) #endif /* get the number of active registers */ YAPEnterCriticalSection(); - Yap_old_TR = (struct trail_frame *)(old_TR = TR); + OldTR = (tr_fr_ptr)(old_TR = TR); push_registers(predarity, nextop); marking_phase(old_TR, current_env, nextop, max); m_time = Yap_cputime(); diff --git a/C/init.c b/C/init.c index 7075bb430..50bba5293 100644 --- a/C/init.c +++ b/C/init.c @@ -78,9 +78,14 @@ ADDR Yap_HeapBase; #ifdef THREADS +struct restore_info rinfo[MAX_WORKERS]; + struct thread_globs Yap_thread_gl[MAX_WORKERS]; #else + +struct restore_info rinfo; + ADDR Yap_HeapBase, Yap_LocalBase, Yap_GlobalBase, @@ -105,6 +110,9 @@ jmp_buf Yap_CompilerBotch; /************ variables concerned with Error Handling *************/ sigjmp_buf Yap_RestartEnv; /* used to restart after an abort execution */ +/******** whether Yap is responsible for signal handling******************/ +int Yap_PrologShouldHandleInterrupts; + /********* IO support *****/ /********* parsing ********************************************/ diff --git a/H/Heap.h b/H/Heap.h index be4b5e124..f97a4823d 100644 --- a/H/Heap.h +++ b/H/Heap.h @@ -10,7 +10,7 @@ * File: Heap.h * * mods: * * comments: Heap Init Structure * -* version: $Id: Heap.h,v 1.76 2004-12-28 22:20:36 vsc Exp $ * +* version: $Id: Heap.h,v 1.77 2005-01-04 02:50:21 vsc Exp $ * *************************************************************************/ /* information that can be stored in Code Space */ @@ -44,6 +44,27 @@ typedef struct scratch_block_struct { UInt sz, msz; } scratch_block; +typedef struct restore_info { + int cl_diff, + g_diff, + h_diff, + l_diff, + tr_diff, + x_diff, + delay_diff; + CELL *old_ASP, *old_LCL0; + tr_fr_ptr old_TR; + CELL *old_GlobalBase, *old_H, *old_H0; + ADDR old_TrailBase, old_TrailTop; + ADDR old_HeapBase, old_HeapTop; +} restoreinfo; + +#if THREADS +extern struct restore_info rinfo[MAX_WORKERS]; +#else +extern struct restore_info rinfo; +#endif + typedef struct worker_local_struct { char *scanner_stack; struct scanner_extra_alloc *scanner_extra_blocks; @@ -68,7 +89,6 @@ typedef struct worker_local_struct { Int tot_gc_time; /* total time spent in GC */ Int tot_gc_recovered; /* number of heap objects in all garbage collections */ jmp_buf gc_restore; /* where to jump if garbage collection crashes */ - struct trail_frame *old_TR; yamop trust_lu_code[3]; } worker_local; @@ -671,6 +691,24 @@ struct various_codes *Yap_heap_regs; #define WakeUpCode Yap_heap_regs->wake_up_code #endif #if defined(YAPOR) || defined(THREADS) +/* The old stack pointers */ +#define OldASP rinfo[worker_id].old_ASP +#define OldLCL0 rinfo[worker_id].old_LCL0 +#define OldTR rinfo[worker_id].old_TR +#define OldGlobalBase rinfo[worker_id].old_GlobalBase +#define OldH rinfo[worker_id].old_H +#define OldH0 rinfo[worker_id].old_H0 +#define OldTrailBase rinfo[worker_id].old_TrailBase +#define OldTrailTop rinfo[worker_id].old_TrailTop +#define OldHeapBase rinfo[worker_id].old_HeapBase +#define OldHeapTop rinfo[worker_id].old_HeapTop +#define ClDiff rinfo[worker_id].cl_diff +#define GDiff rinfo[worker_id].g_diff +#define HDiff rinfo[worker_id].h_diff +#define LDiff rinfo[worker_id].l_diff +#define TrDiff rinfo[worker_id].tr_diff +#define XDiff rinfo[worker_id].x_diff +#define DelayDiff rinfo[worker_id].delay_diff #define ScannerStack Yap_heap_regs->wl[worker_id].scanner_stack #define ScannerExtraAlloc Yap_heap_regs->wl[worker_id].scanner_extra_alloc #define SignalLock Yap_heap_regs->wl[worker_id].signal_lock @@ -691,9 +729,25 @@ struct various_codes *Yap_heap_regs; #define TotGcTime Yap_heap_regs->wl[worker_id].tot_gc_time #define TotGcRecovered Yap_heap_regs->wl[worker_id].tot_gc_recovered #define Yap_gc_restore Yap_heap_regs->wl[worker_id].gc_restore -#define Yap_old_TR Yap_heap_regs->wl[worker_id].old_TR #define TrustLUCode Yap_heap_regs->wl[worker_id].trust_lu_code #else +#define OldASP rinfo.old_ASP +#define OldLCL0 rinfo.old_LCL0 +#define OldTR rinfo.old_TR +#define OldGlobalBase rinfo.old_GlobalBase +#define OldH rinfo.old_H +#define OldH0 rinfo.old_H0 +#define OldTrailBase rinfo.old_TrailBase +#define OldTrailTop rinfo.old_TrailTop +#define OldHeapBase rinfo.old_HeapBase +#define OldHeapTop rinfo.old_HeapTop +#define ClDiff rinfo.cl_diff +#define GDiff rinfo.g_diff +#define HDiff rinfo.h_diff +#define LDiff rinfo.l_diff +#define TrDiff rinfo.tr_diff +#define XDiff rinfo.x_diff +#define DelayDiff rinfo.delay_diff #define ScannerStack Yap_heap_regs->wl.scanner_stack #define ScannerExtraBlocks Yap_heap_regs->wl.scanner_extra_blocks #define ActiveSignals Yap_heap_regs->wl.active_signals @@ -712,7 +766,6 @@ struct various_codes *Yap_heap_regs; #define TotGcTime Yap_heap_regs->wl.tot_gc_time #define TotGcRecovered Yap_heap_regs->wl.tot_gc_recovered #define Yap_gc_restore Yap_heap_regs->wl.gc_restore -#define Yap_old_TR Yap_heap_regs->wl.old_TR #define TrustLUCode Yap_heap_regs->wl.trust_lu_code #endif #define profiling Yap_heap_regs->compiler_profiling diff --git a/H/rclause.h b/H/rclause.h new file mode 100644 index 000000000..863f23cbe --- /dev/null +++ b/H/rclause.h @@ -0,0 +1,1014 @@ + +/************************************************************************* +* * +* YAP Prolog * +* * +* Yap Prolog was developed at NCCUP - Universidade do Porto * +* * +* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * +* * +************************************************************************** +* * +* File: rclause.h * +* comments: walk through a clause * +* * +* Last rev: $Date: 2005-01-04 02:50:21 $,$Author: vsc $ * +* $Log: not supported by cvs2svn $ +* 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. +* +* Revision 1.46 2004/11/23 21:16:21 vsc +* A few extra fixes for saved states. +* +* Revision 1.45 2004/10/26 20:16:18 vsc +* More bug fixes for overflow handling +* +* 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 +* +* 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 +* +* Revision 1.42 2004/06/05 03:37:00 vsc +* coroutining is now a part of attvars. +* some more fixes. +* +* Revision 1.41 2004/04/29 03:45:50 vsc +* fix garbage collection in execute_tail +* +* Revision 1.40 2004/03/31 01:03:10 vsc +* support expand group of clauses +* +* 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. +* * +* * +*************************************************************************/ + +static void +restore_opcodes(yamop *pc) +{ + do { + op_numbers op = Yap_op_from_opcode(pc->opc); + pc->opc = Yap_opcode(op); +#ifdef DEBUG_RESTORE2 + fprintf(stderr, "%s ", op_names[op]); +#endif + switch (op) { + case _Nstop: + Yap_Error(SYSTEM_ERROR, TermNil, + "Invalid Opcode found while restoring %p", pc); + return; + case _Ystop: +#ifdef DEBUG_RESTORE2 + fprintf(stderr, "OK\n"); +#endif + return; + /* instructions type ld */ + case _try_me: + case _retry_me: + case _trust_me: + case _profiled_retry_me: + case _profiled_trust_me: + case _count_retry_me: + case _count_trust_me: + case _try_me0: + case _retry_me0: + case _trust_me0: + case _try_me1: + case _retry_me1: + case _trust_me1: + case _try_me2: + case _retry_me2: + case _trust_me2: + case _try_me3: + case _retry_me3: + case _trust_me3: + case _try_me4: + case _retry_me4: + case _trust_me4: + case _spy_or_trymark: + case _try_and_mark: + case _profiled_retry_and_mark: + case _count_retry_and_mark: + case _retry_and_mark: + case _try_clause: + case _retry: + case _trust: +#ifdef YAPOR + case _getwork: + case _getwork_seq: + case _sync: +#endif +#ifdef TABLING + case _table_try_single: + case _table_try_me: + case _table_retry_me: + case _table_trust_me: + case _table_try: + case _table_retry: + case _table_trust: + case _table_answer_resolution: + case _table_completion: +#endif /* TABLING */ + pc->u.ld.p = PtoPredAdjust(pc->u.ld.p); + pc->u.ld.d = PtoOpAdjust(pc->u.ld.d); + pc = NEXTOP(pc,ld); + break; + case _enter_lu_pred: + case _stale_lu_index: + pc->u.Ill.I = (LogUpdIndex *)PtoOpAdjust((yamop *)(pc->u.Ill.I)); + pc->u.Ill.l1 = PtoOpAdjust(pc->u.Ill.l1); + pc->u.Ill.l2 = PtoOpAdjust(pc->u.Ill.l2); + pc = pc->u.Ill.l1; + break; + /* instructions type p */ +#if !defined(YAPOR) + case _or_last: +#endif + case _enter_profiling: + case _retry_profiled: + case _lock_lu: + case _count_call: + case _count_retry: + case _execute: + pc->u.p.p = PtoPredAdjust(pc->u.p.p); + pc = NEXTOP(pc,p); + break; + case _trust_logical_pred: + case _dexecute: + case _jump: + case _move_back: + case _skip: + case _jump_if_var: + case _try_in: + case _try_clause2: + case _try_clause3: + case _try_clause4: + case _retry2: + case _retry3: + case _retry4: + pc->u.l.l = PtoOpAdjust(pc->u.l.l); + pc = NEXTOP(pc,l); + break; + /* instructions type EC */ + case _jump_if_nonvar: + pc->u.xl.l = PtoOpAdjust(pc->u.xl.l); + pc->u.xl.x = XAdjust(pc->u.xl.x); + pc = NEXTOP(pc,xl); + break; + /* instructions type EC */ + case _alloc_for_logical_pred: + pc->u.EC.ClBase = PtoOpAdjust(pc->u.EC.ClBase); + pc = NEXTOP(pc,EC); + break; + /* instructions type e */ + case _unify_idb_term: + case _copy_idb_term: + /* don't need no _Ystop to know we're done */ + return; + case _trust_fail: + case _op_fail: + case _cut: + case _cut_t: + case _cut_e: + case _procceed: + case _allocate: + case _deallocate: + case _write_void: + case _write_list: + case _write_l_list: + case _pop: + case _index_pred: +#if THREADS + case _thread_local: +#endif + case _expand_index: + case _undef_p: + case _spy_pred: + case _p_equal: + case _p_dif: + case _p_eq: + case _p_functor: + case _enter_a_profiling: + case _count_a_call: + case _index_dbref: + case _index_blob: + case _unlock_lu: +#ifdef YAPOR + case _getwork_first_time: +#endif +#ifdef TABLING + case _trie_do_var: + case _trie_trust_var: + case _trie_try_var: + case _trie_retry_var: + case _trie_do_val: + case _trie_trust_val: + case _trie_try_val: + case _trie_retry_val: + case _trie_do_atom: + case _trie_trust_atom: + case _trie_try_atom: + case _trie_retry_atom: + case _trie_do_list: + case _trie_trust_list: + case _trie_try_list: + case _trie_retry_list: + case _trie_do_struct: + case _trie_trust_struct: + case _trie_try_struct: + case _trie_retry_struct: +#endif /* TABLING */ +#ifdef TABLING_INNER_CUTS + case _clause_with_cut: +#endif /* TABLING_INNER_CUTS */ + pc = NEXTOP(pc,e); + break; + /* instructions type x */ + case _save_b_x: + case _commit_b_x: + case _get_list: + case _put_list: + case _write_x_var: + case _write_x_val: + case _write_x_loc: + pc->u.x.x = XAdjust(pc->u.x.x); + pc = NEXTOP(pc,x); + break; + /* instructions type xF */ + case _p_atom_x: + case _p_atomic_x: + case _p_integer_x: + case _p_nonvar_x: + case _p_number_x: + case _p_var_x: + case _p_db_ref_x: + case _p_primitive_x: + case _p_compound_x: + case _p_float_x: + case _p_cut_by_x: + pc->u.xF.x = XAdjust(pc->u.xF.x); + pc->u.xF.F = PtoOpAdjust(pc->u.xF.F); + pc = NEXTOP(pc,xF); + break; + case _expand_clauses: + Yap_Error(SYSTEM_ERROR, TermNil, + "Invalid Opcode expand_clauses at %p", pc); + break; + /* instructions type y */ + case _save_b_y: + case _commit_b_y: + case _write_y_var: + case _write_y_val: + case _write_y_loc: + pc->u.y.y = YAdjust(pc->u.y.y); + pc = NEXTOP(pc,y); + break; + /* instructions type yF */ + case _p_atom_y: + case _p_atomic_y: + case _p_integer_y: + case _p_nonvar_y: + case _p_number_y: + case _p_var_y: + case _p_db_ref_y: + case _p_primitive_y: + case _p_compound_y: + case _p_float_y: + case _p_cut_by_y: + pc->u.yF.y = YAdjust(pc->u.yF.y); + pc->u.yF.F = PtoOpAdjust(pc->u.yF.F); + pc = NEXTOP(pc,yF); + break; + /* instructions type sla */ + case _p_execute_tail: + case _p_execute: + pc->u.sla.sla_u.p = PtoPredAdjust(pc->u.sla.sla_u.p); + if (pc->u.sla.sla_u.mod != 0) { + pc->u.sla.sla_u.mod = AtomTermAdjust(pc->u.sla.sla_u.mod); + } + pc->u.sla.p0 = PtoPredAdjust(pc->u.sla.p0); + if (pc->u.sla.bmap != NULL) { + pc->u.sla.bmap = CellPtoHeapAdjust(pc->u.sla.bmap); + } + pc = NEXTOP(pc,sla); + break; + case _fcall: + case _call: +#ifdef YAPOR + case _or_last: +#endif + pc->u.sla.sla_u.p = PtoPredAdjust(pc->u.sla.sla_u.p); + if (pc->u.sla.bmap != NULL) { + pc->u.sla.bmap = CellPtoHeapAdjust(pc->u.sla.bmap); + } + pc->u.sla.p0 = PtoPredAdjust(pc->u.sla.p0); + pc = NEXTOP(pc,sla); + break; + /* instructions type sla, but for disjunctions */ + case _either: + case _or_else: + if (pc->u.sla.bmap != NULL) { + pc->u.sla.bmap = CellPtoHeapAdjust(pc->u.sla.bmap); + } + pc->u.sla.sla_u.l = PtoOpAdjust(pc->u.sla.sla_u.l); + pc->u.sla.p0 = PtoPredAdjust(pc->u.sla.p0); + pc = NEXTOP(pc,sla); + break; + /* instructions type sla, but for functions */ + case _call_cpred: + case _call_usercpred: + pc->u.sla.sla_u.p = PtoPredAdjust(pc->u.sla.sla_u.p); + pc->u.sla.p0 = PtoPredAdjust(pc->u.sla.p0); + if (pc->u.sla.bmap != NULL) { + pc->u.sla.bmap = CellPtoHeapAdjust(pc->u.sla.bmap); + } + pc = NEXTOP(pc,sla); + break; + /* instructions type xx */ + case _get_x_var: + case _get_x_val: + case _glist_valx: + case _gl_void_varx: + case _gl_void_valx: + case _put_x_var: + case _put_x_val: + pc->u.xx.xr = XAdjust(pc->u.xx.xr); + pc->u.xx.xl = XAdjust(pc->u.xx.xl); + pc = NEXTOP(pc,xx); + break; + /* instructions type yx */ + case _get_y_var: + case _get_y_val: + case _put_y_var: + case _put_y_val: + case _put_unsafe: + pc->u.yx.x = XAdjust(pc->u.yx.x); + pc->u.yx.y = YAdjust(pc->u.yx.y); + pc = NEXTOP(pc,yx); + break; + /* instructions type xc */ + case _get_atom: + case _put_atom: + case _get_float: + case _get_longint: + case _get_bigint: + pc->u.xc.x = XAdjust(pc->u.xc.x); + { + Term t = pc->u.xc.c; + if (IsAtomTerm(t)) + pc->u.xc.c = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.xc.c = BlobTermAdjust(t); + } + pc = NEXTOP(pc,xc); + break; + /* instructions type cc */ + case _get_2atoms: + { + Term t = pc->u.cc.c1; + if (IsAtomTerm(t)) + pc->u.cc.c1 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.cc.c1 = BlobTermAdjust(t); + } + { + Term t = pc->u.cc.c2; + if (IsAtomTerm(t)) + pc->u.cc.c2 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.cc.c2 = BlobTermAdjust(t); + } + pc = NEXTOP(pc,cc); + break; + /* instructions type ccc */ + case _get_3atoms: + { + Term t = pc->u.ccc.c1; + if (IsAtomTerm(t)) + pc->u.ccc.c1 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.ccc.c1 = BlobTermAdjust(t); + } + { + Term t = pc->u.ccc.c2; + if (IsAtomTerm(t)) + pc->u.ccc.c2 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.ccc.c2 = BlobTermAdjust(t); + } + { + Term t = pc->u.ccc.c3; + if (IsAtomTerm(t)) + pc->u.ccc.c3 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.ccc.c3 = BlobTermAdjust(t); + } + pc = NEXTOP(pc,ccc); + break; + /* instructions type cccc */ + case _get_4atoms: + { + Term t = pc->u.cccc.c1; + if (IsAtomTerm(t)) + pc->u.cccc.c1 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.cccc.c1 = BlobTermAdjust(t); + } + { + Term t = pc->u.cccc.c2; + if (IsAtomTerm(t)) + pc->u.cccc.c2 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.cccc.c2 = BlobTermAdjust(t); + } + { + Term t = pc->u.cccc.c3; + if (IsAtomTerm(t)) + pc->u.cccc.c3 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.cccc.c3 = BlobTermAdjust(t); + } + { + Term t = pc->u.cccc.c4; + if (IsAtomTerm(t)) + pc->u.cccc.c4 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.cccc.c4 = BlobTermAdjust(t); + } + pc = NEXTOP(pc,cccc); + break; + /* instructions type ccccc */ + case _get_5atoms: + { + Term t = pc->u.ccccc.c1; + if (IsAtomTerm(t)) + pc->u.ccccc.c1 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.ccccc.c1 = BlobTermAdjust(t); + } + { + Term t = pc->u.ccccc.c2; + if (IsAtomTerm(t)) + pc->u.ccccc.c2 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.ccccc.c2 = BlobTermAdjust(t); + } + { + Term t = pc->u.ccccc.c3; + if (IsAtomTerm(t)) + pc->u.ccccc.c3 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.ccccc.c3 = BlobTermAdjust(t); + } + { + Term t = pc->u.ccccc.c4; + if (IsAtomTerm(t)) + pc->u.ccccc.c4 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.ccccc.c4 = BlobTermAdjust(t); + } + { + Term t = pc->u.ccccc.c5; + if (IsAtomTerm(t)) + pc->u.ccccc.c5 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.ccccc.c5 = BlobTermAdjust(t); + } + pc = NEXTOP(pc,ccccc); + break; + /* instructions type cccccc */ + case _get_6atoms: + { + Term t = pc->u.cccccc.c1; + if (IsAtomTerm(t)) + pc->u.cccccc.c1 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.cccccc.c1 = BlobTermAdjust(t); + } + { + Term t = pc->u.cccccc.c2; + if (IsAtomTerm(t)) + pc->u.cccccc.c2 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.cccccc.c2 = BlobTermAdjust(t); + } + { + Term t = pc->u.cccccc.c3; + if (IsAtomTerm(t)) + pc->u.cccccc.c3 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.cccccc.c3 = BlobTermAdjust(t); + } + { + Term t = pc->u.cccccc.c4; + if (IsAtomTerm(t)) + pc->u.cccccc.c4 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.cccccc.c4 = BlobTermAdjust(t); + } + { + Term t = pc->u.cccccc.c5; + if (IsAtomTerm(t)) + pc->u.cccccc.c5 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.cccccc.c5 = BlobTermAdjust(t); + } + { + Term t = pc->u.cccccc.c6; + if (IsAtomTerm(t)) + pc->u.cccccc.c6 = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.cccccc.c6 = BlobTermAdjust(t); + } + pc = NEXTOP(pc,cccccc); + break; + /* instructions type xf */ + case _get_struct: + case _put_struct: + pc->u.xf.x = XAdjust(pc->u.xf.x); + pc->u.xf.f = FuncAdjust(pc->u.xf.f); + pc = NEXTOP(pc,xf); + break; + /* instructions type xy */ + case _glist_valy: + case _gl_void_vary: + case _gl_void_valy: + pc->u.xy.x = XAdjust(pc->u.xy.x); + pc->u.xy.y = YAdjust(pc->u.xy.y); + pc = NEXTOP(pc,xy); + break; + /* instructions type ox */ + case _unify_x_var: + case _unify_x_var_write: + case _unify_l_x_var: + case _unify_l_x_var_write: + case _unify_x_val_write: + case _unify_x_val: + case _unify_l_x_val_write: + case _unify_l_x_val: + case _unify_x_loc_write: + case _unify_x_loc: + case _unify_l_x_loc_write: + case _unify_l_x_loc: + case _save_pair_x_write: + case _save_pair_x: + case _save_appl_x_write: + case _save_appl_x: + pc->u.ox.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.ox.opcw)); + pc->u.ox.x = XAdjust(pc->u.ox.x); + pc = NEXTOP(pc,ox); + break; + /* instructions type oxx */ + case _unify_x_var2: + case _unify_x_var2_write: + case _unify_l_x_var2: + case _unify_l_x_var2_write: + pc->u.oxx.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.oxx.opcw)); + pc->u.oxx.xl = XAdjust(pc->u.oxx.xl); + pc->u.oxx.xr = XAdjust(pc->u.oxx.xr); + pc = NEXTOP(pc,oxx); + break; + /* instructions type oy */ + case _unify_y_var: + case _unify_y_var_write: + case _unify_l_y_var: + case _unify_l_y_var_write: + case _unify_y_val_write: + case _unify_y_val: + case _unify_l_y_val_write: + case _unify_l_y_val: + case _unify_y_loc_write: + case _unify_y_loc: + case _unify_l_y_loc_write: + case _unify_l_y_loc: + case _save_pair_y_write: + case _save_pair_y: + case _save_appl_y_write: + case _save_appl_y: + pc->u.oy.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.oy.opcw)); + pc->u.oy.y = YAdjust(pc->u.oy.y); + pc = NEXTOP(pc,oy); + break; + /* instructions type o */ + case _unify_void_write: + case _unify_void: + case _unify_l_void_write: + case _unify_l_void: + case _unify_list_write: + case _unify_list: + case _unify_l_list_write: + case _unify_l_list: + pc->u.o.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.o.opcw)); + pc = NEXTOP(pc,o); + break; + /* instructions type os */ + case _unify_n_voids_write: + case _unify_n_voids: + case _unify_l_n_voids_write: + case _unify_l_n_voids: + pc->u.os.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.os.opcw)); + pc = NEXTOP(pc,os); + break; + /* instructions type oc */ + case _unify_atom_write: + case _unify_atom: + case _unify_l_atom_write: + case _unify_l_atom: + case _unify_float: + case _unify_l_float: + case _unify_longint: + case _unify_l_longint: + case _unify_bigint: + case _unify_l_bigint: + pc->u.oc.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.oc.opcw)); + { + Term t = pc->u.oc.c; + if (IsAtomTerm(t)) + pc->u.oc.c = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.oc.c = BlobTermAdjust(t); + } + pc = NEXTOP(pc,oc); + break; + /* instructions type osc */ + case _unify_n_atoms_write: + case _unify_n_atoms: + pc->u.osc.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.osc.opcw)); + { + Term t = pc->u.osc.c; + if (IsAtomTerm(t)) + pc->u.osc.c = AtomTermAdjust(t); + } + pc = NEXTOP(pc,osc); + break; + /* instructions type of */ + case _unify_struct_write: + case _unify_struct: + case _unify_l_struc_write: + case _unify_l_struc: + pc->u.of.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.of.opcw)); + pc->u.of.f = FuncAdjust(pc->u.of.f); + pc = NEXTOP(pc,of); + break; + /* instructions type s */ + case _write_n_voids: + case _pop_n: +#ifdef TABLING + case _table_new_answer: +#endif /* TABLING */ + pc = NEXTOP(pc,s); + break; + /* instructions type c */ + case _write_atom: + { + Term t = pc->u.c.c; + if (IsAtomTerm(t)) + pc->u.c.c = AtomTermAdjust(t); + else if (IsApplTerm(t)) + pc->u.c.c = BlobTermAdjust(t); + } + pc = NEXTOP(pc,c); + break; + /* instructions type sc */ + case _write_n_atoms: + { + Term t = pc->u.sc.c; + if (IsAtomTerm(t)) + pc->u.sc.c = AtomTermAdjust(t); + } + pc = NEXTOP(pc,sc); + break; + /* instructions type f */ + case _write_struct: + case _write_l_struc: + pc->u.f.f = FuncAdjust(pc->u.f.f); + pc = NEXTOP(pc,f); + break; + /* instructions type sdl */ + case _call_c_wfail: + pc->u.sdl.p = PtoPredAdjust(pc->u.sdl.p); + pc->u.sdl.l = PtoOpAdjust(pc->u.sdl.l); + pc = NEXTOP(pc,sdl); + break; + /* instructions type lds */ + case _try_c: + case _try_userc: + /* don't need to do no nothing here, initstaff will do it for us + */ + pc->u.lds.p = PtoPredAdjust(pc->u.lds.p); + pc = NEXTOP(pc,lds); + break; + case _retry_c: + case _retry_userc: + /* don't need to do no nothing here, initstaff will do it for us + pc->u.lds.d = CCodeAdjust(pc->u.lds.d); */ + pc->u.lds.p = PtoPredAdjust(pc->u.lds.p); + pc = NEXTOP(pc,lds); + break; + /* instructions type llll */ + case _switch_on_type: + pc->u.llll.l1 = PtoOpAdjust(pc->u.llll.l1); + pc->u.llll.l2 = PtoOpAdjust(pc->u.llll.l2); + pc->u.llll.l3 = PtoOpAdjust(pc->u.llll.l3); + pc->u.llll.l4 = PtoOpAdjust(pc->u.llll.l4); + pc = NEXTOP(pc,llll); + break; + /* instructions type xllll */ + case _switch_list_nl: + pc->u.ollll.pop = Yap_opcode(Yap_op_from_opcode(pc->u.ollll.pop)); + pc->u.ollll.l1 = PtoOpAdjust(pc->u.llll.l1); + pc->u.ollll.l2 = PtoOpAdjust(pc->u.llll.l2); + pc->u.ollll.l3 = PtoOpAdjust(pc->u.llll.l3); + pc->u.ollll.l4 = PtoOpAdjust(pc->u.llll.l4); + pc = NEXTOP(pc,ollll); + break; + /* instructions type xllll */ + case _switch_on_arg_type: + pc->u.xllll.x = XAdjust(pc->u.xllll.x); + pc->u.xllll.l1 = PtoOpAdjust(pc->u.xllll.l1); + pc->u.xllll.l2 = PtoOpAdjust(pc->u.xllll.l2); + pc->u.xllll.l3 = PtoOpAdjust(pc->u.xllll.l3); + pc->u.xllll.l4 = PtoOpAdjust(pc->u.xllll.l4); + pc = NEXTOP(pc,xllll); + break; + /* instructions type sllll */ + case _switch_on_sub_arg_type: + pc->u.sllll.l1 = PtoOpAdjust(pc->u.sllll.l1); + pc->u.sllll.l2 = PtoOpAdjust(pc->u.sllll.l2); + pc->u.sllll.l3 = PtoOpAdjust(pc->u.sllll.l3); + pc->u.sllll.l4 = PtoOpAdjust(pc->u.sllll.l4); + pc = NEXTOP(pc,sllll); + break; + /* instructions type lll */ + case _if_not_then: + { + Term t = pc->u.clll.c; + if (IsAtomTerm(t)) + pc->u.clll.c = AtomTermAdjust(t); + } + pc->u.clll.l1 = PtoOpAdjust(pc->u.clll.l1); + pc->u.clll.l2 = PtoOpAdjust(pc->u.clll.l2); + pc->u.clll.l3 = PtoOpAdjust(pc->u.clll.l3); + pc = NEXTOP(pc,clll); + break; + /* switch_on_func */ + case _switch_on_func: + { + int i, j; + CELL *oldcode, *startcode; + + i = pc->u.sssl.s; + startcode = oldcode = (CELL *)(pc->u.sssl.l = PtoOpAdjust(pc->u.sssl.l)); + for (j = 0; j < i; j++) { + Functor oldfunc = (Functor)(oldcode[0]); + CODEADDR oldjmp = (CODEADDR)(oldcode[1]); + if (oldfunc != NULL) { + oldcode[0] = (CELL)FuncAdjust(oldfunc); + } + oldcode[1] = (CELL)CodeAddrAdjust(oldjmp); + oldcode += 2; + } + rehash(startcode, i, Funcs); + pc = NEXTOP(pc,sssl); + } + break; + /* switch_on_cons */ + case _switch_on_cons: + { + int i, j; + CELL *oldcode; +#if !USE_OFFSETS + CELL *startcode; +#endif + + i = pc->u.sssl.s; +#if !USE_OFFSETS + startcode = +#endif + oldcode = (CELL *)(pc->u.sssl.l = PtoOpAdjust(pc->u.sssl.l)); + for (j = 0; j < i; j++) { + Term oldcons = oldcode[0]; + CODEADDR oldjmp = (CODEADDR)(oldcode[1]); + if (oldcons != 0x0 && IsAtomTerm(oldcons)) { + oldcode[0] = AtomTermAdjust(oldcons); + } + oldcode[1] = (CELL)CodeAddrAdjust(oldjmp); + oldcode += 2; + } +#if !USE_OFFSETS + rehash(startcode, i, Atomics); +#endif + pc = NEXTOP(pc,sssl); + } + break; + case _go_on_func: + { + CELL *oldcode = (CELL *)(pc->u.sssl.l = PtoOpAdjust(pc->u.sssl.l)); + Functor oldfunc = (Functor)(oldcode[0]); + + oldcode[0] = (CELL)FuncAdjust(oldfunc); + oldcode[1] = (CELL)CodeAddrAdjust((CODEADDR)oldcode[1]); + oldcode[3] = (CELL)CodeAddrAdjust((CODEADDR)oldcode[3]); + } + pc = NEXTOP(pc,sssl); + break; + case _go_on_cons: + { + CELL *oldcode = (CELL *)(pc->u.sssl.l = PtoOpAdjust(pc->u.sssl.l)); + Term oldcons = oldcode[0]; + + if (IsAtomTerm(oldcons)) { + oldcode[0] = AtomTermAdjust(oldcons); + } + oldcode[1] = (CELL)CodeAddrAdjust((CODEADDR)oldcode[1]); + oldcode[3] = (CELL)CodeAddrAdjust((CODEADDR)oldcode[3]); + } + pc = NEXTOP(pc,sssl); + break; + case _if_func: + { + CELL *oldcode = (CELL *)(pc->u.sssl.l = PtoOpAdjust(pc->u.sssl.l)); + Int j; + + for (j = 0; j < pc->u.sssl.s; j++) { + Functor oldfunc = (Functor)(oldcode[0]); + CODEADDR oldjmp = (CODEADDR)(oldcode[1]); + oldcode[0] = (CELL)FuncAdjust(oldfunc); + oldcode[1] = (CELL)CodeAddrAdjust(oldjmp); + oldcode += 2; + } + /* adjust fail code */ + oldcode[1] = (CELL)CodeAddrAdjust((CODEADDR)oldcode[1]); + } + pc = NEXTOP(pc,sssl); + break; + case _if_cons: + { + CELL *oldcode = (CELL *)(pc->u.sssl.l = PtoOpAdjust(pc->u.sssl.l)); + Int j; + + for (j = 0; j < pc->u.sssl.s; j++) { + Term oldcons = oldcode[0]; + CODEADDR oldjmp = (CODEADDR)(oldcode[1]); + if (IsAtomTerm(oldcons)) { + oldcode[0] = (CELL)AtomTermAdjust(oldcons); + } + oldcode[1] = (CELL)CodeAddrAdjust(oldjmp); + oldcode += 2; + } + /* adjust fail code */ + oldcode[1] = (CELL)CodeAddrAdjust((CODEADDR)oldcode[1]); + } + pc = NEXTOP(pc,sssl); + break; + /* instructions type xxx */ + case _p_plus_vv: + case _p_minus_vv: + case _p_times_vv: + case _p_div_vv: + case _p_and_vv: + case _p_or_vv: + case _p_sll_vv: + case _p_slr_vv: + case _p_arg_vv: + case _p_func2s_vv: + case _p_func2f_xx: + pc->u.xxx.x = XAdjust(pc->u.xxx.x); + pc->u.xxx.x1 = XAdjust(pc->u.xxx.x1); + pc->u.xxx.x2 = XAdjust(pc->u.xxx.x2); + pc = NEXTOP(pc,xxx); + break; + /* instructions type xxc */ + case _p_plus_vc: + case _p_minus_cv: + case _p_times_vc: + case _p_div_cv: + case _p_and_vc: + case _p_or_vc: + case _p_sll_vc: + case _p_slr_vc: + case _p_func2s_vc: + pc->u.xxc.x = XAdjust(pc->u.xxc.x); + pc->u.xxc.xi = XAdjust(pc->u.xxc.xi); + pc = NEXTOP(pc,xxc); + break; + case _p_div_vc: + case _p_sll_cv: + case _p_slr_cv: + case _p_arg_cv: + pc->u.xcx.x = XAdjust(pc->u.xcx.x); + pc->u.xcx.xi = XAdjust(pc->u.xcx.xi); + pc = NEXTOP(pc,xcx); + break; + case _p_func2s_cv: + pc->u.xcx.x = XAdjust(pc->u.xcx.x); + if (IsAtomTerm(pc->u.xcx.c)) + pc->u.xcx.c = AtomTermAdjust(pc->u.xcx.c); + pc->u.xcx.xi = XAdjust(pc->u.xcx.xi); + pc = NEXTOP(pc,xcx); + break; + /* instructions type xyx */ + case _p_func2f_xy: + pc->u.xyx.x = XAdjust(pc->u.xyx.x); + pc->u.xyx.x1 = XAdjust(pc->u.xyx.x1); + pc->u.xyx.y2 = YAdjust(pc->u.xyx.y2); + pc = NEXTOP(pc,xyx); + break; + /* instructions type yxx */ + case _p_plus_y_vv: + case _p_minus_y_vv: + case _p_times_y_vv: + case _p_div_y_vv: + case _p_and_y_vv: + case _p_or_y_vv: + case _p_sll_y_vv: + case _p_slr_y_vv: + case _p_arg_y_vv: + case _p_func2s_y_vv: + case _p_func2f_yx: + pc->u.yxx.y = YAdjust(pc->u.yxx.y); + pc->u.yxx.x1 = XAdjust(pc->u.yxx.x1); + pc->u.yxx.x2 = XAdjust(pc->u.yxx.x2); + pc = NEXTOP(pc,yxx); + break; + /* instructions type yyx */ + case _p_func2f_yy: + pc->u.yyx.y1 = YAdjust(pc->u.yyx.y1); + pc->u.yyx.y2 = YAdjust(pc->u.yyx.y2); + pc->u.yyx.x = XAdjust(pc->u.yyx.x); + pc = NEXTOP(pc,yyx); + break; + /* instructions type yxc */ + case _p_plus_y_vc: + case _p_minus_y_cv: + case _p_times_y_vc: + case _p_div_y_vc: + case _p_div_y_cv: + case _p_and_y_vc: + case _p_or_y_vc: + case _p_sll_y_vc: + case _p_slr_y_vc: + case _p_func2s_y_vc: + pc->u.yxc.y = YAdjust(pc->u.yxc.y); + pc->u.yxc.xi = XAdjust(pc->u.yxc.xi); + pc = NEXTOP(pc,yxc); + break; + /* instructions type ycx */ + case _p_sll_y_cv: + case _p_slr_y_cv: + case _p_arg_y_cv: + pc->u.ycx.y = YAdjust(pc->u.ycx.y); + pc->u.ycx.xi = XAdjust(pc->u.ycx.xi); + pc = NEXTOP(pc,ycx); + break; + /* instructions type ycx */ + case _p_func2s_y_cv: + pc->u.ycx.y = YAdjust(pc->u.ycx.y); + if (IsAtomTerm(pc->u.ycx.c)) + pc->u.ycx.c = AtomTermAdjust(pc->u.ycx.c); + pc->u.ycx.xi = XAdjust(pc->u.ycx.xi); + pc = NEXTOP(pc,ycx); + break; + /* instructions type llxx */ + case _call_bfunc_xx: + pc->u.llxx.p = PtoPredAdjust(pc->u.llxx.p); + pc->u.llxx.f = PtoOpAdjust(pc->u.llxx.f); + pc->u.llxx.x1 = XAdjust(pc->u.llxx.x1); + pc->u.llxx.x2 = XAdjust(pc->u.llxx.x2); + pc = NEXTOP(pc,llxx); + break; + /* instructions type llxy */ + case _call_bfunc_yx: + case _call_bfunc_xy: + pc->u.llxy.p = PtoPredAdjust(pc->u.llxy.p); + pc->u.llxy.f = PtoOpAdjust(pc->u.llxy.f); + pc->u.llxy.x = XAdjust(pc->u.llxy.x); + pc->u.llxy.y = YAdjust(pc->u.llxy.y); + pc = NEXTOP(pc,llxy); + break; + case _call_bfunc_yy: + pc->u.llyy.p = PtoPredAdjust(pc->u.llyy.p); + pc->u.llyy.f = PtoOpAdjust(pc->u.llxy.f); + pc->u.llyy.y1 = YAdjust(pc->u.llyy.y1); + pc->u.llyy.y2 = YAdjust(pc->u.llyy.y2); + pc = NEXTOP(pc,llyy); + break; + } + } while (TRUE); +} + diff --git a/H/rheap.h b/H/rheap.h index 33c17f4a7..801b6e4a8 100644 --- a/H/rheap.h +++ b/H/rheap.h @@ -11,8 +11,13 @@ * File: rheap.h * * comments: walk through heap code * * * -* Last rev: $Date: 2004-12-02 06:06:47 $,$Author: vsc $ * +* Last rev: $Date: 2005-01-04 02:50:21 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* 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. +* * Revision 1.46 2004/11/23 21:16:21 vsc * A few extra fixes for saved states. * @@ -585,959 +590,7 @@ RestoreBB(BlackBoardEntry *pp) pp->KeyOfBB = AtomAdjust(pp->KeyOfBB); } -static void -restore_opcodes(yamop *pc) -{ - do { - op_numbers op = Yap_op_from_opcode(pc->opc); - pc->opc = Yap_opcode(op); -#ifdef DEBUG_RESTORE2 - fprintf(stderr, "%s ", op_names[op]); -#endif - switch (op) { - case _Nstop: - Yap_Error(SYSTEM_ERROR, TermNil, - "Invalid Opcode found while restoring %p", pc); - return; - case _Ystop: -#ifdef DEBUG_RESTORE2 - fprintf(stderr, "OK\n"); -#endif - return; - /* instructions type ld */ - case _try_me: - case _retry_me: - case _trust_me: - case _profiled_retry_me: - case _profiled_trust_me: - case _count_retry_me: - case _count_trust_me: - case _try_me0: - case _retry_me0: - case _trust_me0: - case _try_me1: - case _retry_me1: - case _trust_me1: - case _try_me2: - case _retry_me2: - case _trust_me2: - case _try_me3: - case _retry_me3: - case _trust_me3: - case _try_me4: - case _retry_me4: - case _trust_me4: - case _spy_or_trymark: - case _try_and_mark: - case _profiled_retry_and_mark: - case _count_retry_and_mark: - case _retry_and_mark: - case _try_clause: - case _retry: - case _trust: -#ifdef YAPOR - case _getwork: - case _getwork_seq: - case _sync: -#endif -#ifdef TABLING - case _table_try_single: - case _table_try_me: - case _table_retry_me: - case _table_trust_me: - case _table_try: - case _table_retry: - case _table_trust: - case _table_answer_resolution: - case _table_completion: -#endif /* TABLING */ - pc->u.ld.p = PtoPredAdjust(pc->u.ld.p); - pc->u.ld.d = PtoOpAdjust(pc->u.ld.d); - pc = NEXTOP(pc,ld); - break; - case _enter_lu_pred: - case _stale_lu_index: - pc->u.Ill.I = (LogUpdIndex *)PtoOpAdjust((yamop *)(pc->u.Ill.I)); - pc->u.Ill.l1 = PtoOpAdjust(pc->u.Ill.l1); - pc->u.Ill.l2 = PtoOpAdjust(pc->u.Ill.l2); - pc = pc->u.Ill.l1; - break; - /* instructions type p */ -#if !defined(YAPOR) - case _or_last: -#endif - case _enter_profiling: - case _retry_profiled: - case _lock_lu: - case _count_call: - case _count_retry: - case _execute: - pc->u.p.p = PtoPredAdjust(pc->u.p.p); - pc = NEXTOP(pc,p); - break; - case _trust_logical_pred: - case _dexecute: - case _jump: - case _move_back: - case _skip: - case _jump_if_var: - case _try_in: - case _try_clause2: - case _try_clause3: - case _try_clause4: - case _retry2: - case _retry3: - case _retry4: - pc->u.l.l = PtoOpAdjust(pc->u.l.l); - pc = NEXTOP(pc,l); - break; - /* instructions type EC */ - case _jump_if_nonvar: - pc->u.xl.l = PtoOpAdjust(pc->u.xl.l); - pc->u.xl.x = XAdjust(pc->u.xl.x); - pc = NEXTOP(pc,xl); - break; - /* instructions type EC */ - case _alloc_for_logical_pred: - pc->u.EC.ClBase = PtoOpAdjust(pc->u.EC.ClBase); - pc = NEXTOP(pc,EC); - break; - /* instructions type e */ - case _unify_idb_term: - case _copy_idb_term: - /* don't need no _Ystop to know we're done */ - return; - case _trust_fail: - case _op_fail: - case _cut: - case _cut_t: - case _cut_e: - case _procceed: - case _allocate: - case _deallocate: - case _write_void: - case _write_list: - case _write_l_list: - case _pop: - case _index_pred: -#if THREADS - case _thread_local: -#endif - case _expand_index: - case _undef_p: - case _spy_pred: - case _p_equal: - case _p_dif: - case _p_eq: - case _p_functor: - case _enter_a_profiling: - case _count_a_call: - case _index_dbref: - case _index_blob: - case _unlock_lu: -#ifdef YAPOR - case _getwork_first_time: -#endif -#ifdef TABLING - case _trie_do_var: - case _trie_trust_var: - case _trie_try_var: - case _trie_retry_var: - case _trie_do_val: - case _trie_trust_val: - case _trie_try_val: - case _trie_retry_val: - case _trie_do_atom: - case _trie_trust_atom: - case _trie_try_atom: - case _trie_retry_atom: - case _trie_do_list: - case _trie_trust_list: - case _trie_try_list: - case _trie_retry_list: - case _trie_do_struct: - case _trie_trust_struct: - case _trie_try_struct: - case _trie_retry_struct: -#endif /* TABLING */ -#ifdef TABLING_INNER_CUTS - case _clause_with_cut: -#endif /* TABLING_INNER_CUTS */ - pc = NEXTOP(pc,e); - break; - /* instructions type x */ - case _save_b_x: - case _commit_b_x: - case _get_list: - case _put_list: - case _write_x_var: - case _write_x_val: - case _write_x_loc: - pc->u.x.x = XAdjust(pc->u.x.x); - pc = NEXTOP(pc,x); - break; - /* instructions type xF */ - case _p_atom_x: - case _p_atomic_x: - case _p_integer_x: - case _p_nonvar_x: - case _p_number_x: - case _p_var_x: - case _p_db_ref_x: - case _p_primitive_x: - case _p_compound_x: - case _p_float_x: - case _p_cut_by_x: - pc->u.xF.x = XAdjust(pc->u.xF.x); - pc->u.xF.F = PtoOpAdjust(pc->u.xF.F); - pc = NEXTOP(pc,xF); - break; - case _expand_clauses: - Yap_Error(SYSTEM_ERROR, TermNil, - "Invalid Opcode expand_clauses at %p", pc); - break; - /* instructions type y */ - case _save_b_y: - case _commit_b_y: - case _write_y_var: - case _write_y_val: - case _write_y_loc: - pc->u.y.y = YAdjust(pc->u.y.y); - pc = NEXTOP(pc,y); - break; - /* instructions type yF */ - case _p_atom_y: - case _p_atomic_y: - case _p_integer_y: - case _p_nonvar_y: - case _p_number_y: - case _p_var_y: - case _p_db_ref_y: - case _p_primitive_y: - case _p_compound_y: - case _p_float_y: - case _p_cut_by_y: - pc->u.yF.y = YAdjust(pc->u.yF.y); - pc->u.yF.F = PtoOpAdjust(pc->u.yF.F); - pc = NEXTOP(pc,yF); - break; - /* instructions type sla */ - case _p_execute_tail: - case _p_execute: - pc->u.sla.sla_u.p = PtoPredAdjust(pc->u.sla.sla_u.p); - if (pc->u.sla.sla_u.mod != 0) { - pc->u.sla.sla_u.mod = AtomTermAdjust(pc->u.sla.sla_u.mod); - } - pc->u.sla.p0 = PtoPredAdjust(pc->u.sla.p0); - if (pc->u.sla.bmap != NULL) { - pc->u.sla.bmap = CellPtoHeapAdjust(pc->u.sla.bmap); - } - pc = NEXTOP(pc,sla); - break; - case _fcall: - case _call: -#ifdef YAPOR - case _or_last: -#endif - pc->u.sla.sla_u.p = PtoPredAdjust(pc->u.sla.sla_u.p); - if (pc->u.sla.bmap != NULL) { - pc->u.sla.bmap = CellPtoHeapAdjust(pc->u.sla.bmap); - } - pc->u.sla.p0 = PtoPredAdjust(pc->u.sla.p0); - pc = NEXTOP(pc,sla); - break; - /* instructions type sla, but for disjunctions */ - case _either: - case _or_else: - if (pc->u.sla.bmap != NULL) { - pc->u.sla.bmap = CellPtoHeapAdjust(pc->u.sla.bmap); - } - pc->u.sla.sla_u.l = PtoOpAdjust(pc->u.sla.sla_u.l); - pc->u.sla.p0 = PtoPredAdjust(pc->u.sla.p0); - pc = NEXTOP(pc,sla); - break; - /* instructions type sla, but for functions */ - case _call_cpred: - case _call_usercpred: - pc->u.sla.sla_u.p = PtoPredAdjust(pc->u.sla.sla_u.p); - pc->u.sla.p0 = PtoPredAdjust(pc->u.sla.p0); - if (pc->u.sla.bmap != NULL) { - pc->u.sla.bmap = CellPtoHeapAdjust(pc->u.sla.bmap); - } - pc = NEXTOP(pc,sla); - break; - /* instructions type xx */ - case _get_x_var: - case _get_x_val: - case _glist_valx: - case _gl_void_varx: - case _gl_void_valx: - case _put_x_var: - case _put_x_val: - pc->u.xx.xr = XAdjust(pc->u.xx.xr); - pc->u.xx.xl = XAdjust(pc->u.xx.xl); - pc = NEXTOP(pc,xx); - break; - /* instructions type yx */ - case _get_y_var: - case _get_y_val: - case _put_y_var: - case _put_y_val: - case _put_unsafe: - pc->u.yx.x = XAdjust(pc->u.yx.x); - pc->u.yx.y = YAdjust(pc->u.yx.y); - pc = NEXTOP(pc,yx); - break; - /* instructions type xc */ - case _get_atom: - case _put_atom: - case _get_float: - case _get_longint: - case _get_bigint: - pc->u.xc.x = XAdjust(pc->u.xc.x); - { - Term t = pc->u.xc.c; - if (IsAtomTerm(t)) - pc->u.xc.c = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.xc.c = BlobTermAdjust(t); - } - pc = NEXTOP(pc,xc); - break; - /* instructions type cc */ - case _get_2atoms: - { - Term t = pc->u.cc.c1; - if (IsAtomTerm(t)) - pc->u.cc.c1 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.cc.c1 = BlobTermAdjust(t); - } - { - Term t = pc->u.cc.c2; - if (IsAtomTerm(t)) - pc->u.cc.c2 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.cc.c2 = BlobTermAdjust(t); - } - pc = NEXTOP(pc,cc); - break; - /* instructions type ccc */ - case _get_3atoms: - { - Term t = pc->u.ccc.c1; - if (IsAtomTerm(t)) - pc->u.ccc.c1 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.ccc.c1 = BlobTermAdjust(t); - } - { - Term t = pc->u.ccc.c2; - if (IsAtomTerm(t)) - pc->u.ccc.c2 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.ccc.c2 = BlobTermAdjust(t); - } - { - Term t = pc->u.ccc.c3; - if (IsAtomTerm(t)) - pc->u.ccc.c3 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.ccc.c3 = BlobTermAdjust(t); - } - pc = NEXTOP(pc,ccc); - break; - /* instructions type cccc */ - case _get_4atoms: - { - Term t = pc->u.cccc.c1; - if (IsAtomTerm(t)) - pc->u.cccc.c1 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.cccc.c1 = BlobTermAdjust(t); - } - { - Term t = pc->u.cccc.c2; - if (IsAtomTerm(t)) - pc->u.cccc.c2 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.cccc.c2 = BlobTermAdjust(t); - } - { - Term t = pc->u.cccc.c3; - if (IsAtomTerm(t)) - pc->u.cccc.c3 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.cccc.c3 = BlobTermAdjust(t); - } - { - Term t = pc->u.cccc.c4; - if (IsAtomTerm(t)) - pc->u.cccc.c4 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.cccc.c4 = BlobTermAdjust(t); - } - pc = NEXTOP(pc,cccc); - break; - /* instructions type ccccc */ - case _get_5atoms: - { - Term t = pc->u.ccccc.c1; - if (IsAtomTerm(t)) - pc->u.ccccc.c1 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.ccccc.c1 = BlobTermAdjust(t); - } - { - Term t = pc->u.ccccc.c2; - if (IsAtomTerm(t)) - pc->u.ccccc.c2 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.ccccc.c2 = BlobTermAdjust(t); - } - { - Term t = pc->u.ccccc.c3; - if (IsAtomTerm(t)) - pc->u.ccccc.c3 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.ccccc.c3 = BlobTermAdjust(t); - } - { - Term t = pc->u.ccccc.c4; - if (IsAtomTerm(t)) - pc->u.ccccc.c4 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.ccccc.c4 = BlobTermAdjust(t); - } - { - Term t = pc->u.ccccc.c5; - if (IsAtomTerm(t)) - pc->u.ccccc.c5 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.ccccc.c5 = BlobTermAdjust(t); - } - pc = NEXTOP(pc,ccccc); - break; - /* instructions type cccccc */ - case _get_6atoms: - { - Term t = pc->u.cccccc.c1; - if (IsAtomTerm(t)) - pc->u.cccccc.c1 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.cccccc.c1 = BlobTermAdjust(t); - } - { - Term t = pc->u.cccccc.c2; - if (IsAtomTerm(t)) - pc->u.cccccc.c2 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.cccccc.c2 = BlobTermAdjust(t); - } - { - Term t = pc->u.cccccc.c3; - if (IsAtomTerm(t)) - pc->u.cccccc.c3 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.cccccc.c3 = BlobTermAdjust(t); - } - { - Term t = pc->u.cccccc.c4; - if (IsAtomTerm(t)) - pc->u.cccccc.c4 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.cccccc.c4 = BlobTermAdjust(t); - } - { - Term t = pc->u.cccccc.c5; - if (IsAtomTerm(t)) - pc->u.cccccc.c5 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.cccccc.c5 = BlobTermAdjust(t); - } - { - Term t = pc->u.cccccc.c6; - if (IsAtomTerm(t)) - pc->u.cccccc.c6 = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.cccccc.c6 = BlobTermAdjust(t); - } - pc = NEXTOP(pc,cccccc); - break; - /* instructions type xf */ - case _get_struct: - case _put_struct: - pc->u.xf.x = XAdjust(pc->u.xf.x); - pc->u.xf.f = FuncAdjust(pc->u.xf.f); - pc = NEXTOP(pc,xf); - break; - /* instructions type xy */ - case _glist_valy: - case _gl_void_vary: - case _gl_void_valy: - pc->u.xy.x = XAdjust(pc->u.xy.x); - pc->u.xy.y = YAdjust(pc->u.xy.y); - pc = NEXTOP(pc,xy); - break; - /* instructions type ox */ - case _unify_x_var: - case _unify_x_var_write: - case _unify_l_x_var: - case _unify_l_x_var_write: - case _unify_x_val_write: - case _unify_x_val: - case _unify_l_x_val_write: - case _unify_l_x_val: - case _unify_x_loc_write: - case _unify_x_loc: - case _unify_l_x_loc_write: - case _unify_l_x_loc: - case _save_pair_x_write: - case _save_pair_x: - case _save_appl_x_write: - case _save_appl_x: - pc->u.ox.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.ox.opcw)); - pc->u.ox.x = XAdjust(pc->u.ox.x); - pc = NEXTOP(pc,ox); - break; - /* instructions type oxx */ - case _unify_x_var2: - case _unify_x_var2_write: - case _unify_l_x_var2: - case _unify_l_x_var2_write: - pc->u.oxx.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.oxx.opcw)); - pc->u.oxx.xl = XAdjust(pc->u.oxx.xl); - pc->u.oxx.xr = XAdjust(pc->u.oxx.xr); - pc = NEXTOP(pc,oxx); - break; - /* instructions type oy */ - case _unify_y_var: - case _unify_y_var_write: - case _unify_l_y_var: - case _unify_l_y_var_write: - case _unify_y_val_write: - case _unify_y_val: - case _unify_l_y_val_write: - case _unify_l_y_val: - case _unify_y_loc_write: - case _unify_y_loc: - case _unify_l_y_loc_write: - case _unify_l_y_loc: - case _save_pair_y_write: - case _save_pair_y: - case _save_appl_y_write: - case _save_appl_y: - pc->u.oy.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.oy.opcw)); - pc->u.oy.y = YAdjust(pc->u.oy.y); - pc = NEXTOP(pc,oy); - break; - /* instructions type o */ - case _unify_void_write: - case _unify_void: - case _unify_l_void_write: - case _unify_l_void: - case _unify_list_write: - case _unify_list: - case _unify_l_list_write: - case _unify_l_list: - pc->u.o.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.o.opcw)); - pc = NEXTOP(pc,o); - break; - /* instructions type os */ - case _unify_n_voids_write: - case _unify_n_voids: - case _unify_l_n_voids_write: - case _unify_l_n_voids: - pc->u.os.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.os.opcw)); - pc = NEXTOP(pc,os); - break; - /* instructions type oc */ - case _unify_atom_write: - case _unify_atom: - case _unify_l_atom_write: - case _unify_l_atom: - case _unify_float: - case _unify_l_float: - case _unify_longint: - case _unify_l_longint: - case _unify_bigint: - case _unify_l_bigint: - pc->u.oc.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.oc.opcw)); - { - Term t = pc->u.oc.c; - if (IsAtomTerm(t)) - pc->u.oc.c = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.oc.c = BlobTermAdjust(t); - } - pc = NEXTOP(pc,oc); - break; - /* instructions type osc */ - case _unify_n_atoms_write: - case _unify_n_atoms: - pc->u.osc.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.osc.opcw)); - { - Term t = pc->u.osc.c; - if (IsAtomTerm(t)) - pc->u.osc.c = AtomTermAdjust(t); - } - pc = NEXTOP(pc,osc); - break; - /* instructions type of */ - case _unify_struct_write: - case _unify_struct: - case _unify_l_struc_write: - case _unify_l_struc: - pc->u.of.opcw = Yap_opcode(Yap_op_from_opcode(pc->u.of.opcw)); - pc->u.of.f = FuncAdjust(pc->u.of.f); - pc = NEXTOP(pc,of); - break; - /* instructions type s */ - case _write_n_voids: - case _pop_n: -#ifdef TABLING - case _table_new_answer: -#endif /* TABLING */ - pc = NEXTOP(pc,s); - break; - /* instructions type c */ - case _write_atom: - { - Term t = pc->u.c.c; - if (IsAtomTerm(t)) - pc->u.c.c = AtomTermAdjust(t); - else if (IsApplTerm(t)) - pc->u.c.c = BlobTermAdjust(t); - } - pc = NEXTOP(pc,c); - break; - /* instructions type sc */ - case _write_n_atoms: - { - Term t = pc->u.sc.c; - if (IsAtomTerm(t)) - pc->u.sc.c = AtomTermAdjust(t); - } - pc = NEXTOP(pc,sc); - break; - /* instructions type f */ - case _write_struct: - case _write_l_struc: - pc->u.f.f = FuncAdjust(pc->u.f.f); - pc = NEXTOP(pc,f); - break; - /* instructions type sdl */ - case _call_c_wfail: - pc->u.sdl.p = PtoPredAdjust(pc->u.sdl.p); - pc->u.sdl.l = PtoOpAdjust(pc->u.sdl.l); - pc = NEXTOP(pc,sdl); - break; - /* instructions type lds */ - case _try_c: - case _try_userc: - /* don't need to do no nothing here, initstaff will do it for us - */ - pc->u.lds.p = PtoPredAdjust(pc->u.lds.p); - pc = NEXTOP(pc,lds); - break; - case _retry_c: - case _retry_userc: - /* don't need to do no nothing here, initstaff will do it for us - pc->u.lds.d = CCodeAdjust(pc->u.lds.d); */ - pc->u.lds.p = PtoPredAdjust(pc->u.lds.p); - pc = NEXTOP(pc,lds); - break; - /* instructions type llll */ - case _switch_on_type: - pc->u.llll.l1 = PtoOpAdjust(pc->u.llll.l1); - pc->u.llll.l2 = PtoOpAdjust(pc->u.llll.l2); - pc->u.llll.l3 = PtoOpAdjust(pc->u.llll.l3); - pc->u.llll.l4 = PtoOpAdjust(pc->u.llll.l4); - pc = NEXTOP(pc,llll); - break; - /* instructions type xllll */ - case _switch_list_nl: - pc->u.ollll.pop = Yap_opcode(Yap_op_from_opcode(pc->u.ollll.pop)); - pc->u.ollll.l1 = PtoOpAdjust(pc->u.llll.l1); - pc->u.ollll.l2 = PtoOpAdjust(pc->u.llll.l2); - pc->u.ollll.l3 = PtoOpAdjust(pc->u.llll.l3); - pc->u.ollll.l4 = PtoOpAdjust(pc->u.llll.l4); - pc = NEXTOP(pc,ollll); - break; - /* instructions type xllll */ - case _switch_on_arg_type: - pc->u.xllll.x = XAdjust(pc->u.xllll.x); - pc->u.xllll.l1 = PtoOpAdjust(pc->u.xllll.l1); - pc->u.xllll.l2 = PtoOpAdjust(pc->u.xllll.l2); - pc->u.xllll.l3 = PtoOpAdjust(pc->u.xllll.l3); - pc->u.xllll.l4 = PtoOpAdjust(pc->u.xllll.l4); - pc = NEXTOP(pc,xllll); - break; - /* instructions type sllll */ - case _switch_on_sub_arg_type: - pc->u.sllll.l1 = PtoOpAdjust(pc->u.sllll.l1); - pc->u.sllll.l2 = PtoOpAdjust(pc->u.sllll.l2); - pc->u.sllll.l3 = PtoOpAdjust(pc->u.sllll.l3); - pc->u.sllll.l4 = PtoOpAdjust(pc->u.sllll.l4); - pc = NEXTOP(pc,sllll); - break; - /* instructions type lll */ - case _if_not_then: - { - Term t = pc->u.clll.c; - if (IsAtomTerm(t)) - pc->u.clll.c = AtomTermAdjust(t); - } - pc->u.clll.l1 = PtoOpAdjust(pc->u.clll.l1); - pc->u.clll.l2 = PtoOpAdjust(pc->u.clll.l2); - pc->u.clll.l3 = PtoOpAdjust(pc->u.clll.l3); - pc = NEXTOP(pc,clll); - break; - /* switch_on_func */ - case _switch_on_func: - { - int i, j; - CELL *oldcode, *startcode; - - i = pc->u.sssl.s; - startcode = oldcode = (CELL *)(pc->u.sssl.l = PtoOpAdjust(pc->u.sssl.l)); - for (j = 0; j < i; j++) { - Functor oldfunc = (Functor)(oldcode[0]); - CODEADDR oldjmp = (CODEADDR)(oldcode[1]); - if (oldfunc != NULL) { - oldcode[0] = (CELL)FuncAdjust(oldfunc); - } - oldcode[1] = (CELL)CodeAddrAdjust(oldjmp); - oldcode += 2; - } - rehash(startcode, i, Funcs); - pc = NEXTOP(pc,sssl); - } - break; - /* switch_on_cons */ - case _switch_on_cons: - { - int i, j; - CELL *oldcode; -#if !USE_OFFSETS - CELL *startcode; -#endif - - i = pc->u.sssl.s; -#if !USE_OFFSETS - startcode = -#endif - oldcode = (CELL *)(pc->u.sssl.l = PtoOpAdjust(pc->u.sssl.l)); - for (j = 0; j < i; j++) { - Term oldcons = oldcode[0]; - CODEADDR oldjmp = (CODEADDR)(oldcode[1]); - if (oldcons != 0x0 && IsAtomTerm(oldcons)) { - oldcode[0] = AtomTermAdjust(oldcons); - } - oldcode[1] = (CELL)CodeAddrAdjust(oldjmp); - oldcode += 2; - } -#if !USE_OFFSETS - rehash(startcode, i, Atomics); -#endif - pc = NEXTOP(pc,sssl); - } - break; - case _go_on_func: - { - CELL *oldcode = (CELL *)(pc->u.sssl.l = PtoOpAdjust(pc->u.sssl.l)); - Functor oldfunc = (Functor)(oldcode[0]); - - oldcode[0] = (CELL)FuncAdjust(oldfunc); - oldcode[1] = (CELL)CodeAddrAdjust((CODEADDR)oldcode[1]); - oldcode[3] = (CELL)CodeAddrAdjust((CODEADDR)oldcode[3]); - } - pc = NEXTOP(pc,sssl); - break; - case _go_on_cons: - { - CELL *oldcode = (CELL *)(pc->u.sssl.l = PtoOpAdjust(pc->u.sssl.l)); - Term oldcons = oldcode[0]; - - if (IsAtomTerm(oldcons)) { - oldcode[0] = AtomTermAdjust(oldcons); - } - oldcode[1] = (CELL)CodeAddrAdjust((CODEADDR)oldcode[1]); - oldcode[3] = (CELL)CodeAddrAdjust((CODEADDR)oldcode[3]); - } - pc = NEXTOP(pc,sssl); - break; - case _if_func: - { - CELL *oldcode = (CELL *)(pc->u.sssl.l = PtoOpAdjust(pc->u.sssl.l)); - Int j; - - for (j = 0; j < pc->u.sssl.s; j++) { - Functor oldfunc = (Functor)(oldcode[0]); - CODEADDR oldjmp = (CODEADDR)(oldcode[1]); - oldcode[0] = (CELL)FuncAdjust(oldfunc); - oldcode[1] = (CELL)CodeAddrAdjust(oldjmp); - oldcode += 2; - } - /* adjust fail code */ - oldcode[1] = (CELL)CodeAddrAdjust((CODEADDR)oldcode[1]); - } - pc = NEXTOP(pc,sssl); - break; - case _if_cons: - { - CELL *oldcode = (CELL *)(pc->u.sssl.l = PtoOpAdjust(pc->u.sssl.l)); - Int j; - - for (j = 0; j < pc->u.sssl.s; j++) { - Term oldcons = oldcode[0]; - CODEADDR oldjmp = (CODEADDR)(oldcode[1]); - if (IsAtomTerm(oldcons)) { - oldcode[0] = (CELL)AtomTermAdjust(oldcons); - } - oldcode[1] = (CELL)CodeAddrAdjust(oldjmp); - oldcode += 2; - } - /* adjust fail code */ - oldcode[1] = (CELL)CodeAddrAdjust((CODEADDR)oldcode[1]); - } - pc = NEXTOP(pc,sssl); - break; - /* instructions type xxx */ - case _p_plus_vv: - case _p_minus_vv: - case _p_times_vv: - case _p_div_vv: - case _p_and_vv: - case _p_or_vv: - case _p_sll_vv: - case _p_slr_vv: - case _p_arg_vv: - case _p_func2s_vv: - case _p_func2f_xx: - pc->u.xxx.x = XAdjust(pc->u.xxx.x); - pc->u.xxx.x1 = XAdjust(pc->u.xxx.x1); - pc->u.xxx.x2 = XAdjust(pc->u.xxx.x2); - pc = NEXTOP(pc,xxx); - break; - /* instructions type xxc */ - case _p_plus_vc: - case _p_minus_cv: - case _p_times_vc: - case _p_div_cv: - case _p_and_vc: - case _p_or_vc: - case _p_sll_vc: - case _p_slr_vc: - case _p_func2s_vc: - pc->u.xxc.x = XAdjust(pc->u.xxc.x); - pc->u.xxc.xi = XAdjust(pc->u.xxc.xi); - pc = NEXTOP(pc,xxc); - break; - case _p_div_vc: - case _p_sll_cv: - case _p_slr_cv: - case _p_arg_cv: - pc->u.xcx.x = XAdjust(pc->u.xcx.x); - pc->u.xcx.xi = XAdjust(pc->u.xcx.xi); - pc = NEXTOP(pc,xcx); - break; - case _p_func2s_cv: - pc->u.xcx.x = XAdjust(pc->u.xcx.x); - if (IsAtomTerm(pc->u.xcx.c)) - pc->u.xcx.c = AtomTermAdjust(pc->u.xcx.c); - pc->u.xcx.xi = XAdjust(pc->u.xcx.xi); - pc = NEXTOP(pc,xcx); - break; - /* instructions type xyx */ - case _p_func2f_xy: - pc->u.xyx.x = XAdjust(pc->u.xyx.x); - pc->u.xyx.x1 = XAdjust(pc->u.xyx.x1); - pc->u.xyx.y2 = YAdjust(pc->u.xyx.y2); - pc = NEXTOP(pc,xyx); - break; - /* instructions type yxx */ - case _p_plus_y_vv: - case _p_minus_y_vv: - case _p_times_y_vv: - case _p_div_y_vv: - case _p_and_y_vv: - case _p_or_y_vv: - case _p_sll_y_vv: - case _p_slr_y_vv: - case _p_arg_y_vv: - case _p_func2s_y_vv: - case _p_func2f_yx: - pc->u.yxx.y = YAdjust(pc->u.yxx.y); - pc->u.yxx.x1 = XAdjust(pc->u.yxx.x1); - pc->u.yxx.x2 = XAdjust(pc->u.yxx.x2); - pc = NEXTOP(pc,yxx); - break; - /* instructions type yyx */ - case _p_func2f_yy: - pc->u.yyx.y1 = YAdjust(pc->u.yyx.y1); - pc->u.yyx.y2 = YAdjust(pc->u.yyx.y2); - pc->u.yyx.x = XAdjust(pc->u.yyx.x); - pc = NEXTOP(pc,yyx); - break; - /* instructions type yxc */ - case _p_plus_y_vc: - case _p_minus_y_cv: - case _p_times_y_vc: - case _p_div_y_vc: - case _p_div_y_cv: - case _p_and_y_vc: - case _p_or_y_vc: - case _p_sll_y_vc: - case _p_slr_y_vc: - case _p_func2s_y_vc: - pc->u.yxc.y = YAdjust(pc->u.yxc.y); - pc->u.yxc.xi = XAdjust(pc->u.yxc.xi); - pc = NEXTOP(pc,yxc); - break; - /* instructions type ycx */ - case _p_sll_y_cv: - case _p_slr_y_cv: - case _p_arg_y_cv: - pc->u.ycx.y = YAdjust(pc->u.ycx.y); - pc->u.ycx.xi = XAdjust(pc->u.ycx.xi); - pc = NEXTOP(pc,ycx); - break; - /* instructions type ycx */ - case _p_func2s_y_cv: - pc->u.ycx.y = YAdjust(pc->u.ycx.y); - if (IsAtomTerm(pc->u.ycx.c)) - pc->u.ycx.c = AtomTermAdjust(pc->u.ycx.c); - pc->u.ycx.xi = XAdjust(pc->u.ycx.xi); - pc = NEXTOP(pc,ycx); - break; - /* instructions type llxx */ - case _call_bfunc_xx: - pc->u.llxx.p = PtoPredAdjust(pc->u.llxx.p); - pc->u.llxx.f = PtoOpAdjust(pc->u.llxx.f); - pc->u.llxx.x1 = XAdjust(pc->u.llxx.x1); - pc->u.llxx.x2 = XAdjust(pc->u.llxx.x2); - pc = NEXTOP(pc,llxx); - break; - /* instructions type llxy */ - case _call_bfunc_yx: - case _call_bfunc_xy: - pc->u.llxy.p = PtoPredAdjust(pc->u.llxy.p); - pc->u.llxy.f = PtoOpAdjust(pc->u.llxy.f); - pc->u.llxy.x = XAdjust(pc->u.llxy.x); - pc->u.llxy.y = YAdjust(pc->u.llxy.y); - pc = NEXTOP(pc,llxy); - break; - case _call_bfunc_yy: - pc->u.llyy.p = PtoPredAdjust(pc->u.llyy.p); - pc->u.llyy.f = PtoOpAdjust(pc->u.llxy.f); - pc->u.llyy.y1 = YAdjust(pc->u.llyy.y1); - pc->u.llyy.y2 = YAdjust(pc->u.llyy.y2); - pc = NEXTOP(pc,llyy); - break; - } - } while (TRUE); -} +#include "rclause.h" /* Restores a prolog clause, in its compiled form */ static void diff --git a/Makefile.in b/Makefile.in index e8abf0d4d..390a77c67 100644 --- a/Makefile.in +++ b/Makefile.in @@ -111,6 +111,7 @@ HEADERS = \ $(srcdir)/H/corout.h $(srcdir)/H/dlmalloc.h \ $(srcdir)/H/eval.h $(srcdir)/H/heapgc.h \ $(srcdir)/H/index.h $(srcdir)/H/iopreds.h \ + $(srcdir)/H/rclause.h \ $(srcdir)/H/rheap.h \ $(srcdir)/H/tracer.h \ $(srcdir)/H/threads.h \ diff --git a/m4/Yap.h.m4 b/m4/Yap.h.m4 index 8609e7127..da5043217 100644 --- a/m4/Yap.h.m4 +++ b/m4/Yap.h.m4 @@ -10,7 +10,7 @@ * File: Yap.h.m4 * * mods: * * comments: main header file for YAP * -* version: $Id: Yap.h.m4,v 1.75 2004-12-05 05:01:43 vsc Exp $ * +* version: $Id: Yap.h.m4,v 1.76 2005-01-04 02:50:23 vsc Exp $ * *************************************************************************/ #include "config.h" @@ -927,7 +927,7 @@ extern int Yap_argc; /******** whether Yap is responsible for signal handling ******************/ -int Yap_PrologShouldHandleInterrupts; +extern int Yap_PrologShouldHandleInterrupts; /******************* number of modules ****************************/ diff --git a/m4/sshift.h.m4 b/m4/sshift.h.m4 index ce0577afb..0fe19e55a 100644 --- a/m4/sshift.h.m4 +++ b/m4/sshift.h.m4 @@ -16,21 +16,6 @@ *************************************************************************/ -/* The difference between the old stack pointers and the new ones */ -extern Int HDiff, - GDiff, - LDiff, - TrDiff, - XDiff, - DelayDiff; - -/* The old stack pointers */ -extern CELL *OldASP, *OldLCL0; -extern tr_fr_ptr OldTR; -extern CELL *OldGlobalBase, *OldH, *OldH0; -extern ADDR OldTrailBase, OldTrailTop; -extern ADDR OldHeapBase, OldHeapTop; - #define CharP(ptr) ((char *) (ptr)) Inline(IsHeapP, int, CELL *, ptr, (ptr >= (CELL *)Yap_HeapBase && ptr <= (CELL *)HeapTop) )