fix bad tests for attributed variable, and use a better name for Quick Test.

This commit is contained in:
Vitor Santos Costa 2011-03-19 10:25:23 +00:00
parent 0d8aed7971
commit 2fb880b64a
6 changed files with 18 additions and 22 deletions

View File

@ -188,10 +188,6 @@ Yap_WakeUp(CELL *pt0) {
CACHE_REGS
CELL d0 = *pt0;
RESET_VARIABLE(pt0);
/* did we trail */
if (pt0 < HB) {
TR--;
}
WakeAttVar(pt0, d0 PASS_REGS);
}

View File

@ -467,7 +467,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
*ptf++ = (CELL) ptd0;
} else {
#if COROUTINING
if (copy_att_vars && FastIsAttachedTerm((CELL)ptd0)) {
if (copy_att_vars && GlobalIsAttachedTerm((CELL)ptd0)) {
/* if unbound, call the standard copy term routine */
struct cp_frame *bp;
CELL new;
@ -590,7 +590,7 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
ASP = ArenaLimit(arena);
H = HB = ArenaPt(arena);
#if COROUTINING
if (FastIsAttachedTerm(t)) {
if (GlobalIsAttachedTerm(t)) {
CELL *Hi;
*H = t;

View File

@ -1172,7 +1172,7 @@ mark_variable(CELL_PTR current USES_REGS)
next = GET_NEXT(ccur);
if (IsVarTerm(ccur)) {
if (IN_BETWEEN(Yap_GlobalBase,current,H) && FastIsAttVar(current) && current==next) {
if (IN_BETWEEN(Yap_GlobalBase,current,H) && GlobalIsAttVar(current) && current==next) {
if (next < H0) POP_CONTINUATION();
if (!UNMARKED_MARK(next-1,local_bp)) {
total_marked++;
@ -1656,7 +1656,7 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B
nondeterministically, I know that after backtracking it will be back to be an unbound variable.
The ideal solution would be to unbind all variables. The current solution is to
remark it as an attributed variable */
if (IN_BETWEEN(Yap_GlobalBase,hp,H) && FastIsAttVar(hp) && !UNMARKED_MARK(hp-1,Yap_bp)) {
if (IN_BETWEEN(Yap_GlobalBase,hp,H) && GlobalIsAttVar(hp) && !UNMARKED_MARK(hp-1,Yap_bp)) {
total_marked++;
PUSH_POINTER(hp-1 PASS_REGS);
if (hp-1 < HGEN) {
@ -1697,7 +1697,7 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B
/* can safely ignore this */
CELL *cptr = RepPair(trail_cell);
if (IN_BETWEEN(Yap_GlobalBase,cptr,H) &&
FastIsAttVar(cptr)) {
GlobalIsAttVar(cptr)) {
TrailTerm(trail_base) = (CELL)cptr;
mark_external_reference(&TrailTerm(trail_base) PASS_REGS);
TrailTerm(trail_base) = trail_cell;
@ -2486,7 +2486,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS)
CELL *pt0 = RepPair(trail_cell);
CELL flags;
if (IN_BETWEEN(Yap_GlobalBase, pt0, H) && FastIsAttVar(pt0)) {
if (IN_BETWEEN(Yap_GlobalBase, pt0, H) && GlobalIsAttVar(pt0)) {
TrailTerm(dest) = trail_cell;
/* be careful with partial gc */
if (HEAP_PTR(TrailTerm(dest))) {

View File

@ -67,10 +67,11 @@ IsAttVar (CELL *pt)
return (pt)[-1] == (CELL)attvar_e && pt < H;
}
inline EXTERN int GlobalIsAttVar (CELL *pt);
inline EXTERN int
FastIsAttVar (CELL *pt)
GlobalIsAttVar (CELL *pt)
{
CACHE_REGS
return (pt)[-1] == (CELL)attvar_e;
}
@ -517,9 +518,9 @@ IsAttachedTerm (Term t)
inline EXTERN Int IsAttachedTerm (Term);
inline EXTERN Int
FastIsAttachedTerm (Term t)
GlobalIsAttachedTerm (Term t)
{
return (Int) ((IsVarTerm (t) && FastIsAttVar(VarOfTerm(t))));
return (Int) ((IsVarTerm (t) && GlobalIsAttVar(VarOfTerm(t))));
}

View File

@ -974,13 +974,13 @@ Macros to check the limits of stacks
#define UnifyGlobalCells(a, b) \
if ((b) > (a)) { \
if (FastIsAttVar(b) && !FastIsAttVar(a)) { \
if (GlobalIsAttVar(b) && !GlobalIsAttVar(a)) { \
Bind_Global((a),(CELL)(b)); \
} else { \
Bind_Global((b),(CELL)(a)); \
} \
} else if ((b) < (a)) { \
if (FastIsAttVar(a) && !FastIsAttVar(b)) { \
if (GlobalIsAttVar(a) && !GlobalIsAttVar(b)) { \
Bind_Global((b),(CELL)(a)); \
} else { \
Bind_Global((a),(CELL)(b)); \
@ -990,8 +990,8 @@ Macros to check the limits of stacks
#define UnifyGlobalCellToCell(b, a) \
if ((a) < H) { /* two globals */ \
UnifyGlobalCells(a,b); \
} else { \
Bind_Local((a),(CELL)(b)); \
} else { \
Bind_Local((a),(CELL)(b)); \
}
#define UnifyCells(a, b) \

View File

@ -274,14 +274,13 @@ Binding Macros for Multiple Assignment Variables.
extern void Yap_WakeUp(CELL *v);
#define Bind(A,D) { *(A) = (D); TRAIL(A,D); if (FastIsAttVar(A)) Yap_WakeUp(A); }
#define Bind_Local(A,D) { TRAIL_LOCAL(A,D); *(A) = (D); }
#define Bind_Global(A,D) { *(A) = (D); if (GlobalIsAttVar(A)) Yap_WakeUp(A); else TRAIL_GLOBAL(A,D); }
#define Bind(A,D) { *(A) = (D); if (A < H) { if (GlobalIsAttVar(A)) Yap_WakeUp(A); else TRAIL_GLOBAL(A,D); } else { TRAIL_LOCAL(A,D); } }
#define Bind_NonAtt(A,D) { *(A) = (D); TRAIL(A,D); }
#define Bind_Global(A,D) { *(A) = (D); TRAIL_GLOBAL(A,D); if (FastIsAttVar(A)) Yap_WakeUp(A); }
#define Bind_Global_NonAtt(A,D) { *(A) = (D); TRAIL_GLOBAL(A,D); }
#define Bind_and_Trail(A,D) { *(A) = (D); DO_TRAIL(A, D); }
#define Bind_Local(A,D) { TRAIL_LOCAL(A,D); *(A) = (D); }
#define MaBind(VP,D) { MATRAIL((VP),*(VP),(D)); *(VP) = (D); }