fixes for corourining

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1042 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2004-04-20 22:08:57 +00:00
parent ea52ce8b26
commit 27f85f3355
6 changed files with 75 additions and 16 deletions

View File

@ -111,16 +111,23 @@ CopyAttVar(CELL *orig, CELL ***to_visit_ptr, CELL *res)
newv->Atts[2*j] = time;
if (IsVarTerm(t)) {
RESET_VARIABLE(newv->Atts+(2*j+1));
} else if (IsAtomicTerm(t)) {
CELL *vt = VarOfTerm(t);
if (vt == attv->Atts+(2*j+1)) {
RESET_VARIABLE(newv->Atts+(2*j+1));
} else {
to_visit[0] = vt-1;
to_visit[1] = vt;
to_visit[2] = newv->Atts+2*j+1;
to_visit[3] = vt;
to_visit += 4;
}
} else if (IsVarTerm(t) && IsAtomicTerm(t)) {
newv->Atts[2*j+1] = t;
} else {
to_visit[0] = attv->Atts+2*j;
to_visit[1] = attv->Atts+2*j+1;
to_visit[2] = newv->Atts+2*j+1;
to_visit[3] = (CELL *)(attv->Atts[2*j]);
/* fool the system into thinking we had a variable there */
attv->Atts[2*j+1] = AbsAppl(H);
to_visit += 4;
}
}
@ -345,6 +352,8 @@ BuildNewAttVar(Term t, Int i, Term tatt)
H -= 2;
t = H[0];
tatt = H[1];
printf("attv is %p\n", attv);
attv = (attvar_record *)Yap_ReadTimedVar(DelayedVars);
}
time = InitVarTime();
RESET_VARIABLE(&(attv->Value));
@ -352,7 +361,7 @@ BuildNewAttVar(Term t, Int i, Term tatt)
attv->sus_id = attvars_ext;
for (j = 0; j < NUM_OF_ATTS; j++) {
attv->Atts[2*j] = time;
RESET_VARIABLE(attv->Atts+2*j+1);
RESET_VARIABLE(attv->Atts+(2*j+1));
}
attv->NS = Yap_UpdateTimedVar(AttsMutableList, (CELL)&(attv->Done));
Bind((CELL *)t,(CELL)attv);

View File

@ -11,8 +11,11 @@
* File: index.c *
* comments: Indexing a Prolog predicate *
* *
* Last rev: $Date: 2004-04-16 19:27:31 $,$Author: vsc $ *
* Last rev: $Date: 2004-04-20 22:08:23 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.85 2004/04/16 19:27:31 vsc
* more bug fixes
*
* Revision 1.84 2004/04/14 19:10:38 vsc
* expand_clauses: keep a list of clauses to expand
* fix new trail scheme for multi-assignment variables
@ -81,6 +84,7 @@ UInt STATIC_PROTO(do_index, (ClauseDef *,ClauseDef *,struct intermediates *,UInt
UInt STATIC_PROTO(do_compound_index, (ClauseDef *,ClauseDef *,Term *t,struct intermediates *,UInt,UInt,UInt,UInt,int,int,int,CELL *,int));
UInt STATIC_PROTO(do_dbref_index, (ClauseDef *,ClauseDef *,Term,struct intermediates *,UInt,UInt,int,int,CELL *));
UInt STATIC_PROTO(do_blob_index, (ClauseDef *,ClauseDef *,Term,struct intermediates *,UInt,UInt,int,int,CELL *));
/*path_stack_entry *STATIC_PROTO(kill_unsafe_block, (path_stack_entry *,op_numbers,PredEntry *,int,int,ClauseDef *));*/
static UInt labelno;
@ -6087,6 +6091,11 @@ add_to_index(struct intermediates *cint, int first, path_stack_entry *sp, Clause
case _unlock_lu:
ipc = NEXTOP(ipc,e);
break;
case _op_fail:
while ((--sp)->flag != block_entry);
*sp->u.cle.entry_code = cls->Code;
ipc = pop_path(&sp, cls, ap);
break;
default:
sp = kill_unsafe_block(sp, op, ap, first, FALSE, cls);
ipc = pop_path(&sp, cls, ap);

View File

@ -130,7 +130,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
#ifdef COMMENTED
// if (vsc_count == 218280)
// vsc_xstop = 1;
if (vsc_count < 218200) {
if (vsc_count < 1468068888) {
UNLOCK(heap_regs->low_level_trace_lock);
return;
}

View File

@ -49,7 +49,7 @@ clean_tr(tr_fr_ptr TR0) {
if (TR != TR0) {
do {
Term p = TrailTerm(--TR);
RESET_VARIABLE(p);
RESET_VARIABLE(p);
} while (TR != TR0);
}
}
@ -65,7 +65,6 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
CELL *dvars = NULL;
#endif
HB = HLow;
to_visit0 = to_visit;
loop:
while (pt0 < pt0_end) {
@ -120,7 +119,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
register CELL *ap2;
/* store the terms to visit */
ap2 = RepAppl(d0);
if (ap2 >= HB && ap2 < H) {
if (ap2 >= HB && ap2 <= H) {
/* If this is newer than the current term, just reuse */
*ptf++ = d0;
continue;
@ -185,13 +184,16 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
if (IsAttachedTerm((CELL)ptd0)) {
/* if unbound, call the standard copy term routine */
CELL **bp[1];
if (dvars == NULL) {
dvars = (CELL *)Yap_ReadTimedVar(DelayedVars);
}
if (ptd0 >= dvars) {
*ptf++ = (CELL) ptd0;
} else {
tr_fr_ptr CurTR;
CurTR = TR;
bp[0] = to_visit;
HB = HB0;
if (!attas[ExtFromCell(ptd0)].copy_term_op(ptd0, bp, ptf)) {
@ -199,6 +201,43 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
}
to_visit = bp[0];
HB = HLow;
if (CurTR != TR) {
/* Problem here is that the attached routine might
* have changed the list of suspended goals and stored
* new entries in the trail. This should be quite
* rare, so for simplicity we just swap cells from
* bottom and top of Trail, not nice but not worth
* complicating everything else.
*/
CELL *pt1 = (CELL *)TR0;
CELL *pt2 = (CELL *)CurTR;
CELL *pt3 = (CELL *)TR;
if (pt1 == pt2) {
TR0 = TR;
} else {
/* make a backup copy */
while (pt2 < pt3)
*((CELL *)TR)++ = *pt2++;
/* reset pointers */
TR = (tr_fr_ptr)pt3;
pt2 = (CELL *)CurTR;
/* now go to old trail */
pt3 = pt1+(pt2-pt1);
/* copy old trail above */
if (pt3 != pt1) {
while (pt3 < pt2) {
*pt3++ = *pt1++;
}
}
pt1 = (CELL *)TR0;
pt2 = pt1 + (pt3-(CELL *)CurTR);
/* copy new trail below */
while (pt1 < pt2) {
*pt1++ = *pt3++;
}
TR0 = (tr_fr_ptr)pt1;
}
}
ptf++;
Bind_Global(ptd0, ptf[-1]);
}

View File

@ -224,7 +224,7 @@ repeat :- '$repeat'.
'$execute_commands'(V,_,_) :- var(V), !,
'$do_error'(instantiation_error,meta_call(V)).
'$execute_commands'([],_,_) :- !, fail.
'$execute_commands'([C|_],VL,Con) :- !,
'$execute_commands'([C|Cs],VL,Con) :- !,
(
'$execute_command'(C,VL,Con)
;

View File

@ -318,10 +318,12 @@ module(N) :-
% a meta-call.
%
'$expand_goal'(G0, GoalMod, CurMod, G, NM) :-
'$meta_expansion'(GoalMod, CurMod, G0, GF, []), !,
'$expand_goal2'(GF,GoalMod,G,NM).
'$expand_goal'(G, GoalMod, _, NG, NM) :-
'$expand_goal2'(G, GoalMod, NG, NM).
'$expand_goal2'(G0,GoalMod,G1,NM),
( '$meta_expansion'(GoalMod, CurMod, G1, GF, []) ->
G = GF
;
G = G1
).
'$expand_goal2'(G, M, NG, NM) :-
'$undefined'(G,M),