Merge branch 'master' of ssh://yap.git.sf.net/gitroot/yap/yap-6.3

This commit is contained in:
Vitor Santos Costa 2011-06-26 23:14:48 +01:00
commit 9d00e3426c
13 changed files with 81 additions and 69 deletions

View File

@ -7928,11 +7928,11 @@ Yap_absmi(int inp)
\************************************************************************/ \************************************************************************/
/* enter logical pred */ /* enter logical pred */
BOp(enter_lu_pred, Ills); BOp(enter_lu_pred, Illss);
check_trail(TR); check_trail(TR);
/* mark the indexing code */ /* mark the indexing code */
{ {
LogUpdIndex *cl = PREG->u.Ills.I; LogUpdIndex *cl = PREG->u.Illss.I;
PredEntry *ap = cl->ClPred; PredEntry *ap = cl->ClPred;
if (ap->LastCallOfPred != LUCALL_EXEC) { if (ap->LastCallOfPred != LUCALL_EXEC) {
@ -7947,8 +7947,8 @@ Yap_absmi(int inp)
/* fprintf(stderr,"R %x--%d--%ul\n",ap,ap->TimeStampOfPred,ap->ArityOfPE);*/ /* fprintf(stderr,"R %x--%d--%ul\n",ap,ap->TimeStampOfPred,ap->ArityOfPE);*/
} }
*--YREG = MkIntegerTerm(ap->TimeStampOfPred); *--YREG = MkIntegerTerm(ap->TimeStampOfPred);
/* fprintf(stderr,"> %p/%p %d %d\n",cl,ap,ap->TimeStampOfPred,PREG->u.Ills.s);*/ /* fprintf(stderr,"> %p/%p %d %d\n",cl,ap,ap->TimeStampOfPred,PREG->u.Illss.s);*/
PREG = PREG->u.Ills.l1; PREG = PREG->u.Illss.l1;
/* indicate the indexing code is being used */ /* indicate the indexing code is being used */
#if MULTIPLE_STACKS #if MULTIPLE_STACKS
/* just store a reference */ /* just store a reference */

View File

@ -482,15 +482,16 @@ a_lucl(op_numbers opcode, yamop *code_p, int pass_no, struct intermediates *cip,
if (pass_no) { if (pass_no) {
LogUpdIndex *lcl = (LogUpdIndex *)cip->code_addr; LogUpdIndex *lcl = (LogUpdIndex *)cip->code_addr;
code_p->opc = emit_op(opcode); code_p->opc = emit_op(opcode);
code_p->u.Ills.I = lcl; code_p->u.Illss.I = lcl;
cip->cpc->rnd4 = (CELL)code_p; cip->cpc->rnd4 = (CELL)code_p;
cip->current_try_lab = &code_p->u.Ills.l1; cip->current_try_lab = &code_p->u.Illss.l1;
cip->current_trust_lab = &code_p->u.Ills.l2; cip->current_trust_lab = &code_p->u.Illss.l2;
code_p->u.Ills.l1 = NULL; code_p->u.Illss.l1 = NULL;
code_p->u.Ills.l2 = NULL; code_p->u.Illss.l2 = NULL;
code_p->u.Ills.s = cip->cpc->rnd3; code_p->u.Illss.s = cip->cpc->rnd3;
code_p->u.Illss.e = 0;
} }
GONEXT(Ills); GONEXT(Illss);
return code_p; return code_p;
} }

View File

@ -1197,16 +1197,17 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code
case _enter_lu_pred: case _enter_lu_pred:
{ {
yamop *oipc = ipc; yamop *oipc = ipc;
if (ipc->u.Ills.I->ClFlags & InUseMask || ipc->u.Ills.I->ClRefCount) if (ipc->u.Illss.I->ClFlags & InUseMask || ipc->u.Illss.I->ClRefCount)
return; return;
#ifdef DEBUG #ifdef DEBUG
Yap_DirtyCps+=ipc->u.Ills.s; Yap_DirtyCps+=ipc->u.Illss.s;
Yap_LiveCps-=ipc->u.Ills.s; Yap_LiveCps-=ipc->u.Illss.s;
#endif #endif
ipc = ipc->u.Ills.l1; ipc = ipc->u.Illss.l1;
/* in case we visit again */ /* in case we visit again */
oipc->u.Ills.l1 = FAILCODE; oipc->u.Illss.l1 = FAILCODE;
oipc->u.Ills.s = 0; oipc->u.Illss.s = 0;
oipc->u.Illss.e = 0;
} }
break; break;
case _try_in: case _try_in:

View File

@ -3722,8 +3722,8 @@ index_sz(LogUpdIndex *x)
endop = Yap_opcode(_profiled_trust_logical); endop = Yap_opcode(_profiled_trust_logical);
else else
endop = Yap_opcode(_trust_logical); endop = Yap_opcode(_trust_logical);
start = start->u.Ills.l1; start = start->u.Illss.l1;
if (start->u.Ills.s) do { if (start->u.Illss.s) do {
sz += (UInt)NEXTOP((yamop*)NULL,OtaLl); sz += (UInt)NEXTOP((yamop*)NULL,OtaLl);
op1 = start->opc; op1 = start->opc;
count++; count++;

View File

@ -558,8 +558,8 @@ recover_from_failed_susp_on_cls(struct intermediates *cint, UInt sz)
case enter_lu_op: case enter_lu_op:
if (cpc->rnd4) { if (cpc->rnd4) {
yamop *code_p = (yamop *)cpc->rnd4; yamop *code_p = (yamop *)cpc->rnd4;
yamop *first = code_p->u.Ills.l1; yamop *first = code_p->u.Illss.l1;
yamop *last = code_p->u.Ills.l2; yamop *last = code_p->u.Illss.l2;
while (first) { while (first) {
yamop *next = first->u.OtaLl.n; yamop *next = first->u.OtaLl.n;
LogUpdClause *cl = first->u.OtaLl.d; LogUpdClause *cl = first->u.OtaLl.d;
@ -1001,9 +1001,9 @@ has_cut(yamop *pc)
#endif /* TABLING */ #endif /* TABLING */
pc = NEXTOP(pc,Otapl); pc = NEXTOP(pc,Otapl);
break; break;
/* instructions type Ills */ /* instructions type Illss */
case _enter_lu_pred: case _enter_lu_pred:
pc = pc->u.Ills.l1; pc = pc->u.Illss.l1;
break; break;
case _execute: case _execute:
case _dexecute: case _dexecute:
@ -4059,7 +4059,7 @@ expand_index(struct intermediates *cint) {
break; break;
case _enter_lu_pred: case _enter_lu_pred:
/* no useful info */ /* no useful info */
ipc = ipc->u.Ills.l1; ipc = ipc->u.Illss.l1;
break; break;
case _retry_profiled: case _retry_profiled:
case _count_retry: case _count_retry:
@ -4289,7 +4289,7 @@ expand_index(struct intermediates *cint) {
if (alt != NULL && ap->PredFlags & LogUpdatePredFlag) { if (alt != NULL && ap->PredFlags & LogUpdatePredFlag) {
op_numbers fop = Yap_op_from_opcode(alt->opc); op_numbers fop = Yap_op_from_opcode(alt->opc);
if (fop == _enter_lu_pred) if (fop == _enter_lu_pred)
alt = alt->u.Ills.l1; alt = alt->u.Illss.l1;
} }
ipc = NULL; ipc = NULL;
break; break;
@ -5080,8 +5080,8 @@ find_last_clause(yamop *start)
static void static void
remove_clause_from_index(yamop *header, LogUpdClause *cl) remove_clause_from_index(yamop *header, LogUpdClause *cl)
{ {
yamop **prevp = &(header->u.Ills.l1); yamop **prevp = &(header->u.Illss.l1);
yamop *curp = header->u.Ills.l1; yamop *curp = header->u.Illss.l1;
if (curp->u.OtaLl.d == cl) { if (curp->u.OtaLl.d == cl) {
yamop *newp = curp->u.OtaLl.n; yamop *newp = curp->u.OtaLl.n;
@ -5095,13 +5095,14 @@ remove_clause_from_index(yamop *header, LogUpdClause *cl)
curp = curp->u.OtaLl.n; curp = curp->u.OtaLl.n;
} }
/* in case we were the last */ /* in case we were the last */
if (curp == header->u.Ills.l2) if (curp == header->u.Illss.l2)
header->u.Ills.l2 = ocurp; header->u.Illss.l2 = ocurp;
if (ocurp != ocurp0) if (ocurp != ocurp0)
ocurp->opc = curp->opc; ocurp->opc = curp->opc;
ocurp->u.OtILl.n = curp->u.OtaLl.n; ocurp->u.OtILl.n = curp->u.OtaLl.n;
ocurp->u.OtILl.block = curp->u.OtILl.block; ocurp->u.OtILl.block = curp->u.OtILl.block;
} }
header->u.Illss.e--;
#ifdef DEBUG #ifdef DEBUG
Yap_DirtyCps--; Yap_DirtyCps--;
Yap_FreedCps++; Yap_FreedCps++;
@ -5117,7 +5118,7 @@ remove_dirty_clauses_from_index(yamop *header)
LogUpdClause *cl; LogUpdClause *cl;
yamop *previouscurp; yamop *previouscurp;
OPCODE endop = Yap_opcode(_trust_logical); OPCODE endop = Yap_opcode(_trust_logical);
yamop **prevp= &(header->u.Ills.l1), *curp = header->u.Ills.l1; yamop **prevp= &(header->u.Illss.l1), *curp = header->u.Illss.l1;
OPCODE startopc = curp->opc; OPCODE startopc = curp->opc;
PredEntry *ap = curp->u.OtaLl.d->ClPred; PredEntry *ap = curp->u.OtaLl.d->ClPred;
@ -5128,6 +5129,7 @@ remove_dirty_clauses_from_index(yamop *header)
while ((cl = curp->u.OtaLl.d)->ClFlags & ErasedMask) { while ((cl = curp->u.OtaLl.d)->ClFlags & ErasedMask) {
yamop *ocurp = curp; yamop *ocurp = curp;
header->u.Illss.e--;
#ifdef DEBUG #ifdef DEBUG
Yap_DirtyCps--; Yap_DirtyCps--;
Yap_FreedCps++; Yap_FreedCps++;
@ -5141,12 +5143,15 @@ remove_dirty_clauses_from_index(yamop *header)
curp->opc = startopc; curp->opc = startopc;
if (curp->opc == endop) if (curp->opc == endop)
return; return;
if (!header->u.Illss.e)
return;
previouscurp = curp; previouscurp = curp;
curp = curp->u.OtaLl.n; curp = curp->u.OtaLl.n;
while (TRUE) { while (TRUE) {
if ((cl = curp->u.OtaLl.d)->ClFlags & ErasedMask) { if ((cl = curp->u.OtaLl.d)->ClFlags & ErasedMask) {
yamop *ocurp = curp; yamop *ocurp = curp;
header->u.Illss.e--;
#ifdef DEBUG #ifdef DEBUG
Yap_DirtyCps--; Yap_DirtyCps--;
Yap_FreedCps++; Yap_FreedCps++;
@ -5156,7 +5161,7 @@ remove_dirty_clauses_from_index(yamop *header)
previouscurp->opc = endop; previouscurp->opc = endop;
previouscurp->u.OtILl.block = curp->u.OtILl.block; previouscurp->u.OtILl.block = curp->u.OtILl.block;
previouscurp->u.OtILl.n = NULL; previouscurp->u.OtILl.n = NULL;
header->u.Ills.l2 = previouscurp; header->u.Illss.l2 = previouscurp;
Yap_LUIndexSpace_CP -= (UInt)NEXTOP((yamop*)NULL,OtILl); Yap_LUIndexSpace_CP -= (UInt)NEXTOP((yamop*)NULL,OtILl);
Yap_FreeCodeSpace((ADDR)curp); Yap_FreeCodeSpace((ADDR)curp);
return; return;
@ -5165,6 +5170,8 @@ remove_dirty_clauses_from_index(yamop *header)
curp = curp->u.OtaLl.n; curp = curp->u.OtaLl.n;
Yap_LUIndexSpace_CP -= (UInt)NEXTOP((yamop*)NULL,OtaLl); Yap_LUIndexSpace_CP -= (UInt)NEXTOP((yamop*)NULL,OtaLl);
Yap_FreeCodeSpace((ADDR)ocurp); Yap_FreeCodeSpace((ADDR)ocurp);
if (!header->u.Illss.e)
return;
} else { } else {
previouscurp = curp; previouscurp = curp;
if (curp->opc == endop) { if (curp->opc == endop) {
@ -5201,15 +5208,15 @@ kill_clause(yamop *ipc, yamop *bg, yamop *lt, path_stack_entry *sp0, PredEntry *
return kill_block(sp+1, ap); return kill_block(sp+1, ap);
} }
/* weird case ????? */ /* weird case ????? */
if (!start->u.Ills.s){ if (!start->u.Illss.s){
/* ERROR */ /* ERROR */
Yap_Error(INTERNAL_ERROR, TermNil, "Ills.s == 0 %p", ipc); Yap_Error(INTERNAL_ERROR, TermNil, "Illss.s == 0 %p", ipc);
return sp; return sp;
} }
if (start->u.Ills.s == 1) { if (start->u.Illss.s == 1) {
/* we need to discover which clause is left and then die */ /* we need to discover which clause is left and then die */
path_stack_entry *nsp; path_stack_entry *nsp;
LogUpdClause *tgl = find_last_clause(start->u.Ills.l1); LogUpdClause *tgl = find_last_clause(start->u.Illss.l1);
nsp = sp; nsp = sp;
while ((--nsp)->flag != block_entry); while ((--nsp)->flag != block_entry);
@ -5585,20 +5592,20 @@ add_to_index(struct intermediates *cint, int first, path_stack_entry *sp, Clause
/* ERROR */ /* ERROR */
break; break;
case _enter_lu_pred: case _enter_lu_pred:
ipc->u.Ills.s++; ipc->u.Illss.s++;
icl = ipc->u.Ills.I; icl = ipc->u.Illss.I;
if (first) { if (first) {
if (ap->PredFlags & CountPredFlag) if (ap->PredFlags & CountPredFlag)
ipc->u.Ills.l1->opc = Yap_opcode(_count_retry_logical); ipc->u.Illss.l1->opc = Yap_opcode(_count_retry_logical);
else if (ap->PredFlags & ProfiledPredFlag) else if (ap->PredFlags & ProfiledPredFlag)
ipc->u.Ills.l1->opc = Yap_opcode(_profiled_retry_logical); ipc->u.Illss.l1->opc = Yap_opcode(_profiled_retry_logical);
else else
ipc->u.Ills.l1->opc = Yap_opcode(_retry_logical); ipc->u.Illss.l1->opc = Yap_opcode(_retry_logical);
ipc->u.Ills.l1 = add_try(ap, cls, ipc->u.Ills.l1, cint); ipc->u.Illss.l1 = add_try(ap, cls, ipc->u.Illss.l1, cint);
} else { } else {
/* just go to next instruction */ /* just go to next instruction */
yamop *end = add_trust(icl, cls, cint), yamop *end = add_trust(icl, cls, cint),
*old = ipc->u.Ills.l2; *old = ipc->u.Illss.l2;
/* we used to have two clauses */ /* we used to have two clauses */
if (ap->PredFlags & CountPredFlag) if (ap->PredFlags & CountPredFlag)
@ -5609,7 +5616,7 @@ add_to_index(struct intermediates *cint, int first, path_stack_entry *sp, Clause
old->opc = Yap_opcode(_retry_logical); old->opc = Yap_opcode(_retry_logical);
old->u.OtaLl.n = end; old->u.OtaLl.n = end;
old->u.OtaLl.s = ap->ArityOfPE; old->u.OtaLl.s = ap->ArityOfPE;
ipc->u.Ills.l2 = end; ipc->u.Illss.l2 = end;
} }
ipc = pop_path(&sp, cls, ap, cint); ipc = pop_path(&sp, cls, ap, cint);
break; break;
@ -6204,7 +6211,8 @@ remove_from_index(PredEntry *ap, path_stack_entry *sp, ClauseDef *cls, yamop *bg
ipc = pop_path(&sp, cls, ap, cint); ipc = pop_path(&sp, cls, ap, cint);
break; break;
case _enter_lu_pred: case _enter_lu_pred:
ipc->u.Ills.s--; ipc->u.Illss.s--;
ipc->u.Illss.e++;
#ifdef DEBUG #ifdef DEBUG
Yap_DirtyCps++; Yap_DirtyCps++;
Yap_LiveCps--; Yap_LiveCps--;
@ -6807,7 +6815,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
break; break;
case _enter_lu_pred: case _enter_lu_pred:
{ {
LogUpdIndex *cl = ipc->u.Ills.I; LogUpdIndex *cl = ipc->u.Illss.I;
PredEntry *ap = cl->ClPred; PredEntry *ap = cl->ClPred;
if (ap->LastCallOfPred != LUCALL_EXEC) { if (ap->LastCallOfPred != LUCALL_EXEC) {
@ -6834,7 +6842,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
} }
#endif #endif
} }
ipc = ipc->u.Ills.l1; ipc = ipc->u.Illss.l1;
break; break;
case _try_logical: case _try_logical:
if (b0 == NULL) if (b0 == NULL)
@ -7377,7 +7385,7 @@ Yap_NthClause(PredEntry *ap, Int ncls)
} }
return NULL; return NULL;
case _enter_lu_pred: case _enter_lu_pred:
ipc = ipc->u.Ills.l1; ipc = ipc->u.Illss.l1;
break; break;
case _lock_lu: case _lock_lu:
ipc = NEXTOP(ipc,p); ipc = NEXTOP(ipc,p);
@ -7460,7 +7468,7 @@ Yap_CleanUpIndex(LogUpdIndex *blk)
start = NEXTOP(start, xll); start = NEXTOP(start, xll);
op = Yap_op_from_opcode(start->opc); op = Yap_op_from_opcode(start->opc);
} }
codep = start->u.Ills.l1; codep = start->u.Illss.l1;
remove_dirty_clauses_from_index(start); remove_dirty_clauses_from_index(start);
} }

View File

@ -217,7 +217,7 @@
OPCODE(retry4 ,l), OPCODE(retry4 ,l),
OPCODE(trust ,Otapl), OPCODE(trust ,Otapl),
OPCODE(try_in ,l), OPCODE(try_in ,l),
OPCODE(enter_lu_pred ,Ills), OPCODE(enter_lu_pred ,Illss),
OPCODE(try_logical ,OtaLl), OPCODE(try_logical ,OtaLl),
OPCODE(retry_logical ,OtaLl), OPCODE(retry_logical ,OtaLl),
OPCODE(trust_logical ,OtILl), OPCODE(trust_logical ,OtILl),

View File

@ -362,8 +362,9 @@ typedef struct yami {
struct yami *l1; struct yami *l1;
struct yami *l2; struct yami *l2;
COUNT s; COUNT s;
COUNT e;
CELL next; CELL next;
} Ills; } Illss;
struct { struct {
struct yami *l; struct yami *l;
CELL next; CELL next;

View File

@ -21,14 +21,15 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
pc->u.D.D = DBGroundTermAdjust(pc->u.D.D); pc->u.D.D = DBGroundTermAdjust(pc->u.D.D);
pc = NEXTOP(pc,D); pc = NEXTOP(pc,D);
break; break;
/* instructions type Ills */ /* instructions type Illss */
case _enter_lu_pred: case _enter_lu_pred:
pc->u.Ills.I = PtoLUIndexAdjust(pc->u.Ills.I); pc->u.Illss.I = PtoLUIndexAdjust(pc->u.Illss.I);
pc->u.Ills.l1 = PtoOpAdjust(pc->u.Ills.l1); pc->u.Illss.l1 = PtoOpAdjust(pc->u.Illss.l1);
pc->u.Ills.l2 = PtoOpAdjust(pc->u.Ills.l2); pc->u.Illss.l2 = PtoOpAdjust(pc->u.Illss.l2);
pc->u.Ills.s = ConstantAdjust(pc->u.Ills.s); pc->u.Illss.s = ConstantAdjust(pc->u.Illss.s);
opc = NEXTOP(pc,Ills); pc->u.Illss.e = ConstantAdjust(pc->u.Illss.e);
pc = pc->u.Ills.l1; opc = NEXTOP(pc,Illss);
pc = pc->u.Illss.l1;
break; break;
/* instructions type L */ /* instructions type L */
case _alloc_for_logical_pred: case _alloc_for_logical_pred:

View File

@ -13,9 +13,9 @@
case _write_dbterm: case _write_dbterm:
pc = NEXTOP(pc,D); pc = NEXTOP(pc,D);
break; break;
/* instructions type Ills */ /* instructions type Illss */
case _enter_lu_pred: case _enter_lu_pred:
return walk_got_lu_block(pc->u.Ills.I, startp, endp); return walk_got_lu_block(pc->u.Illss.I, startp, endp);
/* instructions type L */ /* instructions type L */
case _alloc_for_logical_pred: case _alloc_for_logical_pred:
return walk_got_lu_clause(pc->u.L.ClBase, startp, endp); return walk_got_lu_clause(pc->u.L.ClBase, startp, endp);

View File

@ -180,9 +180,9 @@ special_formats(C,"l") :- !,
format(C,' if (op == _Ystop) return;~n',[]). format(C,' if (op == _Ystop) return;~n',[]).
special_formats(C,"sssl") :- !, special_formats(C,"sssl") :- !,
format(C,' AdjustSwitchTable(op, pc->u.sssl.l, pc->u.sssl.s);~n',[]). format(C,' AdjustSwitchTable(op, pc->u.sssl.l, pc->u.sssl.s);~n',[]).
special_formats(C,"Ills") :- !, special_formats(C,"Illss") :- !,
format(C,' opc = NEXTOP(pc,Ills); format(C,' opc = NEXTOP(pc,Illss);
pc = pc->u.Ills.l1; pc = pc->u.Illss.l1;
break;~n',[]), break;~n',[]),
% don't go to NEXTOP % don't go to NEXTOP
fail. fail.
@ -325,8 +325,8 @@ c_call_op("execute_cpred").
c_call_op("call_c_wfail"). c_call_op("call_c_wfail").
% I field gives direct access to LU index block and to all Pred information % I field gives direct access to LU index block and to all Pred information
output_walk(C,"Ills",_) :- !, output_walk(C,"Illss",_) :- !,
format(C,' return walk_got_lu_block(pc->u.Ills.I, startp, endp);~n',[]). format(C,' return walk_got_lu_block(pc->u.Illss.I, startp, endp);~n',[]).
output_walk(C,"OtILl",_) :- !, output_walk(C,"OtILl",_) :- !,
format(C,' return walk_got_lu_block(pc->u.OtILl.block, startp, endp);~n',[]). format(C,' return walk_got_lu_block(pc->u.OtILl.block, startp, endp);~n',[]).
% I field gives direct access to LU index clause and to all Pred information % I field gives direct access to LU index clause and to all Pred information

View File

@ -213,7 +213,7 @@ yap_flag(associate,X) :-
yap_flag(associate,X) :- yap_flag(associate,X) :-
atom(X), !, atom(X), !,
set_value('$associate',X). set_value('$associate',X).
yap_flag(bounded,X) :- yap_flag(associate,X) :-
'$do_error'(type_error(atom,X),associate(X)). '$do_error'(type_error(atom,X),associate(X)).
yap_flag(bounded,X) :- yap_flag(bounded,X) :-

View File

@ -135,7 +135,7 @@ key_statistics(Key, NOfEntries, TotalSize) :-
% Based on the SWI-Prolog definition minus reporting the number of inferences, % Based on the SWI-Prolog definition minus reporting the number of inferences,
% which YAP does not currently supports % which YAP does not currently supports
:- meta_predicate time(:). :- meta_predicate time(0).
time(Goal) :- time(Goal) :-
var(Goal), var(Goal),

View File

@ -12,9 +12,9 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:- meta_predicate :- meta_predicate
parallel(:), parallel(0),
parallel_findall(?,:,?), parallel_findall(?,0,?),
parallel_once(:). parallel_once(0).