iunnumbervars may be copying terms from outside the stacks, so don't share
unless we know we share.
This commit is contained in:
parent
4af0f47b7f
commit
64dded4a53
@ -3898,7 +3898,8 @@ YAP_NumberVars(Term t, Int nbv) {
|
|||||||
|
|
||||||
Term
|
Term
|
||||||
YAP_UnNumberVars(Term t) {
|
YAP_UnNumberVars(Term t) {
|
||||||
return Yap_UnNumberTerm(t);
|
/* don't allow sharing of ground terms */
|
||||||
|
return Yap_UnNumberTerm(t, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -4406,7 +4406,7 @@ Yap_NumberVars( Term inp, Int numbv ) /* numbervariables in term t */
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_numbervars(void)
|
p_numbervars( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t2 = Deref(ARG2);
|
Term t2 = Deref(ARG2);
|
||||||
Int out;
|
Int out;
|
||||||
@ -4425,13 +4425,13 @@ p_numbervars(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unnumber_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, CELL *HLow USES_REGS)
|
unnumber_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, CELL *HLow, int share USES_REGS)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct cp_frame *to_visit0, *to_visit = (struct cp_frame *)Yap_PreAllocCodeSpace();
|
struct cp_frame *to_visit0, *to_visit = (struct cp_frame *)Yap_PreAllocCodeSpace();
|
||||||
CELL *HB0 = HB;
|
CELL *HB0 = HB;
|
||||||
tr_fr_ptr TR0 = TR;
|
tr_fr_ptr TR0 = TR;
|
||||||
int ground = TRUE;
|
int ground = share;
|
||||||
Int max = -1;
|
Int max = -1;
|
||||||
|
|
||||||
HB = HLow;
|
HB = HLow;
|
||||||
@ -4479,7 +4479,7 @@ unnumber_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, CELL *HLow USES_REGS)
|
|||||||
to_visit ++;
|
to_visit ++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ground = TRUE;
|
ground = share;
|
||||||
pt0 = ap2 - 1;
|
pt0 = ap2 - 1;
|
||||||
pt0_end = ap2 + 1;
|
pt0_end = ap2 + 1;
|
||||||
ptf = H;
|
ptf = H;
|
||||||
@ -4555,7 +4555,7 @@ unnumber_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, CELL *HLow USES_REGS)
|
|||||||
to_visit ++;
|
to_visit ++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ground = (f != FunctorMutable);
|
ground = (f != FunctorMutable) && share;
|
||||||
d0 = ArityOfFunctor(f);
|
d0 = ArityOfFunctor(f);
|
||||||
pt0 = ap2;
|
pt0 = ap2;
|
||||||
pt0_end = ap2 + d0;
|
pt0_end = ap2 + d0;
|
||||||
@ -4574,6 +4574,7 @@ unnumber_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, CELL *HLow USES_REGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
derefa_body(d0, ptd0, unnumber_term_unk, unnumber_term_nvar);
|
derefa_body(d0, ptd0, unnumber_term_unk, unnumber_term_nvar);
|
||||||
|
/* this should never happen ? */
|
||||||
ground = FALSE;
|
ground = FALSE;
|
||||||
*ptf++ = (CELL) ptd0;
|
*ptf++ = (CELL) ptd0;
|
||||||
}
|
}
|
||||||
@ -4647,7 +4648,7 @@ unnumber_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, CELL *HLow USES_REGS)
|
|||||||
|
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
UnnumberTerm(Term inp, UInt arity USES_REGS) {
|
UnnumberTerm(Term inp, UInt arity, int share USES_REGS) {
|
||||||
Term t = Deref(inp);
|
Term t = Deref(inp);
|
||||||
tr_fr_ptr TR0 = TR;
|
tr_fr_ptr TR0 = TR;
|
||||||
|
|
||||||
@ -4667,7 +4668,7 @@ UnnumberTerm(Term inp, UInt arity USES_REGS) {
|
|||||||
H += 2;
|
H += 2;
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
if ((res = unnumber_complex_term(ap-1, ap+1, Hi, Hi PASS_REGS)) < 0) {
|
if ((res = unnumber_complex_term(ap-1, ap+1, Hi, Hi, share PASS_REGS)) < 0) {
|
||||||
H = Hi;
|
H = Hi;
|
||||||
if ((t = handle_cp_overflow(res, TR0, arity, t))== 0L)
|
if ((t = handle_cp_overflow(res, TR0, arity, t))== 0L)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -4699,7 +4700,7 @@ UnnumberTerm(Term inp, UInt arity USES_REGS) {
|
|||||||
} else {
|
} else {
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if ((res = unnumber_complex_term(ap, ap+ArityOfFunctor(f), HB0+1, HB0 PASS_REGS)) < 0) {
|
if ((res = unnumber_complex_term(ap, ap+ArityOfFunctor(f), HB0+1, HB0, share PASS_REGS)) < 0) {
|
||||||
H = HB0;
|
H = HB0;
|
||||||
if ((t = handle_cp_overflow(res, TR0, arity, t))== 0L)
|
if ((t = handle_cp_overflow(res, TR0, arity, t))== 0L)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -4714,14 +4715,15 @@ UnnumberTerm(Term inp, UInt arity USES_REGS) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Term
|
Term
|
||||||
Yap_UnNumberTerm(Term inp) {
|
Yap_UnNumberTerm(Term inp, int share) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
return UnnumberTerm(inp, 0 PASS_REGS);
|
return UnnumberTerm(inp, 0, share PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static Int
|
||||||
p_unnumbervars(void) {
|
p_unnumbervars( USES_REGS1 ) {
|
||||||
return Yap_unify(Yap_UnNumberTerm(ARG1), ARG2);
|
/* this should be a standard Prolog term, so we allow sharing? */
|
||||||
|
return Yap_unify(Yap_UnNumberTerm(ARG1, FALSE PASS_REGS), ARG2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Yap_InitUtilCPreds(void)
|
void Yap_InitUtilCPreds(void)
|
||||||
|
@ -398,7 +398,7 @@ int STD_PROTO(Yap_IsGroundTerm,(Term));
|
|||||||
void STD_PROTO(Yap_InitUtilCPreds,(void));
|
void STD_PROTO(Yap_InitUtilCPreds,(void));
|
||||||
Int STD_PROTO(Yap_TermHash,(Term, Int, Int, int));
|
Int STD_PROTO(Yap_TermHash,(Term, Int, Int, int));
|
||||||
Int STD_PROTO(Yap_NumberVars,(Term, Int));
|
Int STD_PROTO(Yap_NumberVars,(Term, Int));
|
||||||
Term STD_PROTO(Yap_UnNumberTerm,(Term));
|
Term STD_PROTO(Yap_UnNumberTerm,(Term, int));
|
||||||
/* yap.c */
|
/* yap.c */
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user