From 2fb880b64accc7450d8db3f592fd9ded388ba5bc Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sat, 19 Mar 2011 10:25:23 +0000 Subject: [PATCH] fix bad tests for attributed variable, and use a better name for Quick Test. --- C/attvar.c | 4 ---- C/globals.c | 4 ++-- C/heapgc.c | 8 ++++---- H/TermExt.h | 9 +++++---- H/absmi.h | 8 ++++---- H/amiops.h | 7 +++---- 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/C/attvar.c b/C/attvar.c index 77d87668b..d5646a9fa 100644 --- a/C/attvar.c +++ b/C/attvar.c @@ -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); } diff --git a/C/globals.c b/C/globals.c index faac0510a..04a144444 100644 --- a/C/globals.c +++ b/C/globals.c @@ -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; diff --git a/C/heapgc.c b/C/heapgc.c index c0879f882..aba9e30f7 100755 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -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))) { diff --git a/H/TermExt.h b/H/TermExt.h index 863e02958..932f11201 100644 --- a/H/TermExt.h +++ b/H/TermExt.h @@ -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)))); } diff --git a/H/absmi.h b/H/absmi.h index 131f13180..30938481f 100644 --- a/H/absmi.h +++ b/H/absmi.h @@ -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) \ diff --git a/H/amiops.h b/H/amiops.h index 2e77f1cec..2498a0e17 100644 --- a/H/amiops.h +++ b/H/amiops.h @@ -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); }