disable cache when checking whether static was in use.

heap overflow while storing db term.
trust_fail should be preceeded by an sla.
make sla point to current pred, get rid of current pred in bitmap.


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@374 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2002-02-26 15:51:54 +00:00
parent d605213a38
commit c771c14b0f
15 changed files with 217 additions and 85 deletions

View File

@ -5671,7 +5671,7 @@ absmi(int inp)
#endif /* FROZEN_REGS */
#ifdef LOW_LEVEL_TRACER
if (do_low_level_trace)
low_level_trace(enter_pred,(PredEntry *)(PREG->u.sla.p),XREGS+1);
low_level_trace(enter_pred,PREG->u.sla.p,XREGS+1);
#endif /* LOW_LEVEL_TRACE */
BEGD(d0);
d0 = (CELL) (PREG->u.sla.l);
@ -5711,15 +5711,15 @@ absmi(int inp)
#endif /* FROZEN_REGS */
#ifdef LOW_LEVEL_TRACER
if (do_low_level_trace)
low_level_trace(enter_pred,(PredEntry *)(PREG->u.sla.p),XREGS+1);
low_level_trace(enter_pred,PREG->u.sla.p,XREGS+1);
#endif /* LOW_LEVEL_TRACE */
{
CODEADDR p = PREG->u.sla.p;
PredEntry *p = PREG->u.sla.p;
PREG = NEXTOP(PREG, sla);
saveregs();
save_machine_regs();
SREG = (CELL *) YapExecute((CPredicate)(((PredEntry *)p)->TrueCodeOfPred));
SREG = (CELL *) YapExecute((CPredicate)(p->TrueCodeOfPred));
}
restore_machine_regs();

View File

@ -12,7 +12,7 @@
* Last rev: *
* mods: *
* comments: allocating space *
* version:$Id: alloc.c,v 1.13 2002-02-22 06:12:18 vsc Exp $ *
* version:$Id: alloc.c,v 1.14 2002-02-26 15:51:54 vsc Exp $ *
*************************************************************************/
#ifdef SCCS
static char SccsId[] = "%W% %G%";
@ -140,6 +140,10 @@ FreeBlock(BlockHeader *b)
/* sanity check */
sp = &(b->b_size) + (b->b_size & ~InUseFlag);
if (Addr(b) <= 0x90c7a24 && sp >= 0x90c7a24) {
extern int do_low_level_trace;
fprintf(stderr,"vsc: Here3\n");
}
if (*sp != b->b_size) {
#if !SHORT_INTS
YP_fprintf(YP_stderr, "** sanity check failed in FreeBlock %p %x %x\n",
@ -229,6 +233,8 @@ AllocHeap(unsigned int size)
b->b_size |= InUseFlag;
UNLOCK(GLOBAL_LOCKS_alloc_block);
UNLOCK(FreeBlocksLock);
if (Addr(b) <= 0x90c7a24 && Addr(b)+(size*sizeof(CELL)+sizeof(YAP_SEG_SIZE)) >= 0x90c7a24)
fprintf(stderr,"vsc: Here1\n");
return (Addr(b) + sizeof(YAP_SEG_SIZE));
}
UNLOCK(FreeBlocksLock);
@ -291,6 +297,8 @@ AllocHeap(unsigned int size)
if (!HEAPTOP_OWNER(worker_id)) {
UNLOCK(HeapTopLock);
}
if (Addr(b) <= 0x90c7a24 && Addr(b)+(size*sizeof(CELL)+sizeof(YAP_SEG_SIZE)) >= 0x90c7a24)
fprintf(stderr,"vsc: Here2\nn");
return (Addr(b) + sizeof(YAP_SEG_SIZE));
}

View File

@ -37,7 +37,7 @@ STATIC_PROTO(AREG emit_xreg2, (void));
STATIC_PROTO(AREG emit_x, (CELL));
STATIC_PROTO(YREG emit_y, (Ventry *));
STATIC_PROTO(CODEADDR emit_a, (CELL));
STATIC_PROTO(CODEADDR emit_bmlabel, (CELL));
STATIC_PROTO(CELL *emit_bmlabel, (CELL));
STATIC_PROTO(CODEADDR emit_ilabel, (CELL));
STATIC_PROTO(Functor emit_f, (CELL));
STATIC_PROTO(CELL emit_c, (CELL));
@ -259,10 +259,10 @@ emit_ilabel(register CELL addr)
return (emit_a(addr));
}
inline static CODEADDR
inline static CELL *
emit_bmlabel(register CELL addr)
{
return (emit_a(Unsigned(code_addr) + label_offset[addr]));
return ((CELL *)(emit_a(Unsigned(code_addr) + label_offset[addr])));
}
inline static Functor
@ -781,13 +781,13 @@ a_p(op_numbers opcode)
* (cpc->rnd2));
code_p->u.sla.l = emit_a((CELL)
RepPredProp(fe)->TrueCodeOfPred);
code_p->u.sla.p = emit_a((CELL)
RepPredProp(fe));
code_p->u.sla.p = RepPredProp(fe);
code_p->u.sla.p0 = CurrentPred;
if (cpc->rnd2)
code_p->u.sla.l2 = emit_bmlabel(cpc->arnds[1]);
else
/* there is no bitmap as there are no variables in the environment */
code_p->u.sla.l2 = (CELL)NIL;
code_p->u.sla.l2 = NULL;
}
GONEXT(sla);
}
@ -818,13 +818,13 @@ a_p(op_numbers opcode)
cpc->rnd2);
code_p->u.sla.l = emit_a((CELL) &
RepPredProp(fe)->StateOfPred);
code_p->u.sla.p = emit_a((CELL)
RepPredProp(fe));
code_p->u.sla.p = RepPredProp(fe);
code_p->u.sla.p0 = CurrentPred;
if (cpc->rnd2)
code_p->u.sla.l2 = emit_bmlabel(cpc->arnds[1]);
else
/* there is no bitmap as there are no variables in the environment */
code_p->u.sla.l2 = (CELL)NIL;
code_p->u.sla.l2 = NULL;
}
GONEXT(sla);
}
@ -862,12 +862,13 @@ a_empty_call(void)
code_p->u.sla.s = emit_count(-Signed(RealEnvSize) - CELLSIZE *
cpc->rnd2);
code_p->u.sla.l = emit_a((CELL)&(pe->StateOfPred));
code_p->u.sla.p = emit_a((CELL)pe);
code_p->u.sla.p = pe;
code_p->u.sla.p0 = CurrentPred;
if (cpc->rnd2)
code_p->u.sla.l2 = emit_bmlabel(cpc->rnd1);
else
/* there is no bitmap as there are no variables in the environment */
code_p->u.sla.l2 = (CELL)NIL;
code_p->u.sla.l2 = NULL;
}
GONEXT(sla);
}
@ -1189,8 +1190,8 @@ a_either(op_numbers opcode, CELL opr, CELL lab)
code_p->u.sla.s = emit_count(opr);
code_p->u.sla.l = emit_a(lab);
/* use code for atom true so that we won't try to do anything smart */
code_p->u.sla.p = emit_a((CELL)
RepPredProp(fe));;
code_p->u.sla.p = RepPredProp(fe);
code_p->u.sla.p0 = CurrentPred;
#ifdef YAPOR
/* code_p->u.sla.p = (CODEADDR)CurrentPred; */
INIT_YAMOP_LTT(code_p, nofalts);
@ -1408,7 +1409,6 @@ a_bmap(void)
{
/* how much space do we need to reserve */
int i, max = (cpc->rnd1)/(8*sizeof(CELL));
fill_a((CELL)CurrentPred);
for (i = 0; i <= max; i++) fill_a(cpc->arnds[i]);
}

View File

@ -1533,7 +1533,7 @@ p_assign_static(void)
if (ref != NULL) {
ReleaseTermFromDB(ref);
}
ptr->ValueOfVE.terms[indx] = StoreTermInDB(t3,3);
ptr->ValueOfVE.terms[indx] = StoreTermInDB(3,3);
}
break;
}

4
C/bb.c
View File

@ -257,7 +257,7 @@ p_bb_put(void)
if (p->Element != NULL) {
ReleaseTermFromDB(p->Element);
}
p->Element = StoreTermInDB(Deref(ARG2),3);
p->Element = StoreTermInDB(2,2);
WRITE_UNLOCK(p->BBRWLock);
return(p->Element != NULL);
}
@ -312,7 +312,7 @@ p_bb_update(void)
}
ReleaseTermFromDB(p->Element);
p->Element = StoreTermInDB(Deref(ARG3),3);
p->Element = StoreTermInDB(3,3);
WRITE_UNLOCK(p->BBRWLock);
return(TRUE);

View File

@ -1135,8 +1135,8 @@ init_consult(int mode, char *file)
ConsultSp->c = (ConsultBase-ConsultSp);
ConsultBase = ConsultSp;
#if !defined(YAPOR) && !defined(SBA)
if (consult_level == 0)
do_toggle_static_predicates_in_use(TRUE);
/* if (consult_level == 0)
do_toggle_static_predicates_in_use(TRUE); */
#endif
consult_level++;
}
@ -1187,8 +1187,8 @@ end_consult(void)
ConsultSp += 3;
consult_level--;
#if !defined(YAPOR) && !defined(SBA)
if (consult_level == 0)
do_toggle_static_predicates_in_use(FALSE);
/* if (consult_level == 0)
do_toggle_static_predicates_in_use(FALSE);*/
#endif
}
@ -1749,9 +1749,9 @@ search_for_static_predicate_in_use(PredEntry *p, int check_everything)
continue;
}
#ifdef YAPOR
pe = PredFromOr(b_ptr->cp_cp->u.ldl.bl);
pe = b_ptr->cp_cp->u.ldl.p;
#else
pe = PredFromOr(b_ptr->cp_cp->u.sla.l2);
pe = b_ptr->cp_cp->u.sla.p0;
#endif /* YAPOR */
break;
case _retry_profiled:
@ -1797,6 +1797,18 @@ mark_pred(int mark, PredEntry *pe)
}
}
#ifndef ANALYST
static char *op_names[_std_top + 1] =
{
#define OPCODE(OP,TYPE) #OP
#include "YapOpcodes.h"
#undef OPCODE
};
#endif
/* go up the chain of choice_points and environments,
marking all static predicates that current execution is depending
upon */
@ -1808,13 +1820,72 @@ do_toggle_static_predicates_in_use(int mask)
if (b_ptr == NULL)
return;
{
op_numbers opnum;
register OPCODE op;
op = b_ptr->cp_ap->opc;
opnum = op_from_opcode(op);
if (1) {
switch (opnum) {
case _or_else:
case _or_last:
case _Nstop:
case _switch_last:
case _switch_l_list:
case _retry_c:
case _retry_userc:
case _trust_logical_pred:
case _retry_profiled:
{
Atom at;
Int arity;
SMALLUNSGN mod;
if (PredForCode((CODEADDR)b_ptr->cp_ap, &at, &arity, &mod)) {
if (arity)
YP_fprintf(YP_stderr,"CP %s/%d (%s)\n", RepAtom(at)->StrOfAE, arity, op_names[opnum]);
else
YP_fprintf(YP_stderr,"CP %s (%s)\n", RepAtom(at)->StrOfAE, op_names[opnum]);
} else
YP_fprintf(YP_stderr,"CP (%s)\n", op_names[opnum]);
}
break;
default:
{
PredEntry *pe = (PredEntry *)b_ptr->cp_ap->u.ld.p;
if (pe == NULL) {
YP_fprintf(YP_stderr,"CP (%s)\n", op_names[opnum]);
} else
if (pe->ArityOfPE)
YP_fprintf(YP_stderr,"CP %s/%d (%s)\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE, op_names[opnum]);
else
YP_fprintf(YP_stderr,"CP %d (%s)\n", RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE, op_names[opnum]);
}
}
}
}
do {
PredEntry *pe;
/* check first environments that are younger than our latest choicepoint */
while (b_ptr > (choiceptr)env_ptr) {
PredEntry *pe = EnvPreg(env_ptr[E_CP]);
if (pe != NULL)
if (pe != NULL && FALSE) {
op_numbers op = op_from_opcode(ENV_ToOp(env_ptr[E_CP]));
if (pe->ArityOfPE)
YP_fprintf(YP_stderr,"ENV %p %s/%d %s\n", env_ptr, RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE, op_names[op]);
else
YP_fprintf(YP_stderr,"ENV %p %s %s\n", env_ptr, RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE, op_names[op]);
if (env_ptr == 0x21d0b24) {
CELL *next_ee = (CELL *)(env_ptr[E_E]);
do {
YP_fprintf(YP_stderr,"looking for parent %p with CP %x value %x\n", next_ee, next_ee[E_CP], EnvPreg(next_ee[E_CP]));
next_ee = (CELL *)(next_ee[E_E]);
} while (next_ee != 0x21d0f28);
}
mark_pred(mask, pe);
}
env_ptr = (CELL *)(env_ptr[E_E]);
}
/* now mark the choicepoint */
@ -1827,9 +1898,9 @@ do_toggle_static_predicates_in_use(int mask)
case _or_else:
case _or_last:
#ifdef YAPOR
pe = PredFromOr(b_ptr->cp_cp->u.ldl.bl);
pe = b_ptr->cp_cp->u.ldl.p;
#else
pe = PredFromOr(b_ptr->cp_cp->u.sla.l2);
pe = b_ptr->cp_cp->u.sla.p0;
#endif /* YAPOR */
break;
case _Nstop:

View File

@ -3191,7 +3191,7 @@ find_next_clause(DBRef ref0)
static Int
jump_to_next_dynamic_clause(void)
{
DBRef ref = (DBRef)(DBRef)(((yamop *)((CODEADDR)P-(CELL)NEXTOP((yamop *)NIL,sla)))->u.sla.l2);
DBRef ref = (DBRef)(((yamop *)((CODEADDR)P-(CELL)NEXTOP((yamop *)NIL,sla)))->u.sla.l2);
yamop *newp = find_next_clause(ref);
if (newp == (yamop *)NULL) {
@ -3493,7 +3493,7 @@ PrepareToEraseClause(Clause *clau, DBRef dbr)
out what is the next clause, if there is one */
code_p->opc = opcode(_call_cpred);
code_p->u.sla.l = (CODEADDR)(&jump_to_next_dynamic_clause);
code_p->u.sla.l2 = (CODEADDR)(dbr);
code_p->u.sla.l2 = (CELL *)(dbr);
#endif /* DISCONNECT_OLD_ENTRIES */
}
@ -3881,9 +3881,10 @@ ReleaseTermFromDB(DBRef ref)
}
DBRef
StoreTermInDB(Term t, int nargs)
StoreTermInDB(int arg, int nargs)
{
DBRef x;
Term t = Deref(XREGS[arg]);
while ((x = CreateDBStruct(t, (DBProp)NIL,
InQueue)) == NULL) {
@ -3897,8 +3898,10 @@ StoreTermInDB(Term t, int nargs)
if (!gc(nargs, ENV, P)) {
Error(SYSTEM_ERROR, TermNil, "YAP could not grow stack in enqueue/2");
return(FALSE);
} else
} else {
t = Deref(XREGS[arg]);
break;
}
case TOVF_ERROR_IN_DB:
Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
return(FALSE);
@ -3906,8 +3909,10 @@ StoreTermInDB(Term t, int nargs)
if (!growheap(FALSE)) {
Error(SYSTEM_ERROR, TermNil, "YAP could not grow heap in enqueue/2");
return(FALSE);
} else
} else {
t = Deref(XREGS[arg]);
break;
}
default:
Error(DBErrorNumber, DBErrorTerm, DBErrorMsg);
return(FALSE);
@ -3962,7 +3967,7 @@ p_enqueue(void)
return(FALSE);
} else
father_key = (db_queue *)DBRefOfTerm(Father);
x = StoreTermInDB(Deref(ARG2), 2);
x = StoreTermInDB(2, 2);
x->Parent = NULL;
WRITE_LOCK(father_key->QRWLock);
if (father_key->LastInQueue != NULL)

View File

@ -151,7 +151,7 @@ DumpActiveGoals (void)
#ifdef YAPOR
pe = PredFromOr(b_ptr->cp_cp->u.ldl.bl);
#else
pe = PredFromOr(b_ptr->cp_cp->u.sla.l2);
pe = b_ptr->cp_cp->u.sla.p0;
#endif /* YAPOR */
break;
case _retry_profiled:
@ -200,6 +200,7 @@ exit_yap (int value)
exit(value);
}
static void
detect_bug_location(char *tp, int psize)
{
@ -288,6 +289,21 @@ detect_bug_location(char *tp, int psize)
}
}
#ifdef DEBUG
#include <stdio.h>
void
bug_location(yamop *pc)
{
yamop *oldp = pc;
P = pc;
detect_bug_location((char *)H, 256);
P = oldp;
fprintf(stderr,"%s\n",(char *)H);
}
#endif
/* This needs to be a static because I can't trust the stack (WIN32), and
I can't trust the Yap stacks (error) */
#define YAP_BUF_SIZE 512

View File

@ -576,6 +576,17 @@ init_dbtable(tr_fr_ptr trail_ptr) {
/* #define INSTRUMENT_GC 1 */
#ifndef ANALYST
static char *op_names[_std_top + 1] =
{
#define OPCODE(OP,TYPE) #OP
#include "YapOpcodes.h"
#undef OPCODE
};
#endif
#ifdef INSTRUMENT_GC
typedef enum {
gc_var,
@ -1078,6 +1089,17 @@ mark_environments(CELL_PTR gc_ENV, OPREG size, CELL *pvbmap)
size = EnvSize((CELL_PTR) (gc_ENV[E_CP])); /* size = EnvSize(CP) */
pvbmap = EnvBMap((CELL_PTR) (gc_ENV[E_CP]));
#if 1
if (size < 0) {
PredEntry *pe = EnvPreg(gc_ENV[E_CP]);
op_numbers op = op_from_opcode(ENV_ToOp(gc_ENV[E_CP]));
YP_fprintf(YP_stderr,"ENV %p-%p(%d) %s\n", gc_ENV, pvbmap, size-EnvSizeInCells, op_names[op]);
if (pe->ArityOfPE)
YP_fprintf(YP_stderr," %s/%d\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE);
else
YP_fprintf(YP_stderr," %s\n", RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE);
}
#endif
gc_ENV = (CELL_PTR) gc_ENV[E_E]; /* link to prev
* environment */
}
@ -1272,17 +1294,6 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B
#endif /* TABLING_SCHEDULING */
#endif
#ifndef ANALYST
static char *op_names[_std_top + 1] =
{
#define OPCODE(OP,TYPE) #OP
#include "YapOpcodes.h"
#undef OPCODE
};
#endif
static void
mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose)
@ -1383,10 +1394,10 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose)
mark_environments((CELL_PTR) (gc_B->cp_a1),
#ifdef YAPOR
-gc_B->cp_cp->u.ldl.s / ((OPREG)sizeof(CELL)),
EnvBMapOffset((CELL *)(gc_B->cp_cp->u.ldl.bl))
(CELL *)(gc_B->cp_cp->u.ldl.bl)
#else
-gc_B->cp_cp->u.sla.s / ((OPREG)sizeof(CELL)),
EnvBMapOffset((CELL *)(gc_B->cp_cp->u.sla.l2))
gc_B->cp_cp->u.sla.l2
#endif
);
} else {
@ -1942,10 +1953,10 @@ sweep_choicepoints(choiceptr gc_B)
sweep_environments((CELL_PTR)(gc_B->cp_a1),
#ifdef YAPOR
-gc_B->cp_cp->u.ldl.s / ((OPREG)sizeof(CELL)),
EnvBMapOffset((CELL *)(gc_B->cp_cp->u.ldl.bl))
(CELL *)(gc_B->cp_cp->u.ldl.bl)
#else
-gc_B->cp_cp->u.sla.s / ((OPREG)sizeof(CELL)),
EnvBMapOffset((CELL *)(gc_B->cp_cp->u.sla.l2))
gc_B->cp_cp->u.sla.l2
#endif
);
break;

View File

@ -524,9 +524,10 @@ InitCPred(char *Name, int Arity, CPredicate code, int flags)
p_code->opc = pe->OpcodeOfPred = opcode(_call_usercpred);
else
p_code->opc = pe->OpcodeOfPred = opcode(_call_cpred);
p_code->u.sla.l2 = (CELL)NIL;
p_code->u.sla.l2 = NULL;
p_code->u.sla.s = -Signed(RealEnvSize);
p_code->u.sla.p = (CODEADDR)pe;
p_code->u.sla.p = pe;
p_code->u.sla.p0 = pe;
p_code = NEXTOP(p_code,sla);
p_code->opc = opcode(_procceed);
{
@ -556,9 +557,9 @@ InitCmpPred(char *Name, int Arity, CmpPredicate cmp_code, CPredicate code, int f
pe->CodeOfPred = pe->FirstClause = pe->LastClause = (CODEADDR) p_code;
pe->ModuleOfPred = CurrentModule;
p_code->opc = pe->OpcodeOfPred = opcode(_call_cpred);
p_code->u.sla.l2 = (CELL)NIL;
p_code->u.sla.l2 = NULL;
p_code->u.sla.s = -Signed(RealEnvSize);
p_code->u.sla.p = (CODEADDR)pe;
p_code->u.sla.p = p_code->u.sla.p0 = pe;
p_code = NEXTOP(p_code,sla);
p_code->opc = opcode(_procceed);
c_predicates[NUMBER_OF_CPREDS] = code;
@ -588,9 +589,9 @@ InitAsmPred(char *Name, int Arity, int code, CPredicate def, int flags)
pe->CodeOfPred = pe->FirstClause = pe->LastClause = (CODEADDR) p_code;
pe->ModuleOfPred = CurrentModule;
p_code->opc = pe->OpcodeOfPred = opcode(_call_cpred);
p_code->u.sla.l2 = (CELL)NIL;
p_code->u.sla.l2 = NULL;
p_code->u.sla.s = -Signed(RealEnvSize);
p_code->u.sla.p = (CODEADDR)pe;
p_code->u.sla.p = p_code->u.sla.p0 = pe;
p_code = NEXTOP(p_code,sla);
p_code->opc = opcode(_procceed);
c_predicates[NUMBER_OF_CPREDS] = def;
@ -792,12 +793,22 @@ InitCodes(void)
heap_regs->failcode_5 = opcode(_op_fail);
heap_regs->failcode_6 = opcode(_op_fail);
heap_regs->env_for_trustfail_code.op = opcode(_call);
heap_regs->env_for_trustfail_code.s = -Signed(RealEnvSize);
heap_regs->env_for_trustfail_code.l = NULL;
heap_regs->env_for_trustfail_code.l2 = NULL;
heap_regs->env_for_trustfail_code.p =
heap_regs->env_for_trustfail_code.p0 =
RepPredProp(PredPropByAtom(LookupAtom("false"),0));
heap_regs->trustfailcode = opcode(_trust_fail);
heap_regs->env_for_yes_code.op = opcode(_call);
heap_regs->env_for_yes_code.s = -Signed(RealEnvSize);
heap_regs->env_for_yes_code.l = NULL;
heap_regs->env_for_yes_code.l2 = NULL;
heap_regs->env_for_yes_code.p =
heap_regs->env_for_yes_code.p0 =
RepPredProp(PredPropByAtom(LookupAtom("true"),0));
heap_regs->yescode = opcode(_Ystop);
heap_regs->undef_op = opcode(_undef_p);
heap_regs->index_op = opcode(_index_pred);

View File

@ -1748,25 +1748,21 @@ RestoreClause(Clause *Cl)
case _or_last:
#endif
pc->u.sla.l = CodeAddrAdjust(pc->u.sla.l);
if (pc->u.sla.l2 != NIL) {
CELL *p;
p = (CELL *)(pc->u.sla.l2 = CodeAddrAdjust(pc->u.sla.l2));
/* restore entry to predicate from bitmap */
p[0] = (CELL)PtoPredAdjust((PredEntry *)(p[0]));
if (pc->u.sla.l2 != NULL) {
pc->u.sla.l2 = CellPtoHeapAdjust(pc->u.sla.l2);
}
pc->u.sla.p = CodeAddrAdjust(pc->u.sla.p);
pc->u.sla.p = PtoPredAdjust(pc->u.sla.p);
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.p = CodeAddrAdjust(pc->u.sla.p);
pc->u.sla.p = PtoPredAdjust(pc->u.sla.p);
pc->u.sla.p0 = PtoPredAdjust(pc->u.sla.p0);
pc->u.sla.l = CCodeAdjust((PredEntry *)(pc->u.sla.p));
if (pc->u.sla.l2 != NIL) {
CELL *p;
p = (CELL *)(pc->u.sla.l2 = CodeAddrAdjust(pc->u.sla.l2));
/* restore entry to predicate from bitmap */
p[0] = (CELL)PtoPredAdjust((PredEntry *)(p[0]));
if (pc->u.sla.l2 != NULL) {
pc->u.sla.l2 = CellPtoHeapAdjust(pc->u.sla.l2);
}
pc = NEXTOP(pc,sla);
break;

View File

@ -10,7 +10,7 @@
* File: Heap.h *
* mods: *
* comments: Heap Init Structure *
* version: $Id: Heap.h,v 1.23 2002-01-30 03:49:50 vsc Exp $ *
* version: $Id: Heap.h,v 1.24 2002-02-26 15:51:54 vsc Exp $ *
*************************************************************************/
/* information that can be stored in Code Space */
@ -53,6 +53,19 @@ typedef struct various_codes {
OPCODE failcode_4;
OPCODE failcode_5;
OPCODE failcode_6;
struct {
OPCODE op;
#ifdef YAPOR
COUNT ltt;
COUNT cut;
COUNT seq;
#endif /* YAPOR */
COUNT s;
CODEADDR l;
CELL *l2;
struct pred_entry *p;
struct pred_entry *p0;
} env_for_trustfail_code; /* sla */
OPCODE trustfailcode;
struct {
OPCODE op;
@ -63,8 +76,9 @@ typedef struct various_codes {
#endif /* YAPOR */
COUNT s;
CODEADDR l;
CODEADDR l2;
CODEADDR p;
CELL *l2;
struct pred_entry *p;
struct pred_entry *p0;
} env_for_yes_code; /* sla */
OPCODE yescode;
#ifdef YAPOR

View File

@ -10,7 +10,7 @@
* File: Yap.proto *
* mods: *
* comments: Function declarations for YAP *
* version: $Id: Yapproto.h,v 1.12 2002-02-22 06:12:18 vsc Exp $ *
* version: $Id: Yapproto.h,v 1.13 2002-02-26 15:51:54 vsc Exp $ *
*************************************************************************/
/* prototype file for Yap */
@ -139,7 +139,9 @@ void STD_PROTO(InitDBPreds,(void));
/* errors.c */
void STD_PROTO(exit_yap,(int));
yamop *STD_PROTO(Error,(yap_error_number,Term,char *msg, ...));
#if DEBUG
void STD_PROTO(bug_location,(yamop *));
#endif
/* eval.c */
void STD_PROTO(InitEval,(void));

View File

@ -329,10 +329,11 @@ typedef struct yami {
#endif /* YAPOR */
COUNT s;
CODEADDR l;
CODEADDR l2;
CODEADDR p;
CELL *l2;
struct pred_entry *p;
struct pred_entry *p0;
CELL next;
} sla; /* also check env for yes code before making any changes */
} sla; /* also check env for yes and trustfail code before making any changes */
struct {
AREG x;
CELL next;
@ -547,11 +548,8 @@ typedef struct choicept {
#define ENV_ToP(cp) ((PredEntry *)(((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NIL,sla)))->u.sla.p))
#define ENV_ToOp(cp) (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NIL,sla)))->opc)
#define EnvSize(cp) ((-ENV_Size(cp))/(OPREG)sizeof(CELL))
#define EnvPrdBMP(p) ((CELL *)(((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NIL,sla)))->u.sla.l2))
#define EnvBMapOffset(p) ((p)+1)
#define EnvBMap(p) EnvBMapOffset(EnvPrdBMP(p))
#define EnvPreg(p) ((PredEntry *)(EnvPrdBMP(p) == NIL ? NIL : EnvPrdBMP(p)[0] ))
#define PredFromOr(p) ((PredEntry *)(((CELL *)(p))[0] == NIL ? NIL : ((CELL *)(p))[0] ))
#define EnvBMap(p) (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NIL,sla)))->u.sla.l2)
#define EnvPreg(p) (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NIL,sla)))->u.sla.p0)
/* access to instructions */

View File

@ -487,7 +487,7 @@ int STD_PROTO(RemoveIndexation,(PredEntry *));
/* dbase.c */
void STD_PROTO(ErDBE,(DBRef));
DBRef STD_PROTO(StoreTermInDB,(Term,int));
DBRef STD_PROTO(StoreTermInDB,(int,int));
Term STD_PROTO(FetchTermFromDB,(DBRef,int));
void STD_PROTO(ReleaseTermFromDB,(DBRef));