Windows fixes, mainly H -> HB

This commit is contained in:
Vitor Santos Costa 2014-01-19 21:15:05 +00:00
parent e1201fc468
commit 6b2e1973ab
71 changed files with 2278 additions and 2330 deletions

566
C/absmi.c

File diff suppressed because it is too large Load Diff

View File

@ -220,7 +220,7 @@ static void init_reg_copies(USES_REGS1)
LOCAL_OldLCL0 = LCL0;
LOCAL_OldTR = TR;
LOCAL_OldGlobalBase = (CELL *)LOCAL_GlobalBase;
LOCAL_OldH = H;
LOCAL_OldH = HR;
LOCAL_OldH0 = H0;
LOCAL_OldTrailBase = LOCAL_TrailBase;
LOCAL_OldTrailTop = LOCAL_TrailTop;
@ -319,7 +319,7 @@ mark_global_cell(CELL *pt)
/* skip bitmaps */
switch(reg) {
case (CELL)FunctorDouble:
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
return pt + 4;
#else
return pt + 3;
@ -378,7 +378,7 @@ mark_global(USES_REGS1)
* the code
*/
pt = H0;
while (pt < H) {
while (pt < HR) {
pt = mark_global_cell(pt);
}
}

View File

@ -3601,7 +3601,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
if (!pass_no) {
#if !USE_SYSTEM_MALLOC
if (CellPtr(cip->label_offset+cip->cpc->rnd1) > ASP-256) {
LOCAL_Error_Size = 256+((char *)(cip->label_offset+cip->cpc->rnd1) - (char *)H);
LOCAL_Error_Size = 256+((char *)(cip->label_offset+cip->cpc->rnd1) - (char *)HR);
save_machine_regs();
siglongjmp(cip->CompilerBotch, 3);
}
@ -3791,7 +3791,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
break;
case align_float_op:
/* install a blob */
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
if (!((CELL)code_p & 0x4))
GONEXT(e);
#endif
@ -3842,18 +3842,18 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
static DBTerm *
fetch_clause_space(Term* tp, UInt size, struct intermediates *cip, UInt *osizep USES_REGS)
{
CELL *h0 = H;
CELL *h0 = HR;
DBTerm *x;
/* This stuff should be just about fetching the space from the data-base,
unfortunately we have to do all sorts of error handling :-( */
H = (CELL *)cip->freep;
HR = (CELL *)cip->freep;
while ((x = Yap_StoreTermInDBPlusExtraSpace(*tp, size, osizep)) == NULL) {
H = h0;
HR = h0;
switch (LOCAL_Error_TYPE) {
case OUT_OF_STACK_ERROR:
LOCAL_Error_Size = 256+((char *)cip->freep - (char *)H);
LOCAL_Error_Size = 256+((char *)cip->freep - (char *)HR);
save_machine_regs();
siglongjmp(cip->CompilerBotch,3);
case OUT_OF_TRAIL_ERROR:
@ -3885,10 +3885,10 @@ fetch_clause_space(Term* tp, UInt size, struct intermediates *cip, UInt *osizep
default:
return NULL;
}
h0 = H;
H = (CELL *)cip->freep;
h0 = HR;
HR = (CELL *)cip->freep;
}
H = h0;
HR = h0;
return x;
}

View File

@ -138,12 +138,12 @@ eval0(Int fi) {
RINT(((CELL *)TR)-LCL0);
#endif
case op_stackfree:
RINT(Unsigned(ASP) - Unsigned(H));
RINT(Unsigned(ASP) - Unsigned(HR));
case op_globalsp:
#if YAPOR_SBA
RINT((Int)H);
RINT((Int)HR);
#else
RINT(H - H0);
RINT(HR - H0);
#endif
}
RERROR();

View File

@ -152,7 +152,7 @@ lsb(Int inp USES_REGS) /* calculate the least significant bit for an integer */
}
if (inp==0)
return 0L;
#if SIZEOF_LONG_INT == 8
#if SIZEOF_INT_P == 8
if (!(inp & 0xffffffffLL)) {inp >>= 32; out += 32;}
#endif
if (!(inp & 0xffffL)) {inp >>= 16; out += 16;}
@ -373,10 +373,10 @@ eval1(Int fi, Term t USES_REGS) {
}
case op_lgamma:
{
#if HAVE_LGAMMA
Float dbl;
dbl = get_float(t);
#if HAVE_LGAMMA
RFLOAT(lgamma(dbl));
#else
RERROR();
@ -384,8 +384,8 @@ eval1(Int fi, Term t USES_REGS) {
}
case op_erf:
{
Float dbl = get_float(t), out;
#if HAVE_ERF
Float dbl = get_float(t), out;
out = erf(dbl);
RFLOAT(out);
#else
@ -394,8 +394,8 @@ eval1(Int fi, Term t USES_REGS) {
}
case op_erfc:
{
Float dbl = get_float(t), out;
#if HAVE_ERF
Float dbl = get_float(t), out;
out = erfc(dbl);
RFLOAT(out);
#else

View File

@ -545,14 +545,14 @@ InitNamedArray(ArrayEntry * p, Int dim USES_REGS)
/* Leave a pointer so that we can reclaim array space when
* we backtrack or when we abort */
/* place terms in reverse order */
Bind_Global(&(p->ValueOfVE),AbsAppl(H));
tp = H;
Bind_Global(&(p->ValueOfVE),AbsAppl(HR));
tp = HR;
tp[0] = (CELL)Yap_MkFunctor(AtomArray, dim);
tp++;
p->ArrayEArity = dim;
/* Initialise the array as a set of variables */
H = tp+dim;
for (; tp < H; tp++) {
HR = tp+dim;
for (; tp < HR; tp++) {
RESET_VARIABLE(tp);
}
WRITE_UNLOCK(p->ArRWLock);
@ -887,13 +887,13 @@ p_create_array( USES_REGS1 )
Functor farray;
farray = Yap_MkFunctor(AtomArray, size);
if (H+1+size > ASP-1024) {
if (HR+1+size > ASP-1024) {
if (!Yap_gcl((1+size)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,LOCAL_ErrorMessage);
return(FALSE);
} else {
if (H+1+size > ASP-1024) {
if (!Yap_growstack( sizeof(CELL) * (size+1-(H-ASP-1024)))) {
if (HR+1+size > ASP-1024) {
if (!Yap_growstack( sizeof(CELL) * (size+1-(HR-ASP-1024)))) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
@ -901,11 +901,11 @@ p_create_array( USES_REGS1 )
}
goto restart;
}
t = AbsAppl(H);
*H++ = (CELL) farray;
t = AbsAppl(HR);
*HR++ = (CELL) farray;
for (; size >= 0; size--) {
RESET_VARIABLE(H);
H++;
RESET_VARIABLE(HR);
HR++;
}
return (Yap_unify(t, ARG1));
}
@ -924,7 +924,7 @@ p_create_array( USES_REGS1 )
)
pp = RepProp(pp->NextOfPE);
if (EndOfPAEntr(pp)) {
if (H+1+size > ASP-1024) {
if (HR+1+size > ASP-1024) {
WRITE_UNLOCK(ae->ARWLock);
if (!Yap_gcl((1+size)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,LOCAL_ErrorMessage);
@ -946,7 +946,7 @@ p_create_array( USES_REGS1 )
Yap_Error(PERMISSION_ERROR_CREATE_ARRAY,t,"create_array",
ae->StrOfAE);
} else {
if (H+1+size > ASP-1024) {
if (HR+1+size > ASP-1024) {
if (!Yap_gcl((1+size)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,LOCAL_ErrorMessage);
return(FALSE);
@ -1411,7 +1411,7 @@ loop:
}
else if (IsPairTerm(d0)) {
/* store the terms to visit */
*ptn++ = AbsPair(H);
*ptn++ = AbsPair(HR);
#ifdef RATIONAL_TREES
to_visit[0] = pt0;
to_visit[1] = pt0_end;
@ -1430,8 +1430,8 @@ loop:
pt0 = RepPair(d0) - 1;
pt0_end = RepPair(d0) + 1;
/* write the head and tail of the list */
ptn = H;
H += 2;
ptn = HR;
HR += 2;
}
else if (IsApplTerm(d0)) {
register Functor f;
@ -1444,7 +1444,7 @@ loop:
continue;
}
}
*ptn++ = AbsAppl(H);
*ptn++ = AbsAppl(HR);
/* store the terms to visit */
#ifdef RATIONAL_TREES
to_visit[0] = pt0;
@ -1465,9 +1465,9 @@ loop:
d0 = ArityOfFunctor(f);
pt0_end = pt0 + d0;
/* start writing the compound term */
ptn = H;
ptn = HR;
*ptn++ = (CELL) f;
H += d0 + 1;
HR += d0 + 1;
}
else { /* AtomOrInt */
*ptn++ = d0;
@ -1516,19 +1516,19 @@ replace_array_references(Term t0 USES_REGS)
return (MkPairTerm(t, TermNil));
} else if (IsPairTerm(t)) {
Term VList = MkVarTerm();
CELL *h0 = H;
CELL *h0 = HR;
H += 2;
HR += 2;
replace_array_references_complex(RepPair(t) - 1, RepPair(t) + 1, h0,
VList PASS_REGS);
return MkPairTerm(AbsPair(h0), VList);
} else {
Term VList = MkVarTerm();
CELL *h0 = H;
CELL *h0 = HR;
Functor f = FunctorOfTerm(t);
*H++ = (CELL) (f);
H += ArityOfFunctor(f);
*HR++ = (CELL) (f);
HR += ArityOfFunctor(f);
replace_array_references_complex(RepAppl(t),
RepAppl(t) + ArityOfFunctor(FunctorOfTerm(t)), h0 + 1,
VList PASS_REGS);
@ -2263,13 +2263,13 @@ p_static_array_to_term( USES_REGS1 )
Int dim = pp->ArrayEArity, indx;
CELL *base;
while (H+1+dim > ASP-1024) {
while (HR+1+dim > ASP-1024) {
if (!Yap_gcl((1+dim)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,LOCAL_ErrorMessage);
return(FALSE);
} else {
if (H+1+dim > ASP-1024) {
if (!Yap_growstack( sizeof(CELL) * (dim+1-(H-ASP-1024)))) {
if (HR+1+dim > ASP-1024) {
if (!Yap_growstack( sizeof(CELL) * (dim+1-(HR-ASP-1024)))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
@ -2278,13 +2278,13 @@ p_static_array_to_term( USES_REGS1 )
}
READ_LOCK(pp->ArRWLock);
READ_UNLOCK(ae->ARWLock);
base = H;
*H++ = (CELL)Yap_MkFunctor(AbsAtom(ae),dim);
base = HR;
*HR++ = (CELL)Yap_MkFunctor(AbsAtom(ae),dim);
switch(tp) {
case array_of_ints:
{
CELL *sptr = H;
H += dim;
CELL *sptr = HR;
HR += dim;
for (indx=0; indx < dim; indx++) {
*sptr++ = MkIntegerTerm(pp->ValueOfVE.ints[indx]);
}
@ -2311,13 +2311,13 @@ p_static_array_to_term( USES_REGS1 )
} else {
TRef = TermNil;
}
*H++ = TRef;
*HR++ = TRef;
}
break;
case array_of_doubles:
{
CELL *sptr = H;
H += dim;
CELL *sptr = HR;
HR += dim;
for (indx=0; indx < dim; indx++) {
*sptr++ = MkEvalFl(pp->ValueOfVE.floats[indx]);
}
@ -2325,8 +2325,8 @@ p_static_array_to_term( USES_REGS1 )
break;
case array_of_ptrs:
{
CELL *sptr = H;
H += dim;
CELL *sptr = HR;
HR += dim;
for (indx=0; indx < dim; indx++) {
*sptr++ = MkIntegerTerm((Int)(pp->ValueOfVE.ptrs[indx]));
}
@ -2334,8 +2334,8 @@ p_static_array_to_term( USES_REGS1 )
break;
case array_of_chars:
{
CELL *sptr = H;
H += dim;
CELL *sptr = HR;
HR += dim;
for (indx=0; indx < dim; indx++) {
*sptr++ = MkIntegerTerm((Int)(pp->ValueOfVE.chars[indx]));
}
@ -2343,8 +2343,8 @@ p_static_array_to_term( USES_REGS1 )
break;
case array_of_uchars:
{
CELL *sptr = H;
H += dim;
CELL *sptr = HR;
HR += dim;
for (indx=0; indx < dim; indx++) {
*sptr++ = MkIntegerTerm((Int)(pp->ValueOfVE.uchars[indx]));
}
@ -2352,8 +2352,8 @@ p_static_array_to_term( USES_REGS1 )
break;
case array_of_terms:
{
CELL *sptr = H;
H += dim;
CELL *sptr = HR;
HR += dim;
for (indx=0; indx < dim; indx++) {
/* The object is now in use */
DBTerm *ref = pp->ValueOfVE.terms[indx];
@ -2370,8 +2370,8 @@ p_static_array_to_term( USES_REGS1 )
break;
case array_of_nb_terms:
{
CELL *sptr = H;
H += dim;
CELL *sptr = HR;
HR += dim;
for (indx=0; indx < dim; indx++) {
/* The object is now in use */
Term To = GetNBTerm(pp->ValueOfVE.lterms, indx PASS_REGS);
@ -2390,7 +2390,7 @@ p_static_array_to_term( USES_REGS1 )
out = pp->ValueOfVE.atoms[indx];
if (out == 0L)
out = TermNil;
*H++ = out;
*HR++ = out;
}
break;
}

View File

@ -1083,8 +1083,8 @@ p_atom_split( USES_REGS1 )
}
at = AtomOfTerm(t1);
if (IsWideAtom(at)) {
wchar_t *ws, *ws1 = (wchar_t *)H;
char *s1 = (char *)H;
wchar_t *ws, *ws1 = (wchar_t *)HR;
char *s1 = (char *)HR;
size_t wlen;
ws = (wchar_t *)RepAtom(at)->StrOfAE;
@ -1112,12 +1112,12 @@ p_atom_split( USES_REGS1 )
if (is_wide(ws+len)) {
to2 = MkAtomTerm(Yap_LookupWideAtom(ws+len));
} else {
char *s2 = (char *)H;
char *s2 = (char *)HR;
if (s2+(wlen-len) > (char *)ASP-1024)
Yap_Error(OUT_OF_STACK_ERROR,t1,"$atom_split/4");
ws += len;
while ((*s2++ = *ws++));
to2 = MkAtomTerm(Yap_LookupAtom((char *)H));
to2 = MkAtomTerm(Yap_LookupAtom((char *)HR));
}
} else {
s1[len] = '\0';
@ -1126,7 +1126,7 @@ p_atom_split( USES_REGS1 )
to2 = MkAtomTerm(Yap_LookupWideAtom(ws+len));
}
} else {
char *s, *s1 = (char *)H;
char *s, *s1 = (char *)HR;
s = RepAtom(at)->StrOfAE;
if (len > (Int)strlen(s)) return(FALSE);
@ -1203,8 +1203,8 @@ p_string_number( USES_REGS1 )
static void *
alloc_tmp_stack(size_t sz USES_REGS) {
void *pt = (void *)H;
while (H > ASP-(1044+sz/sizeof(CELL))) {
void *pt = (void *)HR;
while (HR > ASP-(1044+sz/sizeof(CELL))) {
if (!Yap_gc(5, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "sub_atom/5");
return(NULL);
@ -1245,7 +1245,7 @@ build_new_atomic(int mask, wchar_t *wp, char *p, size_t min, size_t len USES_REG
char *cp = src, *buf, *lim = cp+strlen(cp);
LOCAL_TERM_ERROR( 4*(len+1) );
buf = buf_from_tstring(H);
buf = buf_from_tstring(HR);
while (cp < lim) {
int chr;
cp = utf8_get_char(cp, &chr);

View File

@ -73,8 +73,8 @@ BuildNewAttVar( USES_REGS1 )
attvar_record *newv;
/* add a new attributed variable */
newv = (attvar_record *)H;
H = (CELL *)(newv+1);
newv = (attvar_record *)HR;
HR = (CELL *)(newv+1);
newv->AttFunc = FunctorAttVar;
RESET_VARIABLE(&(newv->Value));
RESET_VARIABLE(&(newv->Done));
@ -97,9 +97,9 @@ CopyAttVar(CELL *orig, struct cp_frame **to_visit_ptr, CELL *res USES_REGS)
to_visit->start_cp = vt-1;
to_visit->end_cp = vt;
if (IsVarTerm(attv->Atts)) {
Bind_Global_NonAtt(&newv->Atts, (CELL)H);
to_visit->to = H;
H++;
Bind_Global_NonAtt(&newv->Atts, (CELL)HR);
to_visit->to = HR;
HR++;
} else {
to_visit->to = &(newv->Atts);
}
@ -156,7 +156,7 @@ WakeAttVar(CELL* pt1, CELL reg2 USES_REGS)
/* if bound to someone else, follow until we find the last one */
attvar_record *attv = RepAttVar(pt1);
CELL *myH = H;
CELL *myH = HR;
CELL *bind_ptr;
if (IsVarTerm(Deref(attv->Atts))) {
@ -201,9 +201,9 @@ WakeAttVar(CELL* pt1, CELL reg2 USES_REGS)
bind_ptr = AddToQueue(attv PASS_REGS);
if (IsNonVarTerm(reg2)) {
if (IsPairTerm(reg2) && RepPair(reg2) == myH)
reg2 = AbsPair(H);
reg2 = AbsPair(HR);
else if (IsApplTerm(reg2) && RepAppl(reg2) == myH)
reg2 = AbsAppl(H);
reg2 = AbsAppl(HR);
}
*bind_ptr = reg2;
Bind_Global_NonAtt(&(attv->Value), reg2);
@ -227,19 +227,19 @@ mark_attvar(CELL *orig)
static Term
BuildAttTerm(Functor mfun, UInt ar USES_REGS)
{
CELL *h0 = H;
CELL *h0 = HR;
UInt i;
if (H+(1024+ar) > ASP) {
if (HR+(1024+ar) > ASP) {
LOCAL_Error_Size=ar*sizeof(CELL);
return 0L;
}
H[0] = (CELL)mfun;
RESET_VARIABLE(H+1);
H += 2;
HR[0] = (CELL)mfun;
RESET_VARIABLE(HR+1);
HR += 2;
for (i = 1; i< ar; i++) {
*H = TermVoidAtt;
H++;
*HR = TermVoidAtt;
HR++;
}
return AbsAppl(h0);
}
@ -390,7 +390,7 @@ DelAtts(attvar_record *attv, Term oatt USES_REGS)
static void
PutAtt(Int pos, Term atts, Term att USES_REGS)
{
if (IsVarTerm(att) && VarOfTerm(att) > H && VarOfTerm(att) < LCL0) {
if (IsVarTerm(att) && VarOfTerm(att) > HR && VarOfTerm(att) < LCL0) {
/* globalise locals */
Term tnew = MkVarTerm();
Bind_NonAtt(VarOfTerm(att), tnew);
@ -850,23 +850,23 @@ p_modules_with_atts( USES_REGS1 ) {
if (IsVarTerm(inp)) {
if (IsAttachedTerm(inp)) {
attvar_record *attv = RepAttVar(VarOfTerm(inp));
CELL *h0 = H;
CELL *h0 = HR;
Term tatt;
if (IsVarTerm(tatt = attv->Atts))
return Yap_unify(ARG2,TermNil);
while (!IsVarTerm(tatt)) {
Functor f = FunctorOfTerm(tatt);
if (H != h0)
H[-1] = AbsPair(H);
if (HR != h0)
HR[-1] = AbsPair(HR);
if (ActiveAtt(tatt, ArityOfFunctor(f))) {
*H = MkAtomTerm(NameOfFunctor(f));
H+=2;
*HR = MkAtomTerm(NameOfFunctor(f));
HR+=2;
}
tatt = ArgOfTerm(1,tatt);
}
if (h0 != H) {
H[-1] = TermNil;
if (h0 != HR) {
HR[-1] = TermNil;
return Yap_unify(ARG2,AbsPair(h0));
}
}
@ -887,7 +887,7 @@ p_swi_all_atts( USES_REGS1 ) {
if (IsVarTerm(inp)) {
if (IsAttachedTerm(inp)) {
attvar_record *attv = RepAttVar(VarOfTerm(inp));
CELL *h0 = H;
CELL *h0 = HR;
Term tatt;
if (IsVarTerm(tatt = attv->Atts))
@ -896,21 +896,21 @@ p_swi_all_atts( USES_REGS1 ) {
Functor f = FunctorOfTerm(tatt);
UInt ar = ArityOfFunctor(f);
if (H != h0)
H[-1] = AbsAppl(H);
H[0] = (CELL) attf;
H[1] = MkAtomTerm(NameOfFunctor(f));
if (HR != h0)
HR[-1] = AbsAppl(HR);
HR[0] = (CELL) attf;
HR[1] = MkAtomTerm(NameOfFunctor(f));
/* SWI */
if (ar == 2)
H[2] = ArgOfTerm(2,tatt);
HR[2] = ArgOfTerm(2,tatt);
else
H[2] = tatt;
H += 4;
H[-1] = AbsAppl(H);
HR[2] = tatt;
HR += 4;
HR[-1] = AbsAppl(HR);
tatt = ArgOfTerm(1,tatt);
}
if (h0 != H) {
H[-1] = TermNil;
if (h0 != HR) {
HR[-1] = TermNil;
return Yap_unify(ARG2,AbsAppl(h0));
}
}
@ -925,17 +925,17 @@ p_swi_all_atts( USES_REGS1 ) {
static Term
AllAttVars( USES_REGS1 ) {
CELL *pt = H0;
CELL *myH = H;
CELL *myH = HR;
while (pt < myH) {
switch(*pt) {
case (CELL)FunctorAttVar:
if (IsUnboundVar(pt+1)) {
if (ASP - myH < 1024) {
LOCAL_Error_Size = (ASP-H)*sizeof(CELL);
LOCAL_Error_Size = (ASP-HR)*sizeof(CELL);
return 0L;
}
if (myH != H) {
if (myH != HR) {
myH[-1] = AbsPair(myH);
}
myH[0] = AbsAttVar((attvar_record *)pt);
@ -944,7 +944,7 @@ AllAttVars( USES_REGS1 ) {
pt += (1+ATT_RECORD_ARITY);
break;
case (CELL)FunctorDouble:
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
pt += 4;
#else
pt += 3;
@ -968,10 +968,10 @@ AllAttVars( USES_REGS1 ) {
pt++;
}
}
if (myH != H) {
Term out = AbsPair(H);
if (myH != HR) {
Term out = AbsPair(HR);
myH[-1] = TermNil;
H = myH;
HR = myH;
return out;
} else {
return TermNil;

View File

@ -38,8 +38,8 @@ Yap_MkBigIntTerm(MP_INT *big)
{
CACHE_REGS
Int nlimbs;
MP_INT *dst = (MP_INT *)(H+2);
CELL *ret = H;
MP_INT *dst = (MP_INT *)(HR+2);
CELL *ret = HR;
Int bytes;
if (mpz_fits_slong_p(big)) {
@ -54,15 +54,15 @@ Yap_MkBigIntTerm(MP_INT *big)
if (nlimbs > (ASP-ret)-1024) {
return TermNil;
}
H[0] = (CELL)FunctorBigInt;
H[1] = BIG_INT;
HR[0] = (CELL)FunctorBigInt;
HR[1] = BIG_INT;
dst->_mp_size = big->_mp_size;
dst->_mp_alloc = nlimbs*(CellSize/sizeof(mp_limb_t));
memmove((void *)(dst+1), (const void *)(big->_mp_d), bytes);
H = (CELL *)(dst+1)+nlimbs;
H[0] = EndSpecials;
H++;
HR = (CELL *)(dst+1)+nlimbs;
HR[0] = EndSpecials;
HR++;
return AbsAppl(ret);
}
@ -81,19 +81,19 @@ Yap_MkBigRatTerm(MP_RAT *big)
{
CACHE_REGS
Int nlimbs;
MP_INT *dst = (MP_INT *)(H+2);
MP_INT *dst = (MP_INT *)(HR+2);
MP_INT *num = mpq_numref(big);
MP_INT *den = mpq_denref(big);
MP_RAT *rat;
CELL *ret = H;
CELL *ret = HR;
if (mpz_cmp_si(den, 1) == 0)
return Yap_MkBigIntTerm(num);
if ((num->_mp_alloc+den->_mp_alloc)*(sizeof(mp_limb_t)/CellSize) > (ASP-ret)-1024) {
return TermNil;
}
H[0] = (CELL)FunctorBigInt;
H[1] = BIG_RATIONAL;
HR[0] = (CELL)FunctorBigInt;
HR[1] = BIG_RATIONAL;
dst->_mp_size = 0;
rat = (MP_RAT *)(dst+1);
rat->_mp_num._mp_size = num->_mp_size;
@ -102,13 +102,13 @@ Yap_MkBigRatTerm(MP_RAT *big)
memmove((void *)(rat+1), (const void *)(num->_mp_d), nlimbs*CellSize);
rat->_mp_den._mp_size = den->_mp_size;
rat->_mp_den._mp_alloc = den->_mp_alloc;
H = (CELL *)(rat+1)+nlimbs;
HR = (CELL *)(rat+1)+nlimbs;
nlimbs = (den->_mp_alloc)*(sizeof(mp_limb_t)/CellSize);
memmove((void *)(H), (const void *)(den->_mp_d), nlimbs*CellSize);
H += nlimbs;
dst->_mp_alloc = (H-(CELL *)(dst+1));
H[0] = EndSpecials;
H++;
memmove((void *)(HR), (const void *)(den->_mp_d), nlimbs*CellSize);
HR += nlimbs;
dst->_mp_alloc = (HR-(CELL *)(dst+1));
HR[0] = EndSpecials;
HR++;
return AbsAppl(ret);
}
@ -142,20 +142,20 @@ Yap_AllocExternalDataInStack(CELL tag, size_t bytes)
{
CACHE_REGS
Int nlimbs;
MP_INT *dst = (MP_INT *)(H+2);
CELL *ret = H;
MP_INT *dst = (MP_INT *)(HR+2);
CELL *ret = HR;
nlimbs = ALIGN_YAPTYPE(bytes,CELL)/CellSize;
if (nlimbs > (ASP-ret)-1024) {
return TermNil;
}
H[0] = (CELL)FunctorBigInt;
H[1] = tag;
HR[0] = (CELL)FunctorBigInt;
HR[1] = tag;
dst->_mp_size = 0;
dst->_mp_alloc = nlimbs;
H = (CELL *)(dst+1)+nlimbs;
H[0] = EndSpecials;
H++;
HR = (CELL *)(dst+1)+nlimbs;
HR[0] = EndSpecials;
HR++;
if (tag != EXTERNAL_BLOB) {
TrailTerm(TR) = AbsPair(ret);
TR++;

View File

@ -379,8 +379,6 @@
#if defined(_MSC_VER) && defined(YAP_EXPORTS)
#define X_API __declspec(dllexport)
#else
#define X_API
#endif
X_API Term YAP_A(int);
@ -802,21 +800,21 @@ YAP_MkBlobTerm(unsigned int sz)
MP_INT *dst;
BACKUP_H();
while (H+(sz+sizeof(MP_INT)/sizeof(CELL)+2) > ASP-1024) {
while (HR+(sz+sizeof(MP_INT)/sizeof(CELL)+2) > ASP-1024) {
if (!doexpand((sz+sizeof(MP_INT)/sizeof(CELL)+2)*sizeof(CELL))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "YAP failed to grow the stack while constructing a blob: %s", LOCAL_ErrorMessage);
return TermNil;
}
}
I = AbsAppl(H);
H[0] = (CELL)FunctorBigInt;
H[1] = ARRAY_INT;
dst = (MP_INT *)(H+2);
I = AbsAppl(HR);
HR[0] = (CELL)FunctorBigInt;
HR[1] = ARRAY_INT;
dst = (MP_INT *)(HR+2);
dst->_mp_size = 0L;
dst->_mp_alloc = sz;
H += (2+sizeof(MP_INT)/sizeof(CELL));
H[sz] = EndSpecials;
H += sz+1;
HR += (2+sizeof(MP_INT)/sizeof(CELL));
HR[sz] = EndSpecials;
HR += sz+1;
RECOVER_H();
return I;
@ -982,7 +980,7 @@ YAP_MkPairTerm(Term t1, Term t2)
Term t;
BACKUP_H();
while (H > ASP-1024) {
while (HR > ASP-1024) {
Int sl1 = Yap_InitSlot(t1 PASS_REGS);
Int sl2 = Yap_InitSlot(t2 PASS_REGS);
RECOVER_H();
@ -1008,7 +1006,7 @@ YAP_MkListFromTerms(Term *ta, Int sz)
if (sz == 0)
return TermNil;
BACKUP_H();
while (H+sz*2 > ASP-1024) {
while (HR+sz*2 > ASP-1024) {
Int sl1 = Yap_InitSlot((CELL)ta PASS_REGS);
RECOVER_H();
if (!Yap_dogc( 0, NULL PASS_REGS )) {
@ -1018,7 +1016,7 @@ YAP_MkListFromTerms(Term *ta, Int sz)
ta = (CELL *)Yap_GetFromSlot(sl1 PASS_REGS);
Yap_RecoverSlots(1 PASS_REGS);
}
h = H;
h = HR;
t = AbsPair(h);
while (sz--) {
Term ti = *ta++;
@ -1032,7 +1030,7 @@ YAP_MkListFromTerms(Term *ta, Int sz)
h += 2;
}
h[-1] = TermNil;
H = h;
HR = h;
RECOVER_H();
return t;
}
@ -1044,7 +1042,7 @@ YAP_MkNewPairTerm()
Term t;
BACKUP_H();
if (H > ASP-1024)
if (HR > ASP-1024)
t = TermNil;
else
t = Yap_MkNewPairTerm();
@ -1102,7 +1100,7 @@ YAP_MkApplTerm(Functor f,UInt arity, Term args[])
Term t;
BACKUP_H();
if (H+arity > ASP-1024)
if (HR+arity > ASP-1024)
t = TermNil;
else
t = Yap_MkApplTerm(f, arity, args);
@ -1118,7 +1116,7 @@ YAP_MkNewApplTerm(Functor f,UInt arity)
Term t;
BACKUP_H();
if (H+arity > ASP-1024)
if (HR+arity > ASP-1024)
t = TermNil;
else
t = Yap_MkNewApplTerm(f, arity);
@ -1193,7 +1191,7 @@ YAP_ExtraSpace(void)
/* find a pointer to extra space allocable */
ptr = (void *)((CELL *)(B+1)+P->u.OtapFs.s);
B->cp_h = H;
B->cp_h = HR;
RECOVER_H();
RECOVER_B();
@ -2466,7 +2464,7 @@ YAP_LeaveGoal(int backtrack, YAP_dogoalinfo *dgi)
P = FAILCODE;
Yap_exec_absmi(TRUE);
/* recover stack space */
H = B->cp_h;
HR = B->cp_h;
TR = B->cp_tr;
#ifdef DEPTH_LIMIT
DEPTH = B->cp_depth;
@ -2702,7 +2700,7 @@ YAP_ShutdownGoal(int backtrack)
P = FAILCODE;
Yap_exec_absmi(TRUE);
/* recover stack space */
H = cut_pt->cp_h;
HR = cut_pt->cp_h;
TR = cut_pt->cp_tr;
}
/* we can always recover the stack */
@ -3381,9 +3379,6 @@ YAP_Reset(void)
{
CACHE_REGS
int res = TRUE;
#if !defined(YAPOR) && !defined(THREADS)
int worker_id = 0;
#endif
BACKUP_MACHINE_REGS();
YAP_ClearExceptions();
@ -3707,8 +3702,8 @@ YAP_FloatsToList(double *dblp, size_t sz)
if (!sz)
return TermNil;
while (ASP-1024 < H + sz*(2+2+SIZEOF_DOUBLE/SIZEOF_LONG_INT)) {
if ((CELL *)dblp > H0 && (CELL *)dblp < H) {
while (ASP-1024 < HR + sz*(2+2+SIZEOF_DOUBLE/SIZEOF_INT_P)) {
if ((CELL *)dblp > H0 && (CELL *)dblp < HR) {
/* we are in trouble */
LOCAL_OpenArray = (CELL *)dblp;
}
@ -3719,12 +3714,12 @@ YAP_FloatsToList(double *dblp, size_t sz)
dblp = (double *)LOCAL_OpenArray;
LOCAL_OpenArray = NULL;
}
t = AbsPair(H);
t = AbsPair(HR);
while (sz) {
oldH = H;
H +=2;
oldH = HR;
HR +=2;
oldH[0] = MkFloatTerm(*dblp++);
oldH[1] = AbsPair(H);
oldH[1] = AbsPair(HR);
sz--;
}
oldH[1] = TermNil;
@ -3779,8 +3774,8 @@ YAP_IntsToList(Int *dblp, size_t sz)
if (!sz)
return TermNil;
while (ASP-1024 < H + sz*3) {
if ((CELL *)dblp > H0 && (CELL *)dblp < H) {
while (ASP-1024 < HR + sz*3) {
if ((CELL *)dblp > H0 && (CELL *)dblp < HR) {
/* we are in trouble */
LOCAL_OpenArray = (CELL *)dblp;
}
@ -3791,12 +3786,12 @@ YAP_IntsToList(Int *dblp, size_t sz)
dblp = (Int *)LOCAL_OpenArray;
LOCAL_OpenArray = NULL;
}
t = AbsPair(H);
t = AbsPair(HR);
while (sz) {
oldH = H;
H +=2;
oldH = HR;
HR +=2;
oldH[0] = MkIntegerTerm(*dblp++);
oldH[1] = AbsPair(H);
oldH[1] = AbsPair(HR);
sz--;
}
oldH[1] = TermNil;
@ -3835,14 +3830,14 @@ YAP_OpenList(int n)
Term t;
BACKUP_H();
while (H+2*n > ASP-1024) {
while (HR+2*n > ASP-1024) {
if (!Yap_dogc( 0, NULL PASS_REGS )) {
RECOVER_H();
return FALSE;
}
}
t = AbsPair(H);
H += 2*n;
t = AbsPair(HR);
HR += 2*n;
RECOVER_H();
return t;
@ -4055,7 +4050,7 @@ YAP_SetYAPFlag(yap_flag_t flag, int val)
Int YAP_VarSlotToNumber(Int s) {
CACHE_REGS
Term *t = (CELL *)Deref(Yap_GetFromSlot(s PASS_REGS));
if (t < H)
if (t < HR)
return t-H0;
return t-LCL0;
}
@ -4265,11 +4260,11 @@ YAP_RequiresExtraStack(size_t sz) {
if (sz < 16*1024)
sz = 16*1024;
if (H <= ASP-sz) {
if (HR <= ASP-sz) {
return FALSE;
}
BACKUP_H();
while (H > ASP-sz) {
while (HR > ASP-sz) {
CACHE_REGS
RECOVER_H();
if (!Yap_dogc( 0, NULL PASS_REGS )) {

View File

@ -3520,26 +3520,26 @@ Yap_find_owner_index(yamop *ipc, PredEntry *ap)
static Term
all_envs(CELL *env_ptr USES_REGS)
{
Term tf = AbsPair(H);
CELL *start = H;
Term tf = AbsPair(HR);
CELL *start = HR;
CELL *bp = NULL;
/* walk the environment chain */
while (env_ptr) {
bp = H;
H += 2;
bp = HR;
HR += 2;
/* notice that MkIntegerTerm may increase the Heap */
bp[0] = MkIntegerTerm(LCL0-env_ptr);
if (H >= ASP-1024) {
H = start;
LOCAL_Error_Size = (ASP-1024)-H;
if (HR >= ASP-1024) {
HR = start;
LOCAL_Error_Size = (ASP-1024)-HR;
while (env_ptr) {
LOCAL_Error_Size += 2;
env_ptr = (CELL *)(env_ptr[E_E]);
}
return 0L;
} else {
bp[1] = AbsPair(H);
bp[1] = AbsPair(HR);
}
env_ptr = (CELL *)(env_ptr[E_E]);
}
@ -3551,24 +3551,24 @@ static Term
all_cps(choiceptr b_ptr USES_REGS)
{
CELL *bp = NULL;
CELL *start = H;
Term tf = AbsPair(H);
CELL *start = HR;
Term tf = AbsPair(HR);
while (b_ptr) {
bp = H;
H += 2;
bp = HR;
HR += 2;
/* notice that MkIntegerTerm may increase the Heap */
bp[0] = MkIntegerTerm((Int)(LCL0-(CELL *)b_ptr));
if (H >= ASP-1024) {
H = start;
LOCAL_Error_Size = (ASP-1024)-H;
if (HR >= ASP-1024) {
HR = start;
LOCAL_Error_Size = (ASP-1024)-HR;
while (b_ptr) {
LOCAL_Error_Size += 2;
b_ptr = b_ptr->cp_b;
}
return 0L;
} else {
bp[1] = AbsPair(H);
bp[1] = AbsPair(HR);
}
b_ptr = b_ptr->cp_b;
}
@ -4992,7 +4992,7 @@ Yap_UpdateTimestamps(PredEntry *ap)
if (bptr->cp_ap->u.OtaLl.d->ClPred == ap) {
UInt ts = IntegerOfTerm(bptr->cp_args[ar]);
if (ts != arp[0]) {
if (arp-H < 1024) {
if (arp-HR < 1024) {
goto overflow;
}
/* be thrifty, have this in case there is a hole */
@ -5010,7 +5010,7 @@ Yap_UpdateTimestamps(PredEntry *ap)
((PredEntry *)IntegerOfTerm(bptr->cp_args[0]) == ap)) {
UInt ts = IntegerOfTerm(bptr->cp_args[5]);
if (ts != arp[0]) {
if (arp-H < 1024) {
if (arp-HR < 1024) {
goto overflow;
}
if (ts != arp[0]-1) {
@ -5562,7 +5562,7 @@ BuildActivePred(PredEntry *ap, CELL *vect)
if (IsVarTerm(t)) {
CELL *pt = VarOfTerm(t);
/* one stack */
if (pt > H) {
if (pt > HR) {
Term nt = MkVarTerm();
Yap_unify(t, nt);
}

View File

@ -13,14 +13,14 @@ mk_blob(int sz USES_REGS)
{
MP_INT *dst;
H[0] = (CELL)FunctorBigInt;
H[1] = CLAUSE_LIST;
dst = (MP_INT *)(H+2);
HR[0] = (CELL)FunctorBigInt;
HR[1] = CLAUSE_LIST;
dst = (MP_INT *)(HR+2);
dst->_mp_size = 0L;
dst->_mp_alloc = sz;
H += (1+sizeof(MP_INT)/sizeof(CELL));
H[sz] = EndSpecials;
H += sz+1;
HR += (1+sizeof(MP_INT)/sizeof(CELL));
HR[sz] = EndSpecials;
HR += sz+1;
}
static CELL *
@ -29,14 +29,14 @@ extend_blob(CELL *start, int sz USES_REGS)
UInt osize;
MP_INT *dst;
if (H + sz > ASP)
if (HR + sz > ASP)
return NULL;
dst = (MP_INT *)(start+2);
osize = dst->_mp_alloc;
start += (1+sizeof(MP_INT)/sizeof(CELL));
start[sz+osize] = EndSpecials;
dst->_mp_alloc += sz;
H += sz;
HR += sz;
return start+osize;
}
@ -46,9 +46,9 @@ Yap_ClauseListInit(clause_list_t in)
{
CACHE_REGS
in->n = 0;
in->start = H;
in->start = HR;
mk_blob(0 PASS_REGS);
in->end = H;
in->end = HR;
return in;
}
@ -61,7 +61,7 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
PredEntry *ap = (PredEntry *)pred;
/* fprintf(stderr,"cl=%p\n",clause); */
if (cl->end != H)
if (cl->end != HR)
return FALSE;
if (cl->n == 0) {
void **ptr;
@ -112,7 +112,7 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
code_p = PREVOP(code_p,Otapl);
code_p->opc = Yap_opcode(_retry);
}
cl->end = H;
cl->end = HR;
cl->n++;
return TRUE;
}
@ -129,9 +129,9 @@ X_API int
Yap_ClauseListDestroy(clause_list_t cl)
{
CACHE_REGS
if (cl->end != H)
if (cl->end != HR)
return FALSE;
H = cl->start;
HR = cl->start;
return TRUE;
}
@ -141,7 +141,7 @@ Yap_ClauseListToClause(clause_list_t cl)
{
CACHE_REGS
void **ptr;
if (cl->end != H)
if (cl->end != HR)
return NULL;
if (cl->n != 1)
return NULL;

View File

@ -82,7 +82,7 @@ static int compare_complex(register CELL *pt0, register CELL *pt0_end, register
CELL *pt1)
{
CACHE_REGS
register CELL **to_visit = (CELL **)H;
register CELL **to_visit = (CELL **)HR;
register int out = 0;
loop:
@ -289,7 +289,7 @@ static int compare_complex(register CELL *pt0, register CELL *pt0_end, register
}
}
/* Do we still have compound terms to visit */
if (to_visit > (CELL **)H) {
if (to_visit > (CELL **)HR) {
#ifdef RATIONAL_TREES
to_visit -= 4;
pt0 = to_visit[0];
@ -308,7 +308,7 @@ static int compare_complex(register CELL *pt0, register CELL *pt0_end, register
done:
/* failure */
#ifdef RATIONAL_TREES
while (to_visit > (CELL **)H) {
while (to_visit > (CELL **)HR) {
to_visit -= 4;
pt0 = to_visit[0];
pt0_end = to_visit[1];

View File

@ -510,10 +510,10 @@ optimize_ce(Term t, unsigned int arity, unsigned int level, compiler_struct *cgl
if (IsApplTerm(t) && IsExtensionFunctor(FunctorOfTerm(t)))
return (t);
while (p != NULL) {
CELL *oldH = H;
H = (CELL *)cglobs->cint.freep;
CELL *oldH = HR;
HR = (CELL *)cglobs->cint.freep;
cmp = Yap_compare_terms(t, (p->TermOfCE));
H = oldH;
HR = oldH;
if (cmp) {
p = p->NextCE;
@ -533,7 +533,7 @@ optimize_ce(Term t, unsigned int arity, unsigned int level, compiler_struct *cgl
p->TermOfCE = t;
p->VarOfCE = MkVarTerm();
if (H >= (CELL *)cglobs->cint.freep0) {
if (HR >= (CELL *)cglobs->cint.freep0) {
/* oops, too many new variables */
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
@ -614,7 +614,7 @@ try_store_as_dbterm(Term t, Int argno, unsigned int arity, int level, compiler_s
CACHE_REGS
DBTerm *dbt;
int g;
CELL *h0 = H;
CELL *h0 = HR;
while ((g=Yap_SizeGroundTerm(t,TRUE)) < 0) {
/* oops, too deep a term */
@ -625,9 +625,9 @@ try_store_as_dbterm(Term t, Int argno, unsigned int arity, int level, compiler_s
if (g < 16)
return FALSE;
/* store ground term away */
H = CellPtr(cglobs->cint.freep);
HR = CellPtr(cglobs->cint.freep);
if ((dbt = Yap_StoreTermInDB(t, -1)) == NULL) {
H = h0;
HR = h0;
switch(LOCAL_Error_TYPE) {
case OUT_OF_STACK_ERROR:
LOCAL_Error_TYPE = YAP_NO_ERROR;
@ -645,7 +645,7 @@ try_store_as_dbterm(Term t, Int argno, unsigned int arity, int level, compiler_s
siglongjmp(cglobs->cint.CompilerBotch,COMPILER_ERR_BOTCH);
}
}
H = h0;
HR = h0;
if (level == 0)
Yap_emit((cglobs->onhead ? get_dbterm_op : put_dbterm_op), dbt->Entry, argno, &cglobs->cint);
else
@ -1123,29 +1123,29 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
if (i2 == 0)
c_eq(t1, t3, cglobs);
else {
CELL *hi = H;
CELL *hi = HR;
Int i;
if (t1 == TermDot && i2 == 2) {
if (H+2 >= (CELL *)cglobs->cint.freep0) {
if (HR+2 >= (CELL *)cglobs->cint.freep0) {
/* oops, too many new variables */
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
}
RESET_VARIABLE(H);
RESET_VARIABLE(H+1);
H += 2;
c_eq(AbsPair(H-2),t3, cglobs);
RESET_VARIABLE(HR);
RESET_VARIABLE(HR+1);
HR += 2;
c_eq(AbsPair(HR-2),t3, cglobs);
} else if (i2 < 256 && IsAtomTerm(t1)) {
*H++ = (CELL)Yap_MkFunctor(AtomOfTerm(t1),i2);
*HR++ = (CELL)Yap_MkFunctor(AtomOfTerm(t1),i2);
for (i=0; i < i2; i++) {
if (H >= (CELL *)cglobs->cint.freep0) {
if (HR >= (CELL *)cglobs->cint.freep0) {
/* oops, too many new variables */
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
}
RESET_VARIABLE(H);
H++;
RESET_VARIABLE(HR);
HR++;
}
c_eq(AbsAppl(hi),t3, cglobs);
} else {
@ -1267,16 +1267,16 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,1);
}
if (H+1+arity >= (CELL *)cglobs->cint.freep0) {
if (HR+1+arity >= (CELL *)cglobs->cint.freep0) {
/* oops, too many new variables */
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
}
tnew = AbsAppl(H);
*H++ = (CELL)Yap_MkFunctor(AtomOfTerm(t1),arity);
tnew = AbsAppl(HR);
*HR++ = (CELL)Yap_MkFunctor(AtomOfTerm(t1),arity);
while (arity--) {
RESET_VARIABLE(H);
H++;
RESET_VARIABLE(HR);
HR++;
}
c_eq(tnew, t3, cglobs);
} else {
@ -1316,7 +1316,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
if (!IsVarTerm(t3)) {
if (Op == _arg) {
Term tmpvar = MkVarTerm();
if (H == (CELL *)cglobs->cint.freep0) {
if (HR == (CELL *)cglobs->cint.freep0) {
/* oops, too many new variables */
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
@ -1716,7 +1716,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
cglobs->goalno = savegoalno;
commitflag = cglobs->labelno;
commitvar = MkVarTerm();
if (H == (CELL *)cglobs->cint.freep0) {
if (HR == (CELL *)cglobs->cint.freep0) {
/* oops, too many new variables */
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
@ -1800,7 +1800,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
/* for now */
cglobs->needs_env = TRUE;
commitvar = MkVarTerm();
if (H == (CELL *)cglobs->cint.freep0) {
if (HR == (CELL *)cglobs->cint.freep0) {
/* oops, too many new variables */
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
@ -1836,7 +1836,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
int save = cglobs->onlast;
commitvar = MkVarTerm();
if (H == (CELL *)cglobs->cint.freep0) {
if (HR == (CELL *)cglobs->cint.freep0) {
/* oops, too many new variables */
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
@ -1963,7 +1963,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
}
else {
Term t2 = MkVarTerm();
if (H == (CELL *)cglobs->cint.freep0) {
if (HR == (CELL *)cglobs->cint.freep0) {
/* oops, too many new variables */
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
@ -1976,7 +1976,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
} else {
Term a2 = ArgOfTerm(2,Goal);
Term t1 = MkVarTerm();
if (H == (CELL *)cglobs->cint.freep0) {
if (HR == (CELL *)cglobs->cint.freep0) {
/* oops, too many new variables */
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
@ -1990,7 +1990,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
}
else {
Term t2 = MkVarTerm();
if (H == (CELL *)cglobs->cint.freep0) {
if (HR == (CELL *)cglobs->cint.freep0) {
/* oops, too many new variables */
save_machine_regs();
siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
@ -3416,7 +3416,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
case OUT_OF_STACK_BOTCH:
/* out of local stack, just duplicate the stack */
{
Int osize = 2*sizeof(CELL)*(ASP-H);
Int osize = 2*sizeof(CELL)*(ASP-HR);
ARG1 = inp_clause;
ARG3 = src;
@ -3425,8 +3425,8 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
LOCAL_Error_Term = inp_clause;
}
if (osize > ASP-H) {
if (!Yap_growstack(2*sizeof(CELL)*(ASP-H))) {
if (osize > ASP-HR) {
if (!Yap_growstack(2*sizeof(CELL)*(ASP-HR))) {
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
LOCAL_Error_Term = inp_clause;
}
@ -3490,7 +3490,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
}
}
my_clause = inp_clause;
HB = H;
HB = HR;
LOCAL_ErrorMessage = NULL;
LOCAL_Error_Size = 0;
LOCAL_Error_TYPE = YAP_NO_ERROR;
@ -3503,7 +3503,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
cglobs.cint.label_offset = NULL;
cglobs.cint.freep =
cglobs.cint.freep0 =
(char *) (H + maxvnum+(sizeof(Int)/sizeof(CELL))*MaxTemps+MaxTemps);
(char *) (HR + maxvnum+(sizeof(Int)/sizeof(CELL))*MaxTemps+MaxTemps);
cglobs.cint.success_handler = 0L;
if (ASP <= CellPtr (cglobs.cint.freep) + 256) {
cglobs.vtable = NULL;
@ -3511,8 +3511,8 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
save_machine_regs();
siglongjmp(cglobs.cint.CompilerBotch,3);
}
cglobs.Uses = (Int *)(H+maxvnum);
cglobs.Contents = (Term *)(H+maxvnum+(sizeof(Int)/sizeof(CELL))*MaxTemps);
cglobs.Uses = (Int *)(HR+maxvnum);
cglobs.Contents = (Term *)(HR+maxvnum+(sizeof(Int)/sizeof(CELL))*MaxTemps);
cglobs.curbranch = cglobs.onbranch = 0;
cglobs.branch_pointer = cglobs.parent_branches;
cglobs.or_found = FALSE;
@ -3627,7 +3627,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
}
reset_vars(cglobs.vtable);
H = HB;
HR = HB;
if (B != NULL) {
HB = B->cp_h;
}

View File

@ -60,7 +60,7 @@ static int can_unify_complex(register CELL *pt0,
saved_TR = TR;
saved_B = B;
saved_HB = HB;
HB = H;
HB = HR;
loop:
while (pt0 < pt0_end) {

View File

@ -584,14 +584,14 @@ copy_double(CELL *st, CELL *pt)
/* first thing, store a link to the list before we move on */
st[0] = (CELL)FunctorDouble;
st[1] = pt[1];
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
st[2] = pt[2];
st[3] = EndSpecials;
#else
st[2] = EndSpecials;
#endif
/* now reserve space */
return st+(2+SIZEOF_DOUBLE/SIZEOF_LONG_INT);
return st+(2+SIZEOF_DOUBLE/SIZEOF_INT_P);
}
static CELL *
@ -645,13 +645,13 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end,
#endif
register visitel *visited = (visitel *)AuxSp;
/* store this in H */
register CELL **to_visit = (CELL **)H;
register CELL **to_visit = (CELL **)HR;
CELL **to_visit_base = to_visit;
/* where we are going to add a new pair */
int vars_found = 0;
#ifdef COROUTINING
Term ConstraintsTerm = TermNil;
CELL *origH = H;
CELL *origH = HR;
#endif
CELL *CodeMaxBase = CodeMax;
@ -919,7 +919,7 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end,
Term t[4];
int sz = to_visit-to_visit_base;
H = (CELL *)to_visit;
HR = (CELL *)to_visit;
/* store the constraint away for: we need a back pointer to
the variable, the constraint in some cannonical form, what type
of constraint, and a list pointer */
@ -928,11 +928,11 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end,
t[2] = MkIntegerTerm(ExtFromCell(ptd0));
t[3] = ConstraintsTerm;
ConstraintsTerm = Yap_MkApplTerm(FunctorClist, 4, t);
if (H+sz >= ASP) {
if (HR+sz >= ASP) {
goto error2;
}
memcpy((void *)H, (void *)(to_visit_base), sz*sizeof(CELL *));
to_visit_base = (CELL **)H;
memcpy((void *)HR, (void *)(to_visit_base), sz*sizeof(CELL *));
to_visit_base = (CELL **)HR;
to_visit = to_visit_base+sz;
}
#endif
@ -988,7 +988,7 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end,
*vars_foundp = vars_found;
DB_UNWIND_CUNIF();
#ifdef COROUTINING
H = origH;
HR = origH;
#endif
return CodeMax;
@ -1007,7 +1007,7 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end,
#endif
DB_UNWIND_CUNIF();
#ifdef COROUTINING
H = origH;
HR = origH;
#endif
return NULL;
@ -1025,7 +1025,7 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end,
#endif
DB_UNWIND_CUNIF();
#ifdef COROUTINING
H = origH;
HR = origH;
#endif
return NULL;
@ -1043,7 +1043,7 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end,
#endif
DB_UNWIND_CUNIF();
#ifdef COROUTINING
H = origH;
HR = origH;
#endif
return NULL;
#if THREADS
@ -2502,7 +2502,7 @@ GetDBTerm(DBTerm *DBSP, int src USES_REGS)
} else if (IsAtomOrIntTerm(t)) {
return t;
} else {
CELL *HOld = H;
CELL *HOld = HR;
CELL *HeapPtr;
CELL *pt;
CELL NOf;
@ -2512,9 +2512,9 @@ GetDBTerm(DBTerm *DBSP, int src USES_REGS)
}
pt = CellPtr(DBSP->Contents);
CalculateStackGap( PASS_REGS1 );
if (H+NOf > ASP-EventFlag/sizeof(CELL)) {
if (HR+NOf > ASP-EventFlag/sizeof(CELL)) {
if (LOCAL_PrologMode & InErrorMode) {
if (H+NOf > ASP)
if (HR+NOf > ASP)
fprintf(GLOBAL_stderr, "\n\n [ FATAL ERROR: No Stack for Error Handling ]\n");
Yap_exit( 1);
} else {
@ -2525,7 +2525,7 @@ GetDBTerm(DBTerm *DBSP, int src USES_REGS)
}
HeapPtr = cpcells(HOld, pt, NOf);
pt += HeapPtr - HOld;
H = HeapPtr;
HR = HeapPtr;
{
link_entry *lp = (link_entry *)pt;
linkblk(lp, HOld-1, (CELL)HOld-(CELL)(DBSP->Contents));
@ -2533,7 +2533,7 @@ GetDBTerm(DBTerm *DBSP, int src USES_REGS)
#ifdef COROUTINING
if (DBSP->ag.attachments != 0L && !src) {
if (!copy_attachments((CELL *)AdjustIDBPtr(DBSP->ag.attachments,(CELL)HOld-(CELL)(DBSP->Contents)) PASS_REGS)) {
H = HOld;
HR = HOld;
LOCAL_Error_TYPE = OUT_OF_ATTVARS_ERROR;
LOCAL_Error_Size = 0;
return (Term)0;
@ -3069,7 +3069,7 @@ i_recorded(DBProp AtProp, Term t3 USES_REGS)
if (IsVarTerm(twork)) {
EXTRA_CBACK_ARG(3,2) = MkIntegerTerm(0);
EXTRA_CBACK_ARG(3,3) = MkIntegerTerm(0);
B->cp_h = H;
B->cp_h = HR;
while ((TermDB = GetDBTermFromDBEntry(ref PASS_REGS)) == (CELL)0) {
/* make sure the garbage collector sees what we want it to see! */
EXTRA_CBACK_ARG(3,1) = (CELL)ref;
@ -3097,7 +3097,7 @@ i_recorded(DBProp AtProp, Term t3 USES_REGS)
} else if (IsAtomOrIntTerm(twork)) {
EXTRA_CBACK_ARG(3,2) = MkIntegerTerm(0);
EXTRA_CBACK_ARG(3,3) = MkIntegerTerm((Int)twork);
B->cp_h = H;
B->cp_h = HR;
READ_LOCK(AtProp->DBRWLock);
do {
if (((twork == ref->DBT.Entry) || IsVarTerm(ref->DBT.Entry)) &&
@ -3114,7 +3114,7 @@ i_recorded(DBProp AtProp, Term t3 USES_REGS)
CELL key;
CELL mask = EvalMasks(twork, &key);
B->cp_h = H;
B->cp_h = HR;
READ_LOCK(AtProp->DBRWLock);
do {
while ((mask & ref->Key) != (key & ref->Mask) && !DEAD_REF(ref)) {
@ -3129,7 +3129,7 @@ i_recorded(DBProp AtProp, Term t3 USES_REGS)
/* success */
EXTRA_CBACK_ARG(3,2) = MkIntegerTerm(((Int)mask));
EXTRA_CBACK_ARG(3,3) = MkIntegerTerm(((Int)key));
B->cp_h = H;
B->cp_h = HR;
break;
} else {
while ((ref = NextDBRef(ref)) != NULL
@ -3187,7 +3187,7 @@ c_recorded(int flags USES_REGS)
{
Term TermDB, TRef;
Register DBRef ref, ref0;
CELL *PreviousHeap = H;
CELL *PreviousHeap = HR;
CELL mask, key;
Term t1;
@ -3256,7 +3256,7 @@ c_recorded(int flags USES_REGS)
}
}
LOCAL_Error_Size = 0;
PreviousHeap = H;
PreviousHeap = HR;
}
Yap_unify(ARG2, TermDB);
} else if (mask == 0) { /* ARG2 is a constant */
@ -3272,7 +3272,7 @@ c_recorded(int flags USES_REGS)
}
} else
do { /* ARG2 is a structure */
H = PreviousHeap;
HR = PreviousHeap;
while ((mask & ref->Key) != (key & ref->Mask)) {
while ((ref = NextDBRef(ref)) != NIL
&& DEAD_REF(ref));
@ -3299,7 +3299,7 @@ c_recorded(int flags USES_REGS)
}
}
LOCAL_Error_Size = 0;
PreviousHeap = H;
PreviousHeap = HR;
}
if (Yap_unify(ARG2, TermDB))
break;
@ -4927,7 +4927,7 @@ cont_current_key( USES_REGS1 )
term = AtT = MkAtomTerm(a);
} else {
unsigned int j;
CELL *p = H;
CELL *p = HR;
for (j = 0; j < arity; j++) {
p[j] = MkVarTerm();

View File

@ -29,22 +29,6 @@
#endif
#include "Foreign.h"
static Term
gen_syntax_error(Atom InpAtom, char *s)
{
CACHE_REGS
Term ts[7], ti[2];
ti[0] = ARG1;
ti[1] = ARG2;
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom(s),2),2,ti);
ts[1] = ts[4] = ts[5] = MkIntTerm(0);
ts[2] = MkAtomTerm(AtomExpectedNumber);
ts[3] = TermNil;
ts[6] = MkAtomTerm(InpAtom);
return(Yap_MkApplTerm(FunctorSyntaxError,7,ts));
}
int Yap_HandleError( const char *s, ... ) {
CACHE_REGS
yap_error_number err = LOCAL_Error_TYPE;
@ -141,7 +125,7 @@ static void detect_bug_location(yamop *,find_pred_type,char *, int);
#define ONHEAP(ptr) (CellPtr(ptr) >= CellPtr(Yap_HeapBase) && CellPtr(ptr) < CellPtr(HeapTop))
#define ONLOCAL(ptr) (CellPtr(ptr) > CellPtr(H) && CellPtr(ptr) < CellPtr(LOCAL_LocalBase))
#define ONLOCAL(ptr) (CellPtr(ptr) > CellPtr(HR) && CellPtr(ptr) < CellPtr(LOCAL_LocalBase))
static int
hidden (Atom at)
@ -379,13 +363,13 @@ dump_stack( USES_REGS1 )
if (handled_exception( PASS_REGS1 ))
return;
#if DEBUG
fprintf(stderr,"%% YAP regs: P=%p, CP=%p, ASP=%p, H=%p, TR=%p, HeapTop=%p\n",P,CP,ASP,H,TR,HeapTop);
fprintf(stderr,"%% YAP regs: P=%p, CP=%p, ASP=%p, H=%p, TR=%p, HeapTop=%p\n",P,CP,ASP,HR,TR,HeapTop);
fprintf(stderr,"%% YAP mode: %ux\n",(unsigned int)LOCAL_PrologMode);
if (LOCAL_ErrorMessage)
fprintf(stderr,"%% LOCAL_ErrorMessage: %s\n",LOCAL_ErrorMessage);
#endif
if (H > ASP || H > LCL0) {
fprintf(stderr,"%% YAP ERROR: Global Collided against Local (%p--%p)\n",H,ASP);
if (HR > ASP || HR > LCL0) {
fprintf(stderr,"%% YAP ERROR: Global Collided against Local (%p--%p)\n",HR,ASP);
} else if (HeapTop > (ADDR)LOCAL_GlobalBase) {
fprintf(stderr,"%% YAP ERROR: Code Space Collided against Global (%p--%p)\n", HeapTop, LOCAL_GlobalBase);
} else {
@ -402,11 +386,11 @@ dump_stack( USES_REGS1 )
}
#endif
#endif
detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, (char *)H, 256);
fprintf (stderr,"%%\n%% PC: %s\n",(char *)H);
detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, (char *)H, 256);
fprintf (stderr,"%% Continuation: %s\n",(char *)H);
fprintf (stderr,"%% %luKB of Global Stack (%p--%p)\n",(unsigned long int)(sizeof(CELL)*(H-H0))/1024,H0,H);
detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256);
fprintf (stderr,"%%\n%% PC: %s\n",(char *)HR);
detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256);
fprintf (stderr,"%% Continuation: %s\n",(char *)HR);
fprintf (stderr,"%% %luKB of Global Stack (%p--%p)\n",(unsigned long int)(sizeof(CELL)*(HR-H0))/1024,H0,HR);
fprintf (stderr,"%% %luKB of Local Stack (%p--%p)\n",(unsigned long int)(sizeof(CELL)*(LCL0-ASP))/1024,ASP,LCL0);
fprintf (stderr,"%% %luKB of Trail (%p--%p)\n",(unsigned long int)((ADDR)TR-LOCAL_TrailBase)/1024,LOCAL_TrailBase,TR);
fprintf (stderr,"%% Performed %ld garbage collections\n", (unsigned long int)LOCAL_GcCalls);
@ -484,8 +468,8 @@ void
Yap_bug_location(yamop *pc)
{
CACHE_REGS
detect_bug_location(pc, FIND_PRED_FROM_ANYWHERE, (char *)H, 256);
fprintf(stderr,"%s\n",(char *)H);
detect_bug_location(pc, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256);
fprintf(stderr,"%s\n",(char *)HR);
dump_stack( PASS_REGS1 );
}
@ -583,10 +567,10 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
fprintf(stderr,"%% YAP OOOPS: %s.\n",tmpbuf);
fprintf(stderr,"%%\n%%\n");
}
detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, (char *)H, 256);
fprintf (stderr,"%%\n%% PC: %s\n",(char *)H);
detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, (char *)H, 256);
fprintf (stderr,"%% Continuation: %s\n",(char *)H);
detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256);
fprintf (stderr,"%%\n%% PC: %s\n",(char *)HR);
detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256);
fprintf (stderr,"%% Continuation: %s\n",(char *)HR);
DumpActiveGoals( PASS_REGS1 );
error_exit_yap (1);
}
@ -1557,11 +1541,8 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
case SYNTAX_ERROR:
{
int i;
Term ti[1];
i = strlen(tmpbuf);
ti[0] = MkAtomTerm(AtomSyntaxError);
nt[0] = gen_syntax_error(AtomNil, tmpbuf);
psize -= i;
fun = FunctorError;
serious = TRUE;

View File

@ -366,7 +366,7 @@ static Int cont_between( USES_REGS1 )
i1 = IntegerOfTerm(t1);
tn = add_int(i1, 1 PASS_REGS);
EXTRA_CBACK_ARG(3,1) = tn;
HB = B->cp_h = H;
HB = B->cp_h = HR;
return TRUE;
} else {
Term t[2];
@ -380,7 +380,7 @@ static Int cont_between( USES_REGS1 )
t[1] = MkIntTerm(1);
tn = Eval(Yap_MkApplTerm(FunctorPlus, 2, t) PASS_REGS);
EXTRA_CBACK_ARG(3,1) = tn;
HB = B->cp_h = H;
HB = B->cp_h = HR;
return TRUE;
}
}

View File

@ -255,34 +255,34 @@ do_execute(Term t, Term mod USES_REGS)
static Term
copy_execn_to_heap(Functor f, CELL *pt, unsigned int n, unsigned int arity, Term mod USES_REGS)
{
CELL *h0 = H;
CELL *h0 = HR;
Term tf;
unsigned int i;
if (arity == 2 &&
NameOfFunctor(f) == AtomDot) {
for (i = 0; i<arity-n;i++) {
*H++ = pt[i];
*HR++ = pt[i];
}
for (i=0; i< n; i++) {
*H++ = h0[(int)(i-n)];
*HR++ = h0[(int)(i-n)];
}
tf = AbsPair(h0);
} else {
*H++ = (CELL)f;
*HR++ = (CELL)f;
for (i = 0; i<arity-n;i++) {
*H++ = pt[i];
*HR++ = pt[i];
}
for (i=0; i< n; i++) {
*H++ = h0[(int)(i-n)];
*HR++ = h0[(int)(i-n)];
}
tf = AbsAppl(h0);
}
if (mod != CurrentModule) {
CELL *h0 = H;
*H++ = (CELL)FunctorModule;
*H++ = mod;
*H++ = tf;
CELL *h0 = HR;
*HR++ = (CELL)FunctorModule;
*HR++ = mod;
*HR++ = tf;
tf = AbsAppl(h0);
}
return tf;
@ -375,7 +375,7 @@ do_execute_n(Term t, Term mod, unsigned int n USES_REGS)
#endif
}
for (i = arity-n+1; i <= arity; i++,j++) {
XREGS[i] = H[j];
XREGS[i] = HR[j];
}
return CallPredicate(pen, B, pen->CodeOfPred PASS_REGS);
}
@ -422,15 +422,15 @@ static void
heap_store(Term t USES_REGS)
{
if (IsVarTerm(t)) {
if (VarOfTerm(t) < H) {
*H++ = t;
if (VarOfTerm(t) < HR) {
*HR++ = t;
} else {
RESET_VARIABLE(H);
Bind_Local(VarOfTerm(t), (CELL)H);
H++;
RESET_VARIABLE(HR);
Bind_Local(VarOfTerm(t), (CELL)HR);
HR++;
}
} else {
*H++ = t;
*HR++ = t;
}
}
@ -1163,7 +1163,7 @@ Yap_PrepGoal(UInt arity, CELL *pt, choiceptr saved_b USES_REGS)
}
B = (choiceptr)ASP;
B--;
B->cp_h = H;
B->cp_h = HR;
B->cp_tr = TR;
B->cp_cp = CP;
B->cp_ap = NOCODE;
@ -1174,7 +1174,7 @@ Yap_PrepGoal(UInt arity, CELL *pt, choiceptr saved_b USES_REGS)
#endif /* DEPTH_LIMIT */
YENV = ASP = (CELL *)B;
YENV[E_CB] = (CELL)B;
HB = H;
HB = HR;
CP = YESCODE;
}
@ -1272,7 +1272,7 @@ execute_pred(PredEntry *ppe, CELL *pt USES_REGS)
} else if (out == 0) {
P = saved_p;
CP = saved_cp;
H = B->cp_h;
HR = B->cp_h;
#ifdef DEPTH_LIMIT
DEPTH= B->cp_depth;
#endif
@ -1338,7 +1338,7 @@ Yap_trust_last(void)
CACHE_REGS
ASP = B->cp_env;
CP = B->cp_cp;
H = B->cp_h;
HR = B->cp_h;
#ifdef DEPTH_LIMIT
DEPTH= B->cp_depth;
#endif
@ -1757,7 +1757,7 @@ Yap_InitYaamRegs( int myworker_id )
Yap_ResetExceptionTerm ( myworker_id );
Yap_PutValue (AtomBreak, MkIntTerm (0));
TR = (tr_fr_ptr)REMOTE_TrailBase(myworker_id);
H = H0 = ((CELL *) REMOTE_GlobalBase(myworker_id))+1; // +1: hack to ensure the gc does not try to mark mistakenly
HR = H0 = ((CELL *) REMOTE_GlobalBase(myworker_id))+1; // +1: hack to ensure the gc does not try to mark mistakenly
LCL0 = ASP = (CELL *) REMOTE_LocalBase(myworker_id);
CurrentTrailTop = (tr_fr_ptr)(REMOTE_TrailTop(myworker_id)-MinTrailGap);
/* notice that an initial choice-point and environment
@ -1770,7 +1770,7 @@ Yap_InitYaamRegs( int myworker_id )
#endif
STATIC_PREDICATES_MARKED = FALSE;
#ifdef FROZEN_STACKS
H_FZ = H;
H_FZ = HR;
#ifdef YAPOR_SBA
BSEG =
#endif /* YAPOR_SBA */

10
C/exo.c
View File

@ -407,7 +407,7 @@ add_index(struct index_t **ip, UInt bmap, PredEntry *ap, UInt count)
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
return NULL;
}
bzero(base, dsz);
memset(base, 0, dsz);
}
i->size = sz+dsz+sizeof(struct index_t);
i->key = (BITS32 *)base;
@ -430,7 +430,7 @@ add_index(struct index_t **ip, UInt bmap, PredEntry *ap, UInt count)
}
if (base != (CELL *)Yap_ReallocCodeSpace((char *)base, sz))
return FALSE;
bzero(base, sz);
memset(base, 0, sz);
i->key = (BITS32 *)base;
i->links = (BITS32 *)(base+i->hsize);
i->ncollisions = i->nentries = i->ntrys = 0;
@ -455,7 +455,7 @@ add_index(struct index_t **ip, UInt bmap, PredEntry *ap, UInt count)
}
if (base != (CELL *)Yap_ReallocCodeSpace((char *)base, sz))
return FALSE;
bzero(base, sz);
memset(base, 0, sz);
i->key = (BITS32 *)base;
i->links = (BITS32 *)base+i->hsize;
i->ncollisions = i->nentries = i->ntrys = 0;
@ -562,7 +562,7 @@ Yap_NextExo(choiceptr cptr, struct index_t *it)
return next;
}
MegaClause *
static MegaClause *
exodb_get_space( Term t, Term mod, Term tn )
{
UInt arity;
@ -668,7 +668,7 @@ store_exo(yamop *pc, UInt arity, Term t0)
return TRUE;
}
void
static void
exoassert( void *handle, Int n, Term term )
{ /* '$number_of_clauses'(Predicate,M,N) */
PredEntry *pe;

View File

@ -108,15 +108,15 @@ NewArena(UInt size, UInt arity, CELL *where USES_REGS)
Term t;
UInt new_size;
if (where == NULL || where == H) {
while (H+size > ASP-1024) {
if (where == NULL || where == HR) {
while (HR+size > ASP-1024) {
if (!Yap_gcl(size*sizeof(CELL), arity, ENV, P)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return TermNil;
}
}
t = CreateNewArena(H, size);
H += size;
t = CreateNewArena(HR, size);
HR += size;
} else {
if ((new_size=Yap_InsertInGlobal(where, size*sizeof(CELL)))==0) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,"No Stack Space for Non-Backtrackable terms");
@ -162,7 +162,7 @@ adjust_cps(UInt size USES_REGS)
{
/* adjust possible back pointers in choice-point stack */
choiceptr b_ptr = B;
while (b_ptr->cp_h == H) {
while (b_ptr->cp_h == HR) {
b_ptr->cp_h += size;
b_ptr = b_ptr->cp_b;
}
@ -183,8 +183,8 @@ GrowArena(Term arena, CELL *pt, UInt old_size, UInt size, UInt arity USES_REGS)
if (size < 4096) {
size = 4096;
}
if (pt == H) {
if (H+size > ASP-1024) {
if (pt == HR) {
if (HR+size > ASP-1024) {
XREGS[arity+1] = arena;
if (!Yap_gcl(size*sizeof(CELL), arity+1, ENV, gc_P(P,CP))) {
@ -197,11 +197,11 @@ GrowArena(Term arena, CELL *pt, UInt old_size, UInt size, UInt arity USES_REGS)
return GrowArena(arena, pt, old_size, size, arity PASS_REGS);
}
adjust_cps(size PASS_REGS);
H += size;
HR += size;
} else {
XREGS[arity+1] = arena;
/* try to recover some room */
if (arena == LOCAL_GlobalArena && 10*(pt-H0) > 8*(H-H0)) {
if (arena == LOCAL_GlobalArena && 10*(pt-H0) > 8*(HR-H0)) {
if (!Yap_gcl(size*sizeof(CELL), arity+1, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,LOCAL_ErrorMessage);
return FALSE;
@ -231,9 +231,9 @@ Yap_GetFromArena(Term *arenap, UInt cells, UInt arity)
CELL *newH;
UInt old_sz = ArenaSz(arena), new_size;
if (IN_BETWEEN(base, H, max)) {
base = H;
H += cells;
if (IN_BETWEEN(base, HR, max)) {
base = HR;
HR += cells;
return base;
}
if (base+cells > max-1024) {
@ -254,11 +254,11 @@ CloseArena(CELL *oldH, CELL *oldHB, CELL *oldASP, Term *oldArenaP, UInt old_size
{
UInt new_size;
if (H == oldH)
if (HR == oldH)
return;
new_size = old_size - (H-RepAppl(*oldArenaP));
*oldArenaP = CreateNewArena(H, new_size);
H = oldH;
new_size = old_size - (HR-RepAppl(*oldArenaP));
*oldArenaP = CreateNewArena(HR, new_size);
HR = oldH;
HB = oldHB;
ASP = oldASP;
}
@ -308,12 +308,12 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
if (IsPairTerm(d0)) {
CELL *ap2 = RepPair(d0);
if ((share && ap2 < HB) ||
(ap2 >= HB && ap2 < H)) {
(ap2 >= HB && ap2 < HR)) {
/* If this is newer than the current term, just reuse */
*ptf++ = d0;
continue;
}
*ptf = AbsPair(H);
*ptf = AbsPair(HR);
ptf++;
#ifdef RATIONAL_TREES
if (to_visit+1 >= (struct cp_frame *)AuxSp) {
@ -325,7 +325,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
to_visit->oldv = *pt0;
to_visit->ground = ground;
/* fool the system into thinking we had a variable there */
*pt0 = AbsPair(H);
*pt0 = AbsPair(HR);
to_visit ++;
#else
if (pt0 < pt0_end) {
@ -342,9 +342,9 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
ground = TRUE;
pt0 = ap2 - 1;
pt0_end = ap2 + 1;
ptf = H;
H += 2;
if (H > ASP - MIN_ARENA_SIZE) {
ptf = HR;
HR += 2;
if (HR > ASP - MIN_ARENA_SIZE) {
goto overflow;
}
} else if (IsApplTerm(d0)) {
@ -353,7 +353,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
/* store the terms to visit */
ap2 = RepAppl(d0);
if ((share && ap2 < HB) ||
(ap2 >= HB && ap2 < H)) {
(ap2 >= HB && ap2 < HR)) {
/* If this is newer than the current term, just reuse */
*ptf++ = d0;
continue;
@ -367,41 +367,41 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
*ptf++ = d0;
break;
case (CELL)FunctorLongInt:
if (H > ASP - (MIN_ARENA_SIZE+3)) {
if (HR > ASP - (MIN_ARENA_SIZE+3)) {
goto overflow;
}
*ptf++ = AbsAppl(H);
H[0] = (CELL)f;
H[1] = ap2[1];
H[2] = EndSpecials;
H += 3;
if (H > ASP - MIN_ARENA_SIZE) {
*ptf++ = AbsAppl(HR);
HR[0] = (CELL)f;
HR[1] = ap2[1];
HR[2] = EndSpecials;
HR += 3;
if (HR > ASP - MIN_ARENA_SIZE) {
goto overflow;
}
break;
case (CELL)FunctorDouble:
if (H > ASP - (MIN_ARENA_SIZE+(2+SIZEOF_DOUBLE/sizeof(CELL)))) {
if (HR > ASP - (MIN_ARENA_SIZE+(2+SIZEOF_DOUBLE/sizeof(CELL)))) {
goto overflow;
}
*ptf++ = AbsAppl(H);
H[0] = (CELL)f;
H[1] = ap2[1];
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
H[2] = ap2[2];
H[3] = EndSpecials;
H += 4;
*ptf++ = AbsAppl(HR);
HR[0] = (CELL)f;
HR[1] = ap2[1];
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
HR[2] = ap2[2];
HR[3] = EndSpecials;
HR += 4;
#else
H[2] = EndSpecials;
H += 3;
HR[2] = EndSpecials;
HR += 3;
#endif
break;
case (CELL)FunctorString:
if (ASP - H > MIN_ARENA_SIZE+3+ap2[1]) {
if (ASP - HR > MIN_ARENA_SIZE+3+ap2[1]) {
goto overflow;
}
*ptf++ = AbsAppl(H);
memcpy(H, ap2, sizeof(CELL)*(3+ap2[1]));
H+=ap2[1]+3;
*ptf++ = AbsAppl(HR);
memcpy(HR, ap2, sizeof(CELL)*(3+ap2[1]));
HR+=ap2[1]+3;
break;
default:
{
@ -409,20 +409,20 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
UInt sz = (sizeof(MP_INT)+3*CellSize+
((MP_INT *)(ap2+2))->_mp_alloc*sizeof(mp_limb_t))/CellSize, i;
if (H > ASP - (MIN_ARENA_SIZE+sz)) {
if (HR > ASP - (MIN_ARENA_SIZE+sz)) {
goto overflow;
}
*ptf++ = AbsAppl(H);
H[0] = (CELL)f;
*ptf++ = AbsAppl(HR);
HR[0] = (CELL)f;
for (i = 1; i < sz; i++) {
H[i] = ap2[i];
HR[i] = ap2[i];
}
H += sz;
HR += sz;
}
}
continue;
}
*ptf = AbsAppl(H);
*ptf = AbsAppl(HR);
ptf++;
/* store the terms to visit */
#ifdef RATIONAL_TREES
@ -435,7 +435,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
to_visit->oldv = *pt0;
to_visit->ground = ground;
/* fool the system into thinking we had a variable there */
*pt0 = AbsAppl(H);
*pt0 = AbsAppl(HR);
to_visit ++;
#else
if (pt0 < pt0_end) {
@ -454,10 +454,10 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
pt0 = ap2;
pt0_end = ap2 + d0;
/* store the functor for the new term */
H[0] = (CELL)f;
ptf = H+1;
H += 1+d0;
if (H > ASP - MIN_ARENA_SIZE) {
HR[0] = (CELL)f;
ptf = HR+1;
HR += 1+d0;
if (HR > ASP - MIN_ARENA_SIZE) {
goto overflow;
}
} else {
@ -471,7 +471,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
ground = FALSE;
/* don't need to copy variables if we want to share the global term */
if ((share && ptd0 < HB && ptd0 > H0) ||
(ptd0 >= HLow && ptd0 < H)) {
(ptd0 >= HLow && ptd0 < HR)) {
/* we have already found this cell */
*ptf++ = (CELL) ptd0;
} else {
@ -530,7 +530,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
overflow:
/* oops, we're in trouble */
H = HLow;
HR = HLow;
/* we've done it */
/* restore our nice, friendly, term to its original state */
HB = HB0;
@ -548,7 +548,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
heap_overflow:
/* oops, we're in trouble */
H = HLow;
HR = HLow;
/* we've done it */
/* restore our nice, friendly, term to its original state */
HB = HB0;
@ -566,7 +566,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, int share, int cop
trail_overflow:
/* oops, we're in trouble */
H = HLow;
HR = HLow;
/* we've done it */
/* restore our nice, friendly, term to its original state */
HB = HB0;
@ -587,7 +587,7 @@ static Term
CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Term *newarena, UInt min_grow USES_REGS)
{
UInt old_size = ArenaSz(arena);
CELL *oldH = H;
CELL *oldH = HR;
CELL *oldHB = HB;
CELL *oldASP = ASP;
int res = 0;
@ -597,14 +597,14 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
t = Deref(t);
if (IsVarTerm(t)) {
ASP = ArenaLimit(arena);
H = HB = ArenaPt(arena);
HR = HB = ArenaPt(arena);
#if COROUTINING
if (GlobalIsAttachedTerm(t)) {
CELL *Hi;
*H = t;
Hi = H+1;
H += 2;
*HR = t;
Hi = HR+1;
HR += 2;
if ((res = copy_complex_term(Hi-2, Hi-1, share, copy_att_vars, Hi, Hi PASS_REGS)) < 0)
goto error_handler;
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
@ -616,7 +616,7 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
return t;
}
tn = MkVarTerm();
if (H > ASP - MIN_ARENA_SIZE) {
if (HR > ASP - MIN_ARENA_SIZE) {
res = -1;
goto error_handler;
}
@ -632,12 +632,12 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
if (share && ArenaPt(arena) > RepPair(t)) {
return t;
}
H = HB = ArenaPt(arena);
HR = HB = ArenaPt(arena);
ASP = ArenaLimit(arena);
ap = RepPair(t);
Hi = H;
tf = AbsPair(H);
H += 2;
Hi = HR;
tf = AbsPair(HR);
HR += 2;
if ((res = copy_complex_term(ap-1, ap+1, share, copy_att_vars, Hi, Hi PASS_REGS)) < 0) {
goto error_handler;
}
@ -652,67 +652,67 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
if (share && ArenaPt(arena) > RepAppl(t)) {
return t;
}
H = HB = ArenaPt(arena);
HR = HB = ArenaPt(arena);
ASP = ArenaLimit(arena);
f = FunctorOfTerm(t);
HB0 = H;
HB0 = HR;
ap = RepAppl(t);
tf = AbsAppl(H);
H[0] = (CELL)f;
tf = AbsAppl(HR);
HR[0] = (CELL)f;
if (IsExtensionFunctor(f)) {
switch((CELL)f) {
case (CELL)FunctorDBRef:
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
return t;
case (CELL)FunctorLongInt:
if (H > ASP - (MIN_ARENA_SIZE+3)) {
if (HR > ASP - (MIN_ARENA_SIZE+3)) {
res = -1;
goto error_handler;
}
H[1] = ap[1];
H[2] = EndSpecials;
H += 3;
HR[1] = ap[1];
HR[2] = EndSpecials;
HR += 3;
break;
case (CELL)FunctorDouble:
if (H > ASP - (MIN_ARENA_SIZE+(2+SIZEOF_DOUBLE/sizeof(CELL)))) {
if (HR > ASP - (MIN_ARENA_SIZE+(2+SIZEOF_DOUBLE/sizeof(CELL)))) {
res = -1;
goto error_handler;
}
H[1] = ap[1];
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
H[2] = ap[2];
H[3] = EndSpecials;
H += 4;
HR[1] = ap[1];
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
HR[2] = ap[2];
HR[3] = EndSpecials;
HR += 4;
#else
H[2] = EndSpecials;
H += 3;
HR[2] = EndSpecials;
HR += 3;
#endif
break;
case (CELL)FunctorString:
if (H > ASP - MIN_ARENA_SIZE+3+ap[1]) {
if (HR > ASP - MIN_ARENA_SIZE+3+ap[1]) {
res = -1;
goto error_handler;
}
memcpy(H, ap, sizeof(CELL)*(3+ap[1]));
H += ap[1]+3;
memcpy(HR, ap, sizeof(CELL)*(3+ap[1]));
HR += ap[1]+3;
break;
default:
{
UInt sz = ArenaSz(t), i;
if (H > ASP - (MIN_ARENA_SIZE+sz)) {
if (HR > ASP - (MIN_ARENA_SIZE+sz)) {
res = -1;
goto error_handler;
}
for (i = 1; i < sz; i++) {
H[i] = ap[i];
HR[i] = ap[i];
}
H += sz;
HR += sz;
}
}
} else {
H += 1+ArityOfFunctor(f);
if (H > ASP-MIN_ARENA_SIZE) {
HR += 1+ArityOfFunctor(f);
if (HR > ASP-MIN_ARENA_SIZE) {
res = -1;
goto error_handler;
}
@ -724,7 +724,7 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
return tf;
}
error_handler:
H = HB;
HR = HB;
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
XREGS[arity+1] = t;
XREGS[arity+2] = arena;
@ -732,7 +732,7 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
{
CELL *old_top = ArenaLimit(*newarena);
ASP = oldASP;
H = oldH;
HR = oldH;
HB = oldHB;
switch (res) {
case -1:
@ -750,7 +750,7 @@ CopyTermToArena(Term t, Term arena, int share, int copy_att_vars, UInt arity, Te
}
}
}
oldH = H;
oldH = HR;
oldHB = HB;
oldASP = ASP;
newarena = (CELL *)XREGS[arity+3];
@ -764,7 +764,7 @@ static Term
CreateTermInArena(Term arena, Atom Na, UInt Nar, UInt arity, Term *newarena, Term init USES_REGS)
{
UInt old_size = ArenaSz(arena);
CELL *oldH = H;
CELL *oldH = HR;
CELL *oldHB = HB;
CELL *oldASP = ASP;
Term tf;
@ -773,22 +773,22 @@ CreateTermInArena(Term arena, Atom Na, UInt Nar, UInt arity, Term *newarena, Ter
UInt i;
restart:
H = HB = ArenaPt(arena);
HR = HB = ArenaPt(arena);
ASP = ArenaLimit(arena);
HB0 = H;
tf = AbsAppl(H);
H[0] = (CELL)f;
H += 1+ArityOfFunctor(f);
if (H > ASP-MIN_ARENA_SIZE) {
HB0 = HR;
tf = AbsAppl(HR);
HR[0] = (CELL)f;
HR += 1+ArityOfFunctor(f);
if (HR > ASP-MIN_ARENA_SIZE) {
/* overflow */
H = HB;
HR = HB;
CloseArena(oldH, oldHB, oldASP, newarena, old_size PASS_REGS);
XREGS[arity+1] = arena;
XREGS[arity+2] = (CELL)newarena;
{
CELL *old_top = ArenaLimit(*newarena);
ASP = oldASP;
H = oldH;
HR = oldH;
HB = oldHB;
if (arena == LOCAL_GlobalArena)
LOCAL_GlobalArenaOverflows++;
@ -797,7 +797,7 @@ CreateTermInArena(Term arena, Atom Na, UInt Nar, UInt arity, Term *newarena, Ter
return 0L;
}
}
oldH = H;
oldH = HR;
oldHB = HB;
oldASP = ASP;
newarena = (CELL *)XREGS[arity+2];
@ -1124,7 +1124,7 @@ p_nb_add_to_accumulator( USES_REGS1 )
CELL *target = RepAppl(t0);
CELL *source = RepAppl(new);
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
target[2] = source[2];
#endif
target[1] = source[1];
@ -1252,7 +1252,7 @@ p_b_setval( USES_REGS1 )
{
/* but first make sure we are doing on a global object, or a constant! */
Term t = Deref(ARG2);
if (IsVarTerm(t) && VarOfTerm(t) > H && VarOfTerm(t) < LCL0) {
if (IsVarTerm(t) && VarOfTerm(t) > HR && VarOfTerm(t) < LCL0) {
Term tn = MkVarTerm();
Bind_Local(VarOfTerm(t), tn);
t = tn;
@ -1492,7 +1492,7 @@ nb_queue(UInt arena_sz USES_REGS)
static Int
p_nb_queue( USES_REGS1 )
{
UInt arena_sz = (ASP-H)/16;
UInt arena_sz = (ASP-HR)/16;
if (LOCAL_DepthArenas > 1)
arena_sz /= LOCAL_DepthArenas;
if (arena_sz < MIN_ARENA_SIZE)
@ -1563,8 +1563,8 @@ RecoverArena(Term arena USES_REGS)
CELL *pt = ArenaPt(arena),
*max = ArenaLimit(arena);
if (max == H) {
H = pt;
if (max == HR) {
HR = pt;
}
}
@ -1626,14 +1626,14 @@ p_nb_queue_enqueue( USES_REGS1 )
qd = GetQueue(ARG1,"enqueue");
arena = GetQueueArena(qd,"enqueue");
/* garbage collection ? */
oldH = H;
oldH = HR;
oldHB = HB;
H = HB = ArenaPt(arena);
HR = HB = ArenaPt(arena);
old_sz = ArenaSz(arena);
qsize = IntegerOfTerm(qd[QUEUE_SIZE]);
while (old_sz < MIN_ARENA_SIZE) {
UInt gsiz = H-RepPair(qd[QUEUE_HEAD]);
H = oldH;
UInt gsiz = HR-RepPair(qd[QUEUE_HEAD]);
HR = oldH;
HB = oldHB;
if (gsiz > 1024*1024) {
gsiz = 1024*1024;
@ -1649,21 +1649,21 @@ p_nb_queue_enqueue( USES_REGS1 )
to = ARG3;
qd = RepAppl(Deref(ARG1))+1;
arena = GetQueueArena(qd,"enqueue");
oldH = H;
oldH = HR;
oldHB = HB;
H = HB = ArenaPt(arena);
HR = HB = ArenaPt(arena);
old_sz = ArenaSz(arena);
}
qd[QUEUE_SIZE] = Global_MkIntegerTerm(qsize+1);
if (qsize == 0) {
qd[QUEUE_HEAD] = AbsPair(H);
qd[QUEUE_HEAD] = AbsPair(HR);
} else {
*VarOfTerm(qd[QUEUE_TAIL]) = AbsPair(H);
*VarOfTerm(qd[QUEUE_TAIL]) = AbsPair(HR);
}
*H++ = to;
RESET_VARIABLE(H);
qd[QUEUE_TAIL] = (CELL)H;
H++;
*HR++ = to;
RESET_VARIABLE(HR);
qd[QUEUE_TAIL] = (CELL)HR;
HR++;
CloseArena(oldH, oldHB, ASP, qd+QUEUE_ARENA, old_sz PASS_REGS);
return TRUE;
}
@ -1688,7 +1688,7 @@ p_nb_queue_dequeue( USES_REGS1 )
out = HeadOfTerm(qd[QUEUE_HEAD]);
qd[QUEUE_HEAD] = TailOfTerm(qd[QUEUE_HEAD]);
/* garbage collection ? */
oldH = H;
oldH = HR;
oldHB = HB;
qd[QUEUE_SIZE] = Global_MkIntegerTerm(qsz-1);
CloseArena(oldH, oldHB, ASP, &arena, old_sz PASS_REGS);
@ -1787,16 +1787,16 @@ MkZeroApplTerm(Functor f, UInt sz USES_REGS)
Term t0, tf;
CELL *pt;
if (H+(sz+1) > ASP-1024)
if (HR+(sz+1) > ASP-1024)
return TermNil;
tf = AbsAppl(H);
*H = (CELL)f;
tf = AbsAppl(HR);
*HR = (CELL)f;
t0 = MkIntTerm(0);
pt = H+1;
pt = HR+1;
while (sz--) {
*pt++ = t0;
}
H = pt;
HR = pt;
return tf;
}
@ -1806,7 +1806,7 @@ p_nb_heap( USES_REGS1 )
Term heap_arena, heap, *ar, *nar;
UInt hsize;
Term tsize = Deref(ARG1);
UInt arena_sz = (H-H0)/16;
UInt arena_sz = (HR-H0)/16;
if (IsVarTerm(tsize)) {
Yap_Error(INSTANTIATION_ERROR,tsize,"nb_heap");
@ -1957,9 +1957,9 @@ p_nb_heap_add_to_heap( USES_REGS1 )
}
arena = qd[HEAP_ARENA];
old_sz = ArenaSz(arena);
oldH = H;
oldH = HR;
oldHB = HB;
H = HB = ArenaPt(arena);
HR = HB = ArenaPt(arena);
qd[HEAP_MAX] = Global_MkIntegerTerm(hmsize);
CloseArena(oldH, oldHB, ASP, qd+HEAP_ARENA, old_sz PASS_REGS);
goto restart;
@ -1979,14 +1979,14 @@ p_nb_heap_add_to_heap( USES_REGS1 )
qd = GetHeap(ARG1,"add_to_heap");
arena = qd[HEAP_ARENA];
/* garbage collection ? */
oldH = H;
oldH = HR;
oldHB = HB;
H = HB = ArenaPt(arena);
HR = HB = ArenaPt(arena);
old_sz = ArenaSz(arena);
while (old_sz < MIN_ARENA_SIZE) {
UInt gsiz = hsize*2;
H = oldH;
HR = oldH;
HB = oldHB;
if (gsiz > 1024*1024) {
gsiz = 1024*1024;
@ -2001,9 +2001,9 @@ p_nb_heap_add_to_heap( USES_REGS1 )
to = ARG3;
qd = RepAppl(Deref(ARG1))+1;
arena = qd[HEAP_ARENA];
oldH = H;
oldH = HR;
oldHB = HB;
H = HB = ArenaPt(arena);
HR = HB = ArenaPt(arena);
old_sz = ArenaSz(arena);
}
pt = qd+HEAP_START;
@ -2034,7 +2034,7 @@ p_nb_heap_del( USES_REGS1 )
return FALSE;
old_sz = ArenaSz(arena);
/* garbage collection ? */
oldH = H;
oldH = HR;
oldHB = HB;
qd[HEAP_SIZE] = Global_MkIntegerTerm(qsz-1);
CloseArena(oldH, oldHB, ASP, &arena, old_sz PASS_REGS);
@ -2089,7 +2089,7 @@ p_nb_beam( USES_REGS1 )
Term beam_arena, beam, *ar, *nar;
UInt hsize;
Term tsize = Deref(ARG1);
UInt arena_sz = (H-H0)/16;
UInt arena_sz = (HR-H0)/16;
if (IsVarTerm(tsize)) {
Yap_Error(INSTANTIATION_ERROR,tsize,"nb_beam");
@ -2368,14 +2368,14 @@ p_nb_beam_add_to_beam( USES_REGS1 )
qd = GetHeap(ARG1,"add_to_beam");
arena = qd[HEAP_ARENA];
/* garbage collection ? */
oldH = H;
oldH = HR;
oldHB = HB;
H = HB = ArenaPt(arena);
HR = HB = ArenaPt(arena);
old_sz = ArenaSz(arena);
while (old_sz < MIN_ARENA_SIZE) {
UInt gsiz = hsize*2;
H = oldH;
HR = oldH;
HB = oldHB;
if (gsiz > 1024*1024) {
gsiz = 1024*1024;
@ -2390,9 +2390,9 @@ p_nb_beam_add_to_beam( USES_REGS1 )
to = ARG3;
qd = RepAppl(Deref(ARG1))+1;
arena = qd[HEAP_ARENA];
oldH = H;
oldH = HR;
oldHB = HB;
H = HB = ArenaPt(arena);
HR = HB = ArenaPt(arena);
old_sz = ArenaSz(arena);
}
pt = qd+HEAP_START;
@ -2421,7 +2421,7 @@ p_nb_beam_del( USES_REGS1 )
return FALSE;
old_sz = ArenaSz(arena);
/* garbage collection ? */
oldH = H;
oldH = HR;
oldHB = HB;
qd[HEAP_SIZE] = Global_MkIntegerTerm(qsz-1);
CloseArena(oldH, oldHB, ASP, &arena, old_sz PASS_REGS);
@ -2488,25 +2488,25 @@ p_nb_beam_keys( USES_REGS1 )
if (!qd)
return FALSE;
qsz = IntegerOfTerm(qd[HEAP_SIZE]);
ho = H;
ho = HR;
pt = qd+HEAP_START;
if (qsz == 0)
return Yap_unify(ARG2, TermNil);
for (i=0; i < qsz; i++) {
if (H > ASP-1024) {
H = ho;
if (!Yap_gcl(((ASP-H)-1024)*sizeof(CELL), 2, ENV, P)) {
if (HR > ASP-1024) {
HR = ho;
if (!Yap_gcl(((ASP-HR)-1024)*sizeof(CELL), 2, ENV, P)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return TermNil;
}
goto restart;
}
*H++ = pt[0];
*H = AbsPair(H+1);
H++;
*HR++ = pt[0];
*HR = AbsPair(HR+1);
HR++;
pt += 2;
}
H[-1] = TermNil;
HR[-1] = TermNil;
return Yap_unify(ARG2, AbsPair(ho));
}

View File

@ -100,7 +100,7 @@ SetHeapRegs(int copying_threads USES_REGS)
LOCAL_OldLCL0 = LCL0;
LOCAL_OldASP = ASP;
LOCAL_OldGlobalBase = (CELL *)LOCAL_GlobalBase;
LOCAL_OldH = H;
LOCAL_OldH = HR;
LOCAL_OldH0 = H0;
LOCAL_OldTrailBase = LOCAL_TrailBase;
LOCAL_OldTrailTop = LOCAL_TrailTop;
@ -135,8 +135,8 @@ SetHeapRegs(int copying_threads USES_REGS)
if (LCL0)
LCL0 = PtoLocAdjust(LCL0);
UNLOCK(LOCAL_SignalLock);
if (H)
H = PtoGloAdjust(H);
if (HR)
HR = PtoGloAdjust(HR);
#ifdef CUT_C
if (Yap_REGS.CUT_C_TOP)
Yap_REGS.CUT_C_TOP = CutCAdjust(Yap_REGS.CUT_C_TOP);
@ -542,7 +542,7 @@ AdjustGlobal(long sz, int thread_copying USES_REGS)
} else {
#endif
pt = H0;
pt_max = (H-sz/CellSize);
pt_max = (HR-sz/CellSize);
#if defined(YAPOR_THREADS)
}
#endif
@ -563,7 +563,7 @@ AdjustGlobal(long sz, int thread_copying USES_REGS)
/* skip bitmaps */
switch((CELL)f) {
case (CELL)FunctorDouble:
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
pt += 3;
#else
pt += 2;
@ -901,19 +901,19 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit USES_REGS)
do_grow = FALSE;
}
} else if (hsplit < (CELL*)omax ||
hsplit > H)
hsplit > HR)
return FALSE;
else if (hsplit == (CELL *)omax)
hsplit = NULL;
if (size < 0 ||
(Unsigned(H)+size < Unsigned(ASP)-StackGap( PASS_REGS1 ) &&
(Unsigned(HR)+size < Unsigned(ASP)-StackGap( PASS_REGS1 ) &&
hsplit > H0)) {
/* don't need to expand stacks */
insert_in_delays = FALSE;
do_grow = FALSE;
}
} else {
if (Unsigned(H)+size < Unsigned(ASP)-CreepFlag) {
if (Unsigned(HR)+size < Unsigned(ASP)-CreepFlag) {
/* we can just ask for more room */
do_grow = FALSE;
}
@ -1184,6 +1184,7 @@ fix_compiler_instructions(PInstr *pcpc USES_REGS)
case index_dbref_op:
case index_blob_op:
case index_long_op:
case index_string_op:
case if_nonvar_op:
case unify_last_list_op:
case write_last_list_op:
@ -1200,6 +1201,7 @@ fix_compiler_instructions(PInstr *pcpc USES_REGS)
case enter_lu_op:
case empty_call_op:
case blob_op:
case string_op:
case fetch_args_vi_op:
case fetch_args_iv_op:
case label_ctl_op:
@ -1665,7 +1667,7 @@ growstack(size_t size USES_REGS)
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
#endif
fprintf(GLOBAL_stderr, "%% Stack Overflow %d\n", LOCAL_stack_overflows);
fprintf(GLOBAL_stderr, "%% Global: %8ld cells (%p-%p)\n", (unsigned long int)(H-(CELL *)LOCAL_GlobalBase),LOCAL_GlobalBase,H);
fprintf(GLOBAL_stderr, "%% Global: %8ld cells (%p-%p)\n", (unsigned long int)(HR-(CELL *)LOCAL_GlobalBase),LOCAL_GlobalBase,HR);
fprintf(GLOBAL_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
fprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
(unsigned long int)(TR-(tr_fr_ptr)LOCAL_TrailBase),LOCAL_TrailBase,TR);
@ -1703,7 +1705,7 @@ Yap_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
#endif
fprintf(GLOBAL_stderr, "%% Stack Overflow %d\n", LOCAL_stack_overflows);
fprintf(GLOBAL_stderr, "%% Global: %8ld cells (%p-%p)\n", (unsigned long int)(H-(CELL *)LOCAL_GlobalBase),LOCAL_GlobalBase,H);
fprintf(GLOBAL_stderr, "%% Global: %8ld cells (%p-%p)\n", (unsigned long int)(HR-(CELL *)LOCAL_GlobalBase),LOCAL_GlobalBase,HR);
fprintf(GLOBAL_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
fprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
(unsigned long int)(TR-(tr_fr_ptr)LOCAL_TrailBase),LOCAL_TrailBase,TR);
@ -1752,7 +1754,7 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr
#endif
fprintf(GLOBAL_stderr, "%% Trail Overflow %d\n", LOCAL_trail_overflows);
#if USE_SYSTEM_MALLOC
fprintf(GLOBAL_stderr, "%% Heap: %8ld cells (%p-%p)\n", (unsigned long int)(H-(CELL *)LOCAL_GlobalBase),(CELL *)LOCAL_GlobalBase,H);
fprintf(GLOBAL_stderr, "%% Heap: %8ld cells (%p-%p)\n", (unsigned long int)(HR-(CELL *)LOCAL_GlobalBase),(CELL *)LOCAL_GlobalBase,HR);
fprintf(GLOBAL_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
fprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
(unsigned long int)(TR-(tr_fr_ptr)LOCAL_TrailBase),LOCAL_TrailBase,TR);
@ -1974,7 +1976,7 @@ Yap_CopyThreadStacks(int worker_q, int worker_p, int incremental)
LOCAL_TrDiff = LOCAL_LDiff = LOCAL_GDiff = LOCAL_GDiff0 = LOCAL_DelayDiff = LOCAL_BaseDiff = size;
LOCAL_XDiff = LOCAL_HDiff = 0;
LOCAL_GSplit = NULL;
H = REMOTE_ThreadHandle(worker_p).current_yaam_regs->H_;
HR = REMOTE_ThreadHandle(worker_p).current_yaam_regs->H_;
H0 = REMOTE_ThreadHandle(worker_p).current_yaam_regs->H0_;
B = REMOTE_ThreadHandle(worker_p).current_yaam_regs->B_;
ENV = REMOTE_ThreadHandle(worker_p).current_yaam_regs->ENV_;

View File

@ -1163,7 +1163,7 @@ mark_variable(CELL_PTR current USES_REGS)
if (UNMARKED_MARK(current,local_bp)) {
POP_CONTINUATION();
}
if (current >= H0 && current < H) {
if (current >= H0 && current < HR) {
//fprintf(stderr,"%p M\n", current);
LOCAL_total_marked++;
if (current < LOCAL_HGEN) {
@ -1177,7 +1177,7 @@ mark_variable(CELL_PTR current USES_REGS)
next = GET_NEXT(ccur);
if (IsVarTerm(ccur)) {
if (IN_BETWEEN(LOCAL_GlobalBase,current,H) && GlobalIsAttVar(current) && current==next) {
if (IN_BETWEEN(LOCAL_GlobalBase,current,HR) && GlobalIsAttVar(current) && current==next) {
if (next < H0) POP_CONTINUATION();
if (!UNMARKED_MARK(next-1,local_bp)) {
//fprintf(stderr,"%p M\n", next-1);
@ -1222,7 +1222,7 @@ mark_variable(CELL_PTR current USES_REGS)
if (next >= HB && current < LCL0 && cnext != TermFoundVar) {
UNMARK(current);
*current = cnext;
if (current >= H0 && current < H) {
if (current >= H0 && current < HR) {
//fprintf(stderr,"%p M\n", current-1);
LOCAL_total_marked--;
if (current < LOCAL_HGEN) {
@ -1247,7 +1247,7 @@ mark_variable(CELL_PTR current USES_REGS)
/* This step is possible because we clean up the trail */
*current = UNMARK_CELL(cnext);
UNMARK(current);
if (current >= H0 && current < H ) {
if (current >= H0 && current < HR ) {
//fprintf(stderr,"%p M\n", current);
LOCAL_total_marked--;
if (current < LOCAL_HGEN) {
@ -1365,7 +1365,7 @@ mark_variable(CELL_PTR current USES_REGS)
MARK(next);
PUSH_POINTER(next PASS_REGS);
{
UInt sz = 1+SIZEOF_DOUBLE/SIZEOF_LONG_INT;
UInt sz = 1+SIZEOF_DOUBLE/SIZEOF_INT_P;
if (next < LOCAL_HGEN) {
LOCAL_total_oldies+= 1+sz;
} else {
@ -1736,7 +1736,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(LOCAL_GlobalBase,hp,H) && GlobalIsAttVar(hp) && !UNMARKED_MARK(hp-1,LOCAL_bp)) {
if (IN_BETWEEN(LOCAL_GlobalBase,hp,HR) && GlobalIsAttVar(hp) && !UNMARKED_MARK(hp-1,LOCAL_bp)) {
//fprintf(stderr,"%p M\n", hp);
LOCAL_total_marked++;
PUSH_POINTER(hp-1 PASS_REGS);
@ -1779,7 +1779,7 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B
} else if (IsPairTerm(trail_cell)) {
/* cannot safely ignore this */
CELL *cptr = RepPair(trail_cell);
if (IN_BETWEEN(LOCAL_GlobalBase,cptr,H)) {
if (IN_BETWEEN(LOCAL_GlobalBase,cptr,HR)) {
if (GlobalIsAttVar(cptr)) {
TrailTerm(trail_base) = (CELL)cptr;
mark_external_reference(&TrailTerm(trail_base) PASS_REGS);
@ -2617,7 +2617,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS)
if (IsVarTerm(trail_cell)) {
/* we need to check whether this is a honest to god trail entry */
/* make sure it is a heap cell before we test whether it has been marked */
if ((CELL *)trail_cell < H && (CELL *)trail_cell >= H0 && MARKED_PTR((CELL *)trail_cell)) {
if ((CELL *)trail_cell < HR && (CELL *)trail_cell >= H0 && MARKED_PTR((CELL *)trail_cell)) {
if (HEAP_PTR(trail_cell)) {
into_relocation_chain(&TrailTerm(dest), GET_NEXT(trail_cell) PASS_REGS);
}
@ -2635,7 +2635,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS)
CELL *pt0 = RepPair(trail_cell);
CELL flags;
if (IN_BETWEEN(LOCAL_GlobalBase, pt0, H)) {
if (IN_BETWEEN(LOCAL_GlobalBase, pt0, HR)) {
if (GlobalIsAttVar(pt0)) {
TrailTerm(dest) = trail_cell;
/* be careful with partial gc */
@ -3445,12 +3445,12 @@ compact_heap( USES_REGS1 )
next_hb = set_next_hb(gc_B PASS_REGS);
dest = H0 + LOCAL_total_marked - 1;
gc_B = update_B_H(gc_B, H, dest+1, dest+2
gc_B = update_B_H(gc_B, HR, dest+1, dest+2
#ifdef TABLING
, &depfr
#endif /* TABLING */
);
for (current = H - 1; current >= start_from; current--) {
for (current = HR - 1; current >= start_from; current--) {
if (MARKED_PTR(current)) {
CELL ccell = UNMARK_CELL(*current);
@ -3541,7 +3541,7 @@ compact_heap( USES_REGS1 )
*/
dest = (CELL_PTR) start_from;
for (current = start_from; current < H; current++) {
for (current = start_from; current < HR; current++) {
CELL ccur = *current;
if (MARKED_PTR(current)) {
CELL uccur = UNMARK_CELL(ccur);
@ -3577,7 +3577,7 @@ compact_heap( USES_REGS1 )
ccur = *current;
next = GET_NEXT(ccur);
if (HEAP_PTR(ccur) &&
(next = GET_NEXT(ccur)) < H && /* move current cell &
(next = GET_NEXT(ccur)) < HR && /* move current cell &
* push */
next > current) { /* into relocation chain */
*dest = ccur;
@ -3601,7 +3601,7 @@ compact_heap( USES_REGS1 )
(unsigned long int)found_marked);
#endif
H = dest; /* reset H */
HR = dest; /* reset H */
HB = B->cp_h;
#ifdef TABLING
if (B_FZ == (choiceptr)LCL0)
@ -3620,7 +3620,7 @@ compact_heap( USES_REGS1 )
static void
icompact_heap( USES_REGS1 )
{
CELL_PTR *iptr, *ibase = (CELL_PTR *)H;
CELL_PTR *iptr, *ibase = (CELL_PTR *)HR;
CELL_PTR dest;
CELL *next_hb;
#ifdef DEBUG
@ -3645,7 +3645,7 @@ icompact_heap( USES_REGS1 )
#endif /* TABLING */
next_hb = set_next_hb(gc_B PASS_REGS);
dest = (CELL_PTR) H0 + LOCAL_total_marked - 1;
gc_B = update_B_H(gc_B, H, dest+1, dest+2
gc_B = update_B_H(gc_B, HR, dest+1, dest+2
#ifdef TABLING
, &depfr
#endif /* TABLING */
@ -3778,7 +3778,7 @@ icompact_heap( USES_REGS1 )
(unsigned long int)found_marked);
#endif
H = dest; /* reset H */
HR = dest; /* reset H */
HB = B->cp_h;
#ifdef TABLING
if (B_FZ == (choiceptr)LCL0)
@ -3867,7 +3867,7 @@ compaction_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp USES_REGS)
{
CELL *CurrentH0 = NULL;
int icompact = (LOCAL_iptop < (CELL_PTR *)ASP && 10*LOCAL_total_marked < H-H0);
int icompact = (LOCAL_iptop < (CELL_PTR *)ASP && 10*LOCAL_total_marked < HR-H0);
if (icompact) {
/* we are going to reuse the total space */
@ -3908,7 +3908,7 @@ compaction_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp USES_REGS)
LOCAL_total_marked += LOCAL_total_oldies;
CurrentH0 = NULL;
}
quicksort((CELL_PTR *)H, 0, (LOCAL_iptop-(CELL_PTR *)H)-1);
quicksort((CELL_PTR *)HR, 0, (LOCAL_iptop-(CELL_PTR *)HR)-1);
icompact_heap( PASS_REGS1 );
} else
#endif /* HYBRID_SCHEME */
@ -3947,7 +3947,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS)
UInt alloc_sz;
int jmp_res;
heap_cells = H-H0;
heap_cells = HR-H0;
gc_verbose = is_gc_verbose();
effectiveness = 0;
gc_trace = FALSE;
@ -3984,7 +3984,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS)
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
#endif
fprintf(GLOBAL_stderr, "%% Start of garbage collection %lu:\n", (unsigned long int)LOCAL_GcCalls);
fprintf(GLOBAL_stderr, "%% Global: %8ld cells (%p-%p)\n", (long int)heap_cells,H0,H);
fprintf(GLOBAL_stderr, "%% Global: %8ld cells (%p-%p)\n", (long int)heap_cells,H0,HR);
fprintf(GLOBAL_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
fprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
(unsigned long int)(TR-(tr_fr_ptr)LOCAL_TrailBase),LOCAL_TrailBase,TR);
@ -4070,7 +4070,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS)
}
memset((void *)LOCAL_bp, 0, alloc_sz);
#ifdef HYBRID_SCHEME
LOCAL_iptop = (CELL_PTR *)H;
LOCAL_iptop = (CELL_PTR *)HR;
#endif
/* get the number of active registers */
LOCAL_HGEN = VarOfTerm(Yap_ReadTimedVar(LOCAL_GcGeneration));
@ -4144,7 +4144,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS)
if (gc_verbose) {
fprintf(GLOBAL_stderr, "%% GC %lu took %g sec, total of %g sec doing GC so far.\n", (unsigned long int)LOCAL_GcCalls, (double)gc_time/1000, (double)LOCAL_TotGcTime/1000);
fprintf(GLOBAL_stderr, "%% Left %ld cells free in stacks.\n",
(unsigned long int)(ASP-H));
(unsigned long int)(ASP-HR));
}
check_global();
return effectiveness;
@ -4231,19 +4231,19 @@ call_gc(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop USES_REGS)
if (gc_on && !(LOCAL_PrologMode & InErrorMode) &&
/* make sure there is a point in collecting the heap */
(ASP-H0)*sizeof(CELL) > gc_lim &&
H-LOCAL_HGEN > (LCL0-ASP)/2) {
HR-LOCAL_HGEN > (LCL0-ASP)/2) {
effectiveness = do_gc(predarity, current_env, nextop PASS_REGS);
if (effectiveness < 0)
return FALSE;
if (effectiveness > 90 && !gc_t) {
while (gc_margin < (H-H0)/sizeof(CELL))
while (gc_margin < (HR-H0)/sizeof(CELL))
gc_margin <<= 1;
}
} else {
effectiveness = 0;
}
/* expand the stack if effectiveness is less than 20 % */
if (ASP - H < gc_margin/sizeof(CELL) ||
if (ASP - HR < gc_margin/sizeof(CELL) ||
effectiveness < 20) {
LeaveGCMode( PASS_REGS1 );
#ifndef YAPOR

View File

@ -2756,10 +2756,10 @@ compile_index(struct intermediates *cint)
siglongjmp(cint->CompilerBotch,2);
}
}
cint->freep = (char *)H;
cint->freep = (char *)HR;
#else
/* reserve double the space for compiler */
cint->cls = (ClauseDef *)H;
cint->cls = (ClauseDef *)HR;
if (cint->cls+2*NClauses > (ClauseDef *)(ASP-4096)) {
/* tell how much space we need */
LOCAL_Error_Size += NClauses*sizeof(ClauseDef);
@ -3809,7 +3809,7 @@ expand_index(struct intermediates *cint) {
}
}
#else
cint->cls = (ClauseDef *)H;
cint->cls = (ClauseDef *)HR;
if (cint->cls+2*nclauses > (ClauseDef *)(ASP-4096)) {
/* tell how much space we need (worst case) */
LOCAL_Error_Size += 2*NClauses*sizeof(ClauseDef);
@ -3837,7 +3837,7 @@ expand_index(struct intermediates *cint) {
}
}
#else
cint->cls = (ClauseDef *)H;
cint->cls = (ClauseDef *)HR;
if (cint->cls+2*NClauses > (ClauseDef *)(ASP-4096)) {
/* tell how much space we need (worst case) */
LOCAL_Error_Size += 2*NClauses*sizeof(ClauseDef);
@ -3866,7 +3866,7 @@ expand_index(struct intermediates *cint) {
return labp;
}
#if USE_SYSTEM_MALLOC
cint->freep = (char *)H;
cint->freep = (char *)HR;
#else
cint->freep = (char *)(max+1);
#endif
@ -6056,7 +6056,7 @@ store_clause_choice_point(Term t1, Term tb, Term tr, yamop *ipc, PredEntry *pe,
tsp[3] = tb;
tsp[4] = tr;
bptr->cp_tr = TR;
HB = bptr->cp_h = H;
HB = bptr->cp_h = HR;
#ifdef DEPTH_LIMIT
bptr->cp_depth = DEPTH;
#endif
@ -6079,7 +6079,7 @@ update_clause_choice_point(yamop *ipc, yamop *ap_pc USES_REGS)
{
Term tpc = MkIntegerTerm((Int)ipc);
B->cp_args[1] = tpc;
B->cp_h = H;
B->cp_h = HR;
B->cp_ap = ap_pc;
}

View File

@ -425,9 +425,9 @@ p_dif( USES_REGS1 )
/* make B and HB point to H to guarantee all bindings will
* be trailed
*/
HBREG = H;
B = (choiceptr) H;
B->cp_h = H;
HBREG = HR;
B = (choiceptr) HR;
B->cp_h = HR;
SET_BB(B);
save_hb();
d0 = Yap_IUnify(d0, d1);
@ -442,7 +442,7 @@ p_dif( USES_REGS1 )
B = pt1;
SET_BB(PROTECT_FROZEN_B(pt1));
#ifdef COROUTINING
H = HBREG;
HR = HBREG;
#endif
HBREG = B->cp_h;
/* untrail all bindings made by Yap_IUnify */
@ -707,10 +707,10 @@ p_functor( USES_REGS1 ) /* functor(?,?,?) */
/* We made it!!!!! we got in d0 the name, in d1 the arity and
* in pt0 the variable to bind it to. */
if (d0 == TermDot && d1 == 2) {
RESET_VARIABLE(H);
RESET_VARIABLE(H+1);
d0 = AbsPair(H);
H += 2;
RESET_VARIABLE(HR);
RESET_VARIABLE(HR+1);
d0 = AbsPair(HR);
HR += 2;
}
else if ((Int)d1 > 0) {
/* now let's build a compound term */
@ -724,9 +724,9 @@ p_functor( USES_REGS1 ) /* functor(?,?,?) */
}
else
d0 = (CELL) Yap_MkFunctor(AtomOfTerm(d0), (Int) d1);
pt1 = H;
pt1 = HR;
*pt1++ = d0;
d0 = AbsAppl(H);
d0 = AbsAppl(HR);
if (pt1+d1 > ENV - StackGap( PASS_REGS1 )) {
if (!Yap_gcl((1+d1)*sizeof(CELL), 3, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
@ -739,7 +739,7 @@ p_functor( USES_REGS1 ) /* functor(?,?,?) */
pt1++;
}
/* done building the term */
H = pt1;
HR = pt1;
ENDP(pt1);
} else if ((Int)d1 < 0) {
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,MkIntegerTerm(d1),"functor/3");

View File

@ -271,7 +271,7 @@ syntax_error (TokEntry * tokptr, IOSTREAM *st, Term *outp)
Int start, err = 0, end;
Term tf[7];
Term *error = tf+3;
CELL *Hi = H;
CELL *Hi = HR;
int has_qq = FALSE;
/* make sure to globalise variable */
@ -280,12 +280,12 @@ syntax_error (TokEntry * tokptr, IOSTREAM *st, Term *outp)
clean_vars(LOCAL_AnonVarTable);
while (1) {
Term ts[2];
if (H > ASP-1024) {
if (HR > ASP-1024) {
tf[3] = TermNil;
err = 0;
end = 0;
/* for some reason moving this earlier confuses gcc on solaris */
H = Hi;
HR = Hi;
break;
}
if (tokptr == LOCAL_toktide) {
@ -302,6 +302,7 @@ syntax_error (TokEntry * tokptr, IOSTREAM *st, Term *outp)
}
break;
case QuasiQuotes_tok:
case WQuasiQuotes_tok:
{
if (has_qq) {
Term t0[1];
@ -372,7 +373,7 @@ syntax_error (TokEntry * tokptr, IOSTREAM *st, Term *outp)
}
/* now we can throw away tokens, so we can unify and possibly overwrite TR */
Yap_unify(*outp, MkVarTerm());
if (IsVarTerm(*outp) && (VarOfTerm(*outp) > H || VarOfTerm(*outp) < H0)) {
if (IsVarTerm(*outp) && (VarOfTerm(*outp) > HR || VarOfTerm(*outp) < H0)) {
tf[0] = Yap_MkNewApplTerm(Yap_MkFunctor(AtomRead,1),1);
} else {
tf[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomRead,1),1,outp);
@ -501,12 +502,12 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
}
/* Scans the term using stack space */
while (TRUE) {
old_H = H;
old_H = HR;
LOCAL_Comments = TermNil;
LOCAL_CommentsNextChar = LOCAL_CommentsTail = NULL;
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(inp_stream, store_comments, &tpos, rd);
if (LOCAL_Error_TYPE != YAP_NO_ERROR && seekable) {
H = old_H;
HR = old_H;
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
if (seekable) {
Sseek64(inp_stream, cpos, SIO_SEEK_SET);
@ -540,7 +541,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
LOCAL_Error_TYPE = YAP_NO_ERROR;
/* preserve value of H after scanning: otherwise we may lose strings
and floats */
old_H = H;
old_H = HR;
if (tokstart != NULL && tokstart->Tok == Ord (eot_tok)) {
/* did we get the end of file from an abort? */
if (LOCAL_ErrorMessage &&
@ -567,7 +568,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
tr_fr_ptr old_TR = TR;
H = old_H;
HR = old_H;
TR = (tr_fr_ptr)LOCAL_ScannerStack;
if (!strcmp(LOCAL_ErrorMessage,"Stack Overflow"))
@ -579,7 +580,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
if (res) {
LOCAL_ScannerStack = (char *)TR;
TR = old_TR;
old_H = H;
old_H = HR;
LOCAL_tokptr = LOCAL_toktide = tokstart;
LOCAL_ErrorMessage = NULL;
goto repeat_cycle;
@ -611,7 +612,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
return FALSE;
if (rd->varnames) {
while (TRUE) {
CELL *old_H = H;
CELL *old_H = HR;
if (setjmp(LOCAL_IOBotch) == 0) {
v = Yap_VarNames(LOCAL_VarTable, TermNil);
@ -622,7 +623,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
old_TR = TR;
/* restart global */
H = old_H;
HR = old_H;
TR = (tr_fr_ptr)LOCAL_ScannerStack;
Yap_growstack_in_parser(&old_TR, &tokstart, &LOCAL_VarTable);
LOCAL_ScannerStack = (char *)TR;
@ -636,7 +637,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
if (rd->variables) {
while (TRUE) {
CELL *old_H = H;
CELL *old_H = HR;
if (setjmp(LOCAL_IOBotch) == 0) {
v = Yap_Variables(LOCAL_VarTable, TermNil);
@ -647,7 +648,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
old_TR = TR;
/* restart global */
H = old_H;
HR = old_H;
TR = (tr_fr_ptr)LOCAL_ScannerStack;
Yap_growstack_in_parser(&old_TR, &tokstart, &LOCAL_VarTable);
LOCAL_ScannerStack = (char *)TR;
@ -659,7 +660,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
}
if (rd->singles) {
while (TRUE) {
CELL *old_H = H;
CELL *old_H = HR;
if (setjmp(LOCAL_IOBotch) == 0) {
v = Yap_Singletons(LOCAL_VarTable, TermNil);
@ -670,7 +671,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
old_TR = TR;
/* restart global */
H = old_H;
HR = old_H;
TR = (tr_fr_ptr)LOCAL_ScannerStack;
Yap_growstack_in_parser(&old_TR, &tokstart, &LOCAL_VarTable);
LOCAL_ScannerStack = (char *)TR;

View File

@ -36,7 +36,7 @@ p_setarg( USES_REGS1 )
Int i;
if (IsVarTerm(t3) &&
VarOfTerm(t3) > H &&VarOfTerm(t3) < ASP) {
VarOfTerm(t3) > HR &&VarOfTerm(t3) < ASP) {
/* local variable */
Term tn = MkVarTerm();
Bind_Local(VarOfTerm(t3), tn);
@ -124,17 +124,17 @@ NewTimedVar(CELL val USES_REGS)
Term out;
timed_var *tv;
if (IsVarTerm(val) &&
VarOfTerm(val) > H) {
VarOfTerm(val) > HR) {
Term nval = MkVarTerm();
Bind_Local(VarOfTerm(val), nval);
val = nval;
}
out = AbsAppl(H);
*H++ = (CELL)FunctorMutable;
tv = (timed_var *)H;
out = AbsAppl(HR);
*HR++ = (CELL)FunctorMutable;
tv = (timed_var *)HR;
RESET_VARIABLE(&(tv->clock));
tv->value = val;
H += sizeof(timed_var)/sizeof(CELL);
HR += sizeof(timed_var)/sizeof(CELL);
return(out);
}
@ -149,13 +149,13 @@ Term
Yap_NewEmptyTimedVar( void )
{
CACHE_REGS
Term out = AbsAppl(H);
Term out = AbsAppl(HR);
timed_var *tv;
*H++ = (CELL)FunctorMutable;
tv = (timed_var *)H;
*HR++ = (CELL)FunctorMutable;
tv = (timed_var *)HR;
RESET_VARIABLE(&(tv->clock));
RESET_VARIABLE(&(tv->value));
H += sizeof(timed_var)/sizeof(CELL);
HR += sizeof(timed_var)/sizeof(CELL);
return(out);
}
@ -181,7 +181,7 @@ UpdateTimedVar(Term inv, Term new USES_REGS)
CELL t = tv->value;
CELL* timestmp = (CELL *)(tv->clock);
if (IsVarTerm(new) &&
VarOfTerm(new) > H) {
VarOfTerm(new) > HR) {
Term nnew = MkVarTerm();
Bind_Local(VarOfTerm(new), nnew);
new = nnew;
@ -200,9 +200,9 @@ UpdateTimedVar(Term inv, Term new USES_REGS)
#endif
tv->value = new;
} else {
Term nclock = (Term)H;
Term nclock = (Term)HR;
MaBind(&(tv->value), new);
*H++ = TermFoundVar;
*HR++ = TermFoundVar;
MaBind(&(tv->clock), nclock);
}
return(t);

View File

@ -52,11 +52,11 @@ Term
Yap_MkNewPairTerm(void)
{
CACHE_REGS
register CELL *p = H;
register CELL *p = HR;
RESET_VARIABLE(H);
RESET_VARIABLE(H+1);
H+=2;
RESET_VARIABLE(HR);
RESET_VARIABLE(HR+1);
HR+=2;
return (AbsPair(p));
}
@ -66,15 +66,15 @@ Yap_MkApplTerm(Functor f, unsigned int n, register Term *a)
* args a */
{
CACHE_REGS
CELL *t = H;
CELL *t = HR;
if (n == 0)
return (MkAtomTerm(NameOfFunctor(f)));
if (f == FunctorList)
return MkPairTerm(a[0], a[1]);
*H++ = (CELL) f;
*HR++ = (CELL) f;
while (n--)
*H++ = (CELL) * a++;
*HR++ = (CELL) * a++;
return (AbsAppl(t));
}
@ -84,20 +84,20 @@ Yap_MkNewApplTerm(Functor f, unsigned int n)
* args a */
{
CACHE_REGS
CELL *t = H;
CELL *t = HR;
if (n == 0)
return (MkAtomTerm(NameOfFunctor(f)));
if (f == FunctorList) {
RESET_VARIABLE(H);
RESET_VARIABLE(H+1);
H+=2;
RESET_VARIABLE(HR);
RESET_VARIABLE(HR+1);
HR+=2;
return (AbsPair(t));
}
*H++ = (CELL) f;
*HR++ = (CELL) f;
while (n--) {
RESET_VARIABLE(H);
H++;
RESET_VARIABLE(HR);
HR++;
}
return (AbsAppl(t));
}
@ -113,7 +113,7 @@ Yap_Globalise(Term t)
if (!IsVarTerm(t))
return t;
vt = VarOfTerm(t);
if (vt <= H && vt > H0)
if (vt <= HR && vt > H0)
return t;
tn = MkVarTerm();
Yap_unify(t, tn);

View File

@ -83,7 +83,7 @@ static Term ParseTerm(read_data *, int, JMPBUFF * CACHE_TYPE);
#define TRY(S,P) \
{ Volatile JMPBUFF *saveenv, newenv; \
Volatile TokEntry *saveT=LOCAL_tokptr; \
Volatile CELL *saveH=H; \
Volatile CELL *saveH=HR; \
Volatile int savecurprio=curprio; \
saveenv=FailBuff; \
if(!sigsetjmp(newenv.JmpBuff, 0)) { \
@ -93,7 +93,7 @@ static Term ParseTerm(read_data *, int, JMPBUFF * CACHE_TYPE);
P; \
} \
else { FailBuff=saveenv; \
H=saveH; \
HR=saveH; \
curprio = savecurprio; \
LOCAL_tokptr=saveT; \
} \
@ -102,7 +102,7 @@ static Term ParseTerm(read_data *, int, JMPBUFF * CACHE_TYPE);
#define TRY3(S,P,F) \
{ Volatile JMPBUFF *saveenv, newenv; \
Volatile TokEntry *saveT=LOCAL_tokptr; \
Volatile CELL *saveH=H; \
Volatile CELL *saveH=HR; \
saveenv=FailBuff; \
if(!sigsetjmp(newenv.JmpBuff, 0)) { \
FailBuff = &newenv; \
@ -112,7 +112,7 @@ static Term ParseTerm(read_data *, int, JMPBUFF * CACHE_TYPE);
} \
else { \
FailBuff=saveenv; \
H=saveH; \
HR=saveH; \
LOCAL_tokptr=saveT; \
F } \
}
@ -193,7 +193,7 @@ VarNames(VarEntry *p,Term l USES_REGS)
o = Yap_MkApplTerm(FunctorEq, 2, t);
o = MkPairTerm(o, VarNames(p->VarRight,
VarNames(p->VarLeft,l PASS_REGS) PASS_REGS));
if (H > ASP-4096) {
if (HR > ASP-4096) {
save_machine_regs();
siglongjmp(LOCAL_IOBotch,1);
}
@ -226,7 +226,7 @@ Singletons(VarEntry *p,Term l USES_REGS)
o = Yap_MkApplTerm(FunctorEq, 2, t);
o = MkPairTerm(o, Singletons(p->VarRight,
Singletons(p->VarLeft,l PASS_REGS) PASS_REGS));
if (H > ASP-4096) {
if (HR > ASP-4096) {
save_machine_regs();
siglongjmp(LOCAL_IOBotch,1);
}
@ -253,7 +253,7 @@ Variables(VarEntry *p,Term l USES_REGS)
if (p != NULL) {
Term o;
o = MkPairTerm(p->VarAdr, Variables(p->VarRight,Variables(p->VarLeft,l PASS_REGS) PASS_REGS));
if (H > ASP-4096) {
if (HR > ASP-4096) {
save_machine_regs();
siglongjmp(LOCAL_IOBotch,1);
}
@ -472,7 +472,7 @@ ParseArgs(read_data *rd, Atom a, wchar_t close, JMPBUFF *FailBuff, Term arg1 USE
FAIL;
}
t = Yap_MkApplTerm(func, nargs, p);
if (H > ASP-4096) {
if (HR > ASP-4096) {
LOCAL_ErrorMessage = "Stack Overflow";
return TermNil;
}
@ -500,7 +500,7 @@ ParseArgs(read_data *rd, Atom a, wchar_t close, JMPBUFF *FailBuff, Term arg1 USE
* Needed because the arguments for the functor are placed in reverse
* order
*/
if (H > ASP-(nargs+1)) {
if (HR > ASP-(nargs+1)) {
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}
@ -520,7 +520,7 @@ ParseArgs(read_data *rd, Atom a, wchar_t close, JMPBUFF *FailBuff, Term arg1 USE
else
t = Yap_MkApplTerm(func, nargs, p);
#endif
if (H > ASP-4096) {
if (HR > ASP-4096) {
LOCAL_ErrorMessage = "Stack Overflow";
return TermNil;
}
@ -547,10 +547,10 @@ ParseList(read_data *rd, JMPBUFF *FailBuff USES_REGS)
{
Term o;
CELL *to_store;
o = AbsPair(H);
o = AbsPair(HR);
loop:
to_store = H;
H+=2;
to_store = HR;
HR+=2;
to_store[0] = ParseTerm(rd, 999, FailBuff PASS_REGS);
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)) {
if (((int) LOCAL_tokptr->TokInfo) == ',') {
@ -561,12 +561,12 @@ ParseList(read_data *rd, JMPBUFF *FailBuff USES_REGS)
to_store[1] = ParseTerm(rd, 999, FailBuff PASS_REGS);
} else {
/* check for possible overflow against local stack */
if (H > ASP-4096) {
if (HR > ASP-4096) {
to_store[1] = TermNil;
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
} else {
to_store[1] = AbsPair(H);
to_store[1] = AbsPair(HR);
goto loop;
}
}
@ -664,7 +664,7 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
t = ParseTerm(rd, oprprio, FailBuff PASS_REGS);
t = Yap_MkApplTerm(func, 1, &t);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
if (HR > ASP-4096) {
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}
@ -749,7 +749,7 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
t = ParseTerm(rd, 1200, FailBuff PASS_REGS);
t = Yap_MkApplTerm(FunctorBraces, 1, &t);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
if (HR > ASP-4096) {
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}
@ -860,7 +860,7 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
args[1] = ParseTerm(rd, oprprio, FailBuff PASS_REGS);
t = Yap_MkApplTerm(func, 2, args);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
if (HR > ASP-4096) {
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}
@ -883,7 +883,7 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
}
t = Yap_MkApplTerm(func, 1, &t);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
if (HR > ASP-4096) {
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}
@ -902,7 +902,7 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
args[1] = ParseTerm(rd, 1000, FailBuff PASS_REGS);
t = Yap_MkApplTerm(FunctorComma, 2, args);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
if (HR > ASP-4096) {
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}
@ -917,7 +917,7 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
args[1] = ParseTerm(rd, oprprio, FailBuff PASS_REGS);
t = Yap_MkApplTerm(FunctorVBar, 2, args);
/* check for possible overflow against local stack */
if (H > ASP-4096) {
if (HR > ASP-4096) {
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}

View File

@ -369,7 +369,7 @@ put_info(int info, int mode USES_REGS)
if (putout(Unsigned(LCL0)-Unsigned(ASP)) < 0)
return -1;
/* Space used for global stack */
if (putout(Unsigned(H) - Unsigned(LOCAL_GlobalBase)) < 0)
if (putout(Unsigned(HR) - Unsigned(LOCAL_GlobalBase)) < 0)
return -1;
/* Space used for trail */
if (putout(Unsigned(TR) - Unsigned(LOCAL_TrailBase)) < 0)
@ -396,7 +396,7 @@ save_regs(int mode USES_REGS)
return -1;
if (putcellptr(LCL0) < 0)
return -1;
if (putcellptr(H) < 0)
if (putcellptr(HR) < 0)
return -1;
if (putcellptr(HB) < 0)
return -1;
@ -535,7 +535,7 @@ save_stacks(int mode USES_REGS)
if (mywrite(splfild, (char *) ASP, j) < 0)
return -1;
/* Save the global stack */
j = Unsigned(H) - Unsigned(LOCAL_GlobalBase);
j = Unsigned(HR) - Unsigned(LOCAL_GlobalBase);
if (mywrite(splfild, (char *) LOCAL_GlobalBase, j) < 0)
return -1;
/* Save the trail */
@ -834,7 +834,7 @@ get_regs(int flag USES_REGS)
LCL0 = get_cellptr();
if (LOCAL_ErrorMessage)
return -1;
H = get_cellptr();
HR = get_cellptr();
if (LOCAL_ErrorMessage)
return -1;
HB = get_cellptr();
@ -929,7 +929,7 @@ get_regs(int flag USES_REGS)
LOCAL_OldASP = ASP;
LOCAL_OldLCL0 = LCL0;
LOCAL_OldGlobalBase = (CELL *)LOCAL_GlobalBase;
LOCAL_OldH = H;
LOCAL_OldH = HR;
LOCAL_OldTR = TR;
LOCAL_GDiff = Unsigned(NewGlobalBase) - Unsigned(LOCAL_GlobalBase);
LOCAL_GDiff0 = 0;
@ -977,7 +977,7 @@ CopyStacks( USES_REGS1 )
NewASP = (char *) (Unsigned(ASP) + (Unsigned(LCL0) - Unsigned(LOCAL_OldLCL0)));
if (myread(splfild, (char *) NewASP, j) < 0)
return -1;
j = Unsigned(H) - Unsigned(LOCAL_OldGlobalBase);
j = Unsigned(HR) - Unsigned(LOCAL_OldGlobalBase);
if (myread(splfild, (char *) LOCAL_GlobalBase, j) < 0)
return -1;
j = Unsigned(TR) - Unsigned(LOCAL_OldTrailBase);
@ -1060,7 +1060,7 @@ restore_regs(int flag USES_REGS)
CP = PtoOpAdjust(CP);
ENV = PtoLocAdjust(ENV);
ASP = PtoLocAdjust(ASP);
H = PtoGloAdjust(H);
HR = PtoGloAdjust(HR);
B = (choiceptr)PtoLocAdjust(CellPtr(B));
TR = PtoTRAdjust(TR);
P = PtoOpAdjust(P);
@ -1149,8 +1149,8 @@ rehash(CELL *oldcode, int NOfE, int KindOfEntries USES_REGS)
if (LOCAL_HDiff == 0)
return;
basep = H;
if (H + (NOfE*2) > ASP) {
basep = HR;
if (HR + (NOfE*2) > ASP) {
basep = (CELL *)TR;
if (basep + (NOfE*2) > (CELL *)LOCAL_TrailTop) {
if (!Yap_growtrail((ADDR)(basep + (NOfE*2))-LOCAL_TrailTop, TRUE)) {

View File

@ -631,22 +631,18 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
}
}
if (ch == 'e' || ch == 'E') {
char cbuff = ch;
if (--max_size == 0) {
return num_send_error_message("Number Too Long");
}
*sp++ = ch;
ch = getchr(inp_stream);
if (ch == '-') {
cbuff = '-';
if (--max_size == 0) {
return num_send_error_message("Number Too Long");
}
*sp++ = '-';
ch = getchr(inp_stream);
} else if (ch == '+') {
cbuff = '+';
ch = getchr(inp_stream);
}
if (chtype(ch) != NU) {
@ -719,7 +715,7 @@ Yap_scan_num(IOSTREAM *inp)
return TermNil;
}
cherr = '\0';
if (ASP-H < 1024)
if (ASP-HR < 1024)
return TermNil;
out = get_num(&ch, &cherr, inp, ptr, 4096, sign); /* */
PopScannerMemory(ptr, 4096);
@ -731,7 +727,7 @@ Yap_scan_num(IOSTREAM *inp)
#define CHECK_SPACE() \
if (ASP-H < 1024) { \
if (ASP-HR < 1024) { \
LOCAL_ErrorMessage = "Stack Overflow"; \
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR; \
LOCAL_Error_Size = 0L; \
@ -744,8 +740,8 @@ Yap_scan_num(IOSTREAM *inp)
static void
open_comment(int ch, IOSTREAM *inp_stream USES_REGS) {
CELL *h0 = H;
H += 5;
CELL *h0 = HR;
HR += 5;
h0[0] = AbsAppl(h0+2);
h0[1] = TermNil;
if (!LOCAL_CommentsTail) {

View File

@ -58,12 +58,12 @@ build_new_list(CELL *pt, Term t USES_REGS)
}
pt += 2;
if (pt > ASP - 4096) {
if (!Yap_gcl((ASP-H)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
if (!Yap_gcl((ASP-HR)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return(FALSE);
}
t = Deref(ARG1);
pt = H;
pt = HR;
out = 0;
goto restart;
}
@ -346,7 +346,7 @@ static Int
p_sort( USES_REGS1 )
{
/* use the heap to build a new list */
CELL *pt = H;
CELL *pt = HR;
Term out;
/* list size */
Int size;
@ -355,13 +355,13 @@ p_sort( USES_REGS1 )
return(FALSE);
if (size < 2)
return(Yap_unify(ARG1, ARG2));
pt = H; /* because of possible garbage collection */
pt = HR; /* because of possible garbage collection */
/* make sure no one writes on our temp data structure */
H += size*2;
HR += size*2;
/* reserve the necessary space */
size = compact_mergesort(pt, size, M_EVEN);
/* reajust space */
H = pt+size*2;
HR = pt+size*2;
adjust_vector(pt, size);
out = AbsPair(pt);
return(Yap_unify(out, ARG2));
@ -371,7 +371,7 @@ static Int
p_msort( USES_REGS1 )
{
/* use the heap to build a new list */
CELL *pt = H;
CELL *pt = HR;
Term out;
/* list size */
Int size;
@ -380,9 +380,9 @@ p_msort( USES_REGS1 )
return(FALSE);
if (size < 2)
return(Yap_unify(ARG1, ARG2));
pt = H; /* because of possible garbage collection */
pt = HR; /* because of possible garbage collection */
/* reserve the necessary space */
H += size*2;
HR += size*2;
simple_mergesort(pt, size, M_EVEN);
adjust_vector(pt, size);
out = AbsPair(pt);
@ -393,7 +393,7 @@ static Int
p_ksort( USES_REGS1 )
{
/* use the heap to build a new list */
CELL *pt = H;
CELL *pt = HR;
Term out;
/* list size */
Int size;
@ -403,8 +403,8 @@ p_ksort( USES_REGS1 )
if (size < 2)
return(Yap_unify(ARG1, ARG2));
/* reserve the necessary space */
pt = H; /* because of possible garbage collection */
H += size*2;
pt = HR; /* because of possible garbage collection */
HR += size*2;
if (!key_mergesort(pt, size, M_EVEN, FunctorMinus))
return(FALSE);
adjust_vector(pt, size);

View File

@ -634,15 +634,15 @@ p_univ( USES_REGS1 )
}
build_compound:
/* build the term directly on the heap */
Ar = H;
H++;
Ar = HR;
HR++;
while (!IsVarTerm(twork) && IsPairTerm(twork)) {
*H++ = HeadOfTerm(twork);
if (H > ASP - 1024) {
*HR++ = HeadOfTerm(twork);
if (HR > ASP - 1024) {
/* restore space */
H = Ar;
if (!Yap_gcl((ASP-H)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
HR = Ar;
if (!Yap_gcl((ASP-HR)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
@ -671,11 +671,11 @@ p_univ( USES_REGS1 )
arity, CellPtr(TR));
}
#else
arity = H-Ar-1;
arity = HR-Ar-1;
if (at == AtomDot && arity == 2) {
Ar[0] = Ar[1];
Ar[1] = Ar[2];
H --;
HR --;
twork = AbsPair(Ar);
} else {
*Ar = (CELL)(Yap_MkFunctor(at, arity));
@ -716,7 +716,7 @@ p_univ( USES_REGS1 )
} else
#endif
{
while (H+arity*2 > ASP-1024) {
while (HR+arity*2 > ASP-1024) {
if (!Yap_gcl((arity*2)*sizeof(CELL), 2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return(FALSE);
@ -1301,7 +1301,7 @@ Yap_show_statistics(void)
frag);
fprintf(GLOBAL_stderr, "Stack Space: %ld (%ld for Global, %ld for local).\n",
(unsigned long int)(sizeof(CELL)*(LCL0-H0)),
(unsigned long int)(sizeof(CELL)*(H-H0)),
(unsigned long int)(sizeof(CELL)*(HR-H0)),
(unsigned long int)(sizeof(CELL)*(LCL0-ASP)));
fprintf(GLOBAL_stderr, "Trail Space: %ld (%ld used).\n",
(unsigned long int)(sizeof(tr_fr_ptr)*(Unsigned(LOCAL_TrailTop)-Unsigned(LOCAL_TrailBase))),
@ -1376,7 +1376,7 @@ GlobalMax(void)
CELL *pt;
if (GlobalTide != StkWidth) {
pt = H;
pt = HR;
while (pt+2 < ASP) {
if (pt[0] == 0 &&
pt[1] == 0 &&
@ -1419,7 +1419,7 @@ LocalMax(void)
if (LocalTide != StkWidth) {
pt = LCL0;
while (pt-3 > H) {
while (pt-3 > HR) {
if (pt[-1] == 0 &&
pt[-2] == 0 &&
pt[-3] == 0)
@ -1427,7 +1427,7 @@ LocalMax(void)
else
--pt;
}
if (pt-3 > H)
if (pt-3 > HR)
i = Unsigned(LCL0) - Unsigned(pt);
else
/* so that both Local and Global have reached maximum width */
@ -1477,7 +1477,7 @@ static Int
p_statistics_stacks_info( USES_REGS1 )
{
Term tmax = MkIntegerTerm(Unsigned(LCL0) - Unsigned(H0));
Term tgusage = MkIntegerTerm(Unsigned(H) - Unsigned(H0));
Term tgusage = MkIntegerTerm(Unsigned(HR) - Unsigned(H0));
Term tlusage = MkIntegerTerm(Unsigned(LCL0) - Unsigned(ASP));
return(Yap_unify(tmax, ARG1) && Yap_unify(tgusage,ARG2) && Yap_unify(tlusage,ARG3));

View File

@ -205,7 +205,6 @@ Yap_InitSysPath(void) {
strncpy(LOCAL_FileNameBuf, YAP_SHAREDIR, YAP_FILENAME_MAX);
#if _MSC_VER || defined(__MINGW32__)
{
DWORD fatts;
int buflen;
char *pt;
@ -2733,7 +2732,9 @@ set_fpu_exceptions(int flag)
#if HAVE_FETESTEXCEPT
feclearexcept(FE_ALL_EXCEPT);
#endif
#ifndef _WIN32
my_signal (SIGFPE, HandleMatherr);
#endif
} else {
/* do IEEE arithmetic in the way the big boys do */
#if defined(__hpux)
@ -2748,7 +2749,9 @@ set_fpu_exceptions(int flag)
int v = _FPU_IEEE;
_FPU_SETCW(v);
#endif
#ifndef _WIN32
my_signal (SIGFPE, SIG_IGN);
#endif
}
}

View File

@ -39,7 +39,7 @@ Globalize(Term v USES_REGS)
if (!IsVarTerm(v = Deref(v))) {
return v;
}
if (VarOfTerm(v) > H && VarOfTerm(v) < LCL0) {
if (VarOfTerm(v) > HR && VarOfTerm(v) < LCL0) {
Bind_Local(VarOfTerm(v), MkVarTerm());
v = Deref(v);
}
@ -591,7 +591,7 @@ write_strings( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng
char *cp = s, *buf;
LOCAL_TERM_ERROR( 2*(lim-s) );
buf = buf_from_tstring(H);
buf = buf_from_tstring(HR);
while (*cp && cp < lim) {
int chr;
cp = utf8_get_char(cp, &chr);
@ -614,7 +614,7 @@ write_strings( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng
char *buf;
LOCAL_TERM_ERROR( 2*(lim-s) );
buf = buf_from_tstring(H);
buf = buf_from_tstring(HR);
while (cp < lim) {
int chr;
cp = get_char(cp, &chr);
@ -636,7 +636,7 @@ write_strings( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng
char *buf;
LOCAL_TERM_ERROR( 2*(lim-s) );
buf = buf_from_tstring(H);
buf = buf_from_tstring(HR);
while (wp < lim) {
int chr;
wp = get_wchar(wp, &chr);
@ -658,7 +658,7 @@ write_strings( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng
static Term
write_atoms( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng USES_REGS)
{
Term t = AbsPair(H);
Term t = AbsPair(HR);
size_t sz = 0;
size_t min = 0, max = leng;
if (out->type & (YAP_STRING_NCHARS|YAP_STRING_TRUNC)) {
@ -677,9 +677,9 @@ write_atoms( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U
int chr;
cp = utf8_get_char(cp, &chr);
w[0] = chr;
H[0] = MkAtomTerm(Yap_LookupMaybeWideAtom(w));
H[1] = AbsPair(H+2);
H += 2;
HR[0] = MkAtomTerm(Yap_LookupMaybeWideAtom(w));
HR[1] = AbsPair(HR+2);
HR += 2;
sz++;
if (sz == max) break;
}
@ -696,9 +696,9 @@ write_atoms( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U
int chr;
cp = get_char(cp, &chr);
w[0] = chr;
H[0] = MkAtomTerm(Yap_LookupAtom(w));
H[1] = AbsPair(H+2);
H += 2;
HR[0] = MkAtomTerm(Yap_LookupAtom(w));
HR[1] = AbsPair(HR+2);
HR += 2;
sz++;
if (sz == max) break;
}
@ -715,26 +715,26 @@ write_atoms( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U
int chr;
cp = get_wchar(cp, &chr);
w[0] = chr;
H[0] = MkAtomTerm(Yap_LookupMaybeWideAtom(w));
H[1] = AbsPair(H+2);
H += 2;
HR[0] = MkAtomTerm(Yap_LookupMaybeWideAtom(w));
HR[1] = AbsPair(HR+2);
HR += 2;
sz++;
if (sz == max) break;
}
}
}
while (sz < min) {
H[0] = MkAtomTerm(AtomEmptyAtom);
H[1] = AbsPair(H+2);
H += 2;
HR[0] = MkAtomTerm(AtomEmptyAtom);
HR[1] = AbsPair(HR+2);
HR += 2;
sz++;
}
if (out->type & YAP_STRING_DIFF) {
if (sz == 0) t = out->dif;
else H[-1] = Globalize(out->dif PASS_REGS);
else HR[-1] = Globalize(out->dif PASS_REGS);
} else {
if (sz == 0) t = TermNil;
else H[-1] = TermNil;
else HR[-1] = TermNil;
}
out->val.t = t;
return (t);
@ -743,7 +743,7 @@ write_atoms( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U
static Term
write_codes( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng USES_REGS)
{
Term t = AbsPair(H);
Term t = AbsPair(HR);
size_t min = 0, max = leng;
size_t sz = 0;
@ -760,9 +760,9 @@ write_codes( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U
while (*cp && cp < lim) {
int chr;
cp = utf8_get_char(cp, &chr);
H[0] = MkIntTerm(chr);
H[1] = AbsPair(H+2);
H += 2;
HR[0] = MkIntTerm(chr);
HR[1] = AbsPair(HR+2);
HR += 2;
sz++;
if (sz == max) break;
}
@ -776,9 +776,9 @@ write_codes( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U
while (cp < lim) {
int chr;
cp = get_char(cp, &chr);
H[0] = MkIntTerm(chr);
H[1] = AbsPair(H+2);
H += 2;
HR[0] = MkIntTerm(chr);
HR[1] = AbsPair(HR+2);
HR += 2;
sz++;
if (sz == max) break;
}
@ -792,26 +792,26 @@ write_codes( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U
while (cp < lim) {
int chr;
cp = get_wchar(cp, &chr);
H[0] = MkIntTerm(chr);
H[1] = AbsPair(H+2);
H += 2;
HR[0] = MkIntTerm(chr);
HR[1] = AbsPair(HR+2);
HR += 2;
sz++;
if (sz == max) break;
}
}
}
while (sz < min) {
H[0] = MkIntTerm(MkIntTerm(0));
H[1] = AbsPair(H+2);
H += 2;
HR[0] = MkIntTerm(MkIntTerm(0));
HR[1] = AbsPair(HR+2);
HR += 2;
sz++;
}
if (out->type & YAP_STRING_DIFF) {
if (sz == 0) t = out->dif;
else H[-1] = Globalize(out->dif PASS_REGS);
else HR[-1] = Globalize(out->dif PASS_REGS);
} else {
if (sz == 0) t = TermNil;
else H[-1] = TermNil;
else HR[-1] = TermNil;
}
out->val.t = t;
return (t);
@ -821,10 +821,9 @@ write_codes( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U
static Atom
write_atom( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng USES_REGS)
{
size_t min = 0, max = leng;
size_t max = leng;
if (out->type & (YAP_STRING_NCHARS|YAP_STRING_TRUNC)) {
if (out->type & YAP_STRING_NCHARS) min = out->sz;
if (out->type & YAP_STRING_TRUNC && out->max < max) max = out->max;
if (out->type & YAP_STRING_TRUNC && out->max < max) max = out->max;
}
switch (enc) {
@ -1162,7 +1161,7 @@ concat( int n, seq_tv_t *out, void *sv[], encoding_t encv[], size_t lengv[] USES
if (out->type == YAP_STRING_STRING) {
/* we assume we concatenate strings only, or ASCII stuff like numbers */
Term t = init_tstring( PASS_REGS1 );
char *buf = buf_from_tstring(H);
char *buf = buf_from_tstring(HR);
int i;
for (i = 0; i < n; i++) {
if (encv[i] == YAP_WCHAR) {
@ -1182,7 +1181,7 @@ concat( int n, seq_tv_t *out, void *sv[], encoding_t encv[], size_t lengv[] USES
*buf ++ = '\0';
close_tstring( buf PASS_REGS );
out->val.t = t;
return H;
return HR;
} else {
encoding_t enc = YAP_CHAR;
size_t sz = 0;
@ -1196,7 +1195,7 @@ concat( int n, seq_tv_t *out, void *sv[], encoding_t encv[], size_t lengv[] USES
}
if (enc == YAP_WCHAR) {
/* wide atom */
wchar_t *buf = (wchar_t *)H;
wchar_t *buf = (wchar_t *)HR;
Atom at;
Term t = ARG1;
LOCAL_ERROR( sz+3 );
@ -1216,11 +1215,11 @@ concat( int n, seq_tv_t *out, void *sv[], encoding_t encv[], size_t lengv[] USES
}
}
*buf++ = '\0';
at = out->val.a = Yap_LookupWideAtom((wchar_t *)H);
at = out->val.a = Yap_LookupWideAtom((wchar_t *)HR);
return at;
} else {
/* atom */
char *buf = (char *)H;
char *buf = (char *)HR;
Atom at;
Term t = ARG1;
@ -1231,7 +1230,7 @@ concat( int n, seq_tv_t *out, void *sv[], encoding_t encv[], size_t lengv[] USES
while ( (chr = *ptr++) != '\0' ) *buf++ = chr;
}
*buf++ = '\0';
at = out->val.a = Yap_LookupAtom((char *)H);
at = out->val.a = Yap_LookupAtom((char *)HR);
return at;
}
}
@ -1244,7 +1243,7 @@ slice( size_t min, size_t max, void *buf, seq_tv_t *out, encoding_t enc USES_REG
if (out->type == YAP_STRING_STRING) {
/* we assume we concatenate strings only, or ASCII stuff like numbers */
Term t = init_tstring( PASS_REGS1 );
char *nbuf = buf_from_tstring(H);
char *nbuf = buf_from_tstring(HR);
if (enc == YAP_WCHAR) {
wchar_t *ptr = (wchar_t *)buf + min;
int chr;
@ -1268,7 +1267,7 @@ slice( size_t min, size_t max, void *buf, seq_tv_t *out, encoding_t enc USES_REG
/* atom */
if (enc == YAP_WCHAR) {
/* wide atom */
wchar_t *nbuf = (wchar_t *)H;
wchar_t *nbuf = (wchar_t *)HR;
Term t = TermNil;
wchar_t *ptr = (wchar_t *)buf + min;
if (max>min) {
@ -1279,7 +1278,7 @@ slice( size_t min, size_t max, void *buf, seq_tv_t *out, encoding_t enc USES_REG
at = Yap_LookupMaybeWideAtom( nbuf );
} else if (enc == YAP_CHAR) {
/* atom */
char *nbuf = (char *)H;
char *nbuf = (char *)HR;
if (max>min) {
Term t = TermNil;
@ -1291,7 +1290,7 @@ slice( size_t min, size_t max, void *buf, seq_tv_t *out, encoding_t enc USES_REG
at = Yap_LookupAtom( nbuf );
} else {
/* atom */
wchar_t *nbuf = (wchar_t *)H;
wchar_t *nbuf = (wchar_t *)HR;
Term t = ARG1;
const char *ptr = utf8_skip ( (const char *)buf, min );
int chr;
@ -1299,7 +1298,7 @@ slice( size_t min, size_t max, void *buf, seq_tv_t *out, encoding_t enc USES_REG
LOCAL_ERROR( max-min );
while ( min++ < max ) { ptr = utf8_get_char(ptr, & chr); *nbuf++ = chr; }
nbuf[0] = '\0';
at = Yap_LookupMaybeWideAtom( (wchar_t*)H );
at = Yap_LookupMaybeWideAtom( (wchar_t*)HR );
}
out->val.a = at;
return at->StrOfAE;

View File

@ -397,7 +397,7 @@ oc_unify_nvar_nvar:
/* d0 is bound and d1 is unbound */
Bind(pt1, d0);
/* local variables cannot be in a term */
if (pt1 > H && pt1 < LCL0)
if (pt1 > HR && pt1 < LCL0)
return TRUE;
if (rational_tree(d0))
return(FALSE);
@ -410,7 +410,7 @@ oc_unify_var_nvar:
/* pt0 is unbound and d1 is bound */
Bind(pt0, d1);
/* local variables cannot be in a term */
if (pt0 > H && pt0 < LCL0)
if (pt0 > HR && pt0 < LCL0)
return TRUE;
if (rational_tree(d1))
return(FALSE);
@ -587,7 +587,7 @@ InitReverseLookupOpcode(void)
}
}
}
bzero(OP_RTABLE, sz);
memset(OP_RTABLE, 0, sz);
opeptr = OP_RTABLE;
/* clear up table */
{

File diff suppressed because it is too large Load Diff

View File

@ -206,7 +206,7 @@ ensure_space(size_t sz) {
}
}
if (!s) {
s = (char *)H;
s = (char *)HR;
if (s+sz >= (char *)ASP) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,"not enough space to write bignum: it requires %d bytes", sz);
s = NULL;

View File

@ -231,7 +231,7 @@ extern REGSTORE Yap_REGS;
#define P Yap_REGS.P_ /* prolog machine program counter */
#define YENV Yap_REGS.YENV_ /* current environment (may differ from ENV) */
register CELL *H asm ("$9");
register CELL *HR asm ("$9");
register CELL *HB asm ("$10");
register choiceptr B asm ("$11");
register yamop *CP asm ("$12");
@ -247,7 +247,7 @@ register CELL CreepFlag asm ("$15");
/* Interface with foreign code, make sure the foreign code sees all the
registers the way they used to be */
INLINE_ONLY EXTERN inline void save_machine_regs(void) {
Yap_REGS.H_ = H;
Yap_REGS.H_ = HR;
Yap_REGS.HB_ = HB;
Yap_REGS.B_ = B;
Yap_REGS.CP_ = CP;
@ -258,7 +258,7 @@ INLINE_ONLY EXTERN inline void save_machine_regs(void) {
}
INLINE_ONLY EXTERN inline void restore_machine_regs(void) {
H = Yap_REGS.H_;
HR = Yap_REGS.H_;
HB = Yap_REGS.HB_;
B = Yap_REGS.B_;
CP = Yap_REGS.CP_;
@ -287,16 +287,16 @@ INLINE_ONLY EXTERN inline void restore_machine_regs(void) {
TR = BK_TR
INLINE_ONLY EXTERN inline void save_H(void) {
Yap_REGS.H_ = H;
Yap_REGS.H_ = HR;
}
INLINE_ONLY EXTERN inline void restore_H(void) {
H = Yap_REGS.H_;
HR = Yap_REGS.H_;
}
#define BACKUP_H() CELL *BK_H = H; restore_H()
#define BACKUP_H() CELL *BK_H = HR; restore_H()
#define RECOVER_H() save_H(); H = BK_H
#define RECOVER_H() save_H(); HR = BK_H
INLINE_ONLY EXTERN inline void save_B(void) {
Yap_REGS.B_ = B;
@ -325,7 +325,7 @@ INLINE_ONLY EXTERN inline void restore_TR(void) {
#define P Yap_REGS.P_ /* prolog machine program counter */
#define YENV Yap_REGS.YENV_ /* current environment (may differ from ENV) */
register CELL *H asm ("$16");
register CELL *HR asm ("$16");
register CELL *HB asm ("$17");
register choiceptr B asm ("$18");
register yamop *CP asm ("$19");
@ -334,7 +334,7 @@ register CELL CreepFlag asm ("$21");
register tr_fr_ptr TR asm ("$22");
INLINE_ONLY EXTERN inline void save_machine_regs(void) {
Yap_REGS.H_ = H;
Yap_REGS.H_ = HR;
Yap_REGS.HB_ = HB;
Yap_REGS.B_ = B;
Yap_REGS.CP_ = CP;
@ -343,7 +343,7 @@ INLINE_ONLY EXTERN inline void save_machine_regs(void) {
}
INLINE_ONLY EXTERN inline void restore_machine_regs(void) {
H = Yap_REGS.H_;
HR = Yap_REGS.H_;
HB = Yap_REGS.HB_;
B = Yap_REGS.B_;
CP = Yap_REGS.CP_;
@ -352,7 +352,7 @@ INLINE_ONLY EXTERN inline void restore_machine_regs(void) {
}
#define BACKUP_MACHINE_REGS() \
CELL *BK_H = H; \
CELL *BK_H = HR; \
CELL *BK_HB = HB; \
choiceptr BK_B = B; \
CELL BK_CreepFlag = CreepFlag; \
@ -362,7 +362,7 @@ INLINE_ONLY EXTERN inline void restore_machine_regs(void) {
#define RECOVER_MACHINE_REGS() \
save_machine_regs(); \
H = BK_H; \
HR = BK_H; \
HB = BK_HB; \
B = BK_B; \
CreepFlag = BK_CreepFlag; \
@ -370,16 +370,16 @@ INLINE_ONLY EXTERN inline void restore_machine_regs(void) {
TR = BK_TR
INLINE_ONLY EXTERN inline void save_H(void) {
Yap_REGS.H_ = H;
Yap_REGS.H_ = HR;
}
INLINE_ONLY EXTERN inline void restore_H(void) {
H = Yap_REGS.H_;
HR = Yap_REGS.H_;
}
#define BACKUP_H() CELL *BK_H = H; restore_H()
#define BACKUP_H() CELL *BK_H = HR; restore_H()
#define RECOVER_H() save_H(); H = BK_H
#define RECOVER_H() save_H(); HR = BK_H
INLINE_ONLY EXTERN inline void save_B(void) {
Yap_REGS.B_ = B;
@ -399,7 +399,7 @@ INLINE_ONLY EXTERN inline void restore_B(void) {
#define P Yap_REGS.P_ /* prolog machine program counter */
#define YENV Yap_REGS.YENV_ /* current environment (may differ from ENV) */
register CELL *H asm ("r12");
register CELL *HR asm ("r12");
register CELL *HB asm ("r13");
register choiceptr B asm ("r14");
register yamop *CP asm ("r15");
@ -408,7 +408,7 @@ register CELL CreepFlag asm ("r17");
register tr_fr_ptr TR asm ("r18");
INLINE_ONLY EXTERN inline void save_machine_regs(void) {
Yap_REGS.H_ = H;
Yap_REGS.H_ = HR;
Yap_REGS.HB_ = HB;
Yap_REGS.B_ = B;
Yap_REGS.CP_ = CP;
@ -417,7 +417,7 @@ INLINE_ONLY EXTERN inline void save_machine_regs(void) {
}
INLINE_ONLY EXTERN inline void restore_machine_regs(void) {
H = Yap_REGS.H_;
HR = Yap_REGS.H_;
HB = Yap_REGS.HB_;
B = Yap_REGS.B_;
CP = Yap_REGS.CP_;
@ -426,7 +426,7 @@ INLINE_ONLY EXTERN inline void restore_machine_regs(void) {
}
#define BACKUP_MACHINE_REGS() \
CELL *BK_H = H; \
CELL *BK_H = HR; \
CELL *BK_HB = HB; \
choiceptr BK_B = B; \
CELL BK_CreepFlag = CreepFlag; \
@ -436,7 +436,7 @@ INLINE_ONLY EXTERN inline void restore_machine_regs(void) {
#define RECOVER_MACHINE_REGS() \
save_machine_regs(); \
H = BK_H; \
HR = BK_H; \
HB = BK_HB; \
B = BK_B; \
CreepFlag = BK_CreepFlag; \
@ -444,16 +444,16 @@ INLINE_ONLY EXTERN inline void restore_machine_regs(void) {
TR = BK_TR
INLINE_ONLY EXTERN inline void save_H(void) {
Yap_REGS.H_ = H;
Yap_REGS.H_ = HR;
}
INLINE_ONLY EXTERN inline void restore_H(void) {
H = Yap_REGS.H_;
HR = Yap_REGS.H_;
}
#define BACKUP_H() CELL *BK_H = H; restore_H()
#define BACKUP_H() CELL *BK_H = HR; restore_H()
#define RECOVER_H() save_H(); H = BK_H
#define RECOVER_H() save_H(); HR = BK_H
INLINE_ONLY EXTERN inline void save_B(void) {
Yap_REGS.B_ = B;
@ -501,7 +501,7 @@ register tr_fr_ptr TR asm ("r13");
#else
register tr_fr_ptr TR asm ("r21");
#endif
register CELL *H asm ("r14");
register CELL *HR asm ("r14");
register CELL *HB asm ("r15");
register choiceptr B asm ("r16");
register yamop *CP asm ("r17");
@ -520,7 +520,7 @@ register CELL *YENV asm ("r19");
INLINE_ONLY EXTERN inline void save_machine_regs(void) {
Yap_REGS.H_ = H;
Yap_REGS.H_ = HR;
Yap_REGS.HB_ = HB;
Yap_REGS.B_ = B;
Yap_REGS.CP_ = CP;
@ -529,7 +529,7 @@ INLINE_ONLY EXTERN inline void save_machine_regs(void) {
}
INLINE_ONLY EXTERN inline void restore_machine_regs(void) {
H = Yap_REGS.H_;
HR = Yap_REGS.H_;
HB = Yap_REGS.HB_;
B = Yap_REGS.B_;
CP = Yap_REGS.CP_;
@ -538,7 +538,7 @@ INLINE_ONLY EXTERN inline void restore_machine_regs(void) {
}
#define BACKUP_MACHINE_REGS() \
CELL *BK_H = H; \
CELL *BK_H = HR; \
CELL *BK_HB = HB; \
choiceptr BK_B = B; \
yamop *BK_CP = CP; \
@ -547,23 +547,23 @@ INLINE_ONLY EXTERN inline void restore_machine_regs(void) {
#define RECOVER_MACHINE_REGS() \
save_machine_regs(); \
H = BK_H; \
HR = BK_H; \
HB = BK_HB; \
B = BK_B; \
CP = BK_CP; \
TR = BK_TR
INLINE_ONLY EXTERN inline void save_H(void) {
Yap_REGS.H_ = H;
Yap_REGS.H_ = HR;
}
INLINE_ONLY EXTERN inline void restore_H(void) {
H = Yap_REGS.H_;
HR = Yap_REGS.H_;
}
#define BACKUP_H() CELL *BK_H = H; restore_H()
#define BACKUP_H() CELL *BK_H = HR; restore_H()
#define RECOVER_H() save_H(); H = BK_H
#define RECOVER_H() save_H(); HR = BK_H
INLINE_ONLY EXTERN inline void save_B(void) {
Yap_REGS.B_ = B;
@ -594,7 +594,7 @@ INLINE_ONLY EXTERN inline void restore_TR(void) {
#define P Yap_REGS.P_ /* prolog machine program counter */
#define YENV Yap_REGS.YENV_ /* current environment (may differ from ENV) */
#define S Yap_REGS.S_ /* structure pointer */
#define H Yap_REGS.H_ /* top of heap (global) stack */
#define HR Yap_REGS.H_ /* top of heap (global) stack */
#define B Yap_REGS.B_ /* latest choice point */
#define TR Yap_REGS.TR_ /* top of trail */
#define HB Yap_REGS.HB_ /* heap (global) stack top at time of latest c.p. */

View File

@ -71,7 +71,7 @@ __IsAttVar (CELL *pt USES_REGS)
{
#ifdef YAP_H
return (pt)[-1] == (CELL)attvar_e
&& pt < H;
&& pt < HR;
#else
return (pt)[-1] == (CELL)attvar_e;
#endif
@ -181,7 +181,7 @@ special_functors;
INLINE_ONLY inline EXTERN Float CpFloatUnaligned(CELL *ptr);
#if SIZEOF_DOUBLE == SIZEOF_LONG_INT
#if SIZEOF_DOUBLE == SIZEOF_INT_P
#define MkFloatTerm(fl) __MkFloatTerm((fl) PASS_REGS)
@ -190,9 +190,9 @@ INLINE_ONLY inline EXTERN Term __MkFloatTerm (Float USES_REGS);
INLINE_ONLY inline EXTERN Term
__MkFloatTerm (Float dbl USES_REGS)
{
return (Term) ((H[0] = (CELL) FunctorDouble, *(Float *) (H + 1) =
dbl, H[2] = EndSpecials, H +=
3, AbsAppl (H - 3)));
return (Term) ((HR[0] = (CELL) FunctorDouble, *(Float *) (HR + 1) =
dbl, HR[2] = EndSpecials, HR +=
3, AbsAppl (HR - 3)));
}
@ -216,7 +216,7 @@ CpFloatUnaligned(CELL *ptr)
#else
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
#define DOUBLE_ALIGNED(ADDR) ((CELL)(ADDR) & 0x4)
@ -228,9 +228,9 @@ AlignGlobalForDouble( USES_REGS1 )
{
/* Force Alignment for floats. Note that garbage collector may
break the alignment; */
if (!DOUBLE_ALIGNED(H)) {
RESET_VARIABLE(H);
H++;
if (!DOUBLE_ALIGNED(HR)) {
RESET_VARIABLE(HR);
HR++;
}
}
@ -260,14 +260,16 @@ CpFloatUnaligned (CELL * ptr)
INLINE_ONLY inline EXTERN Term MkFloatTerm (Float);
#define MkFloatTerm(fl) __MkFloatTerm((fl) PASS_REGS)
INLINE_ONLY inline EXTERN Term
MkFloatTerm (Float dbl)
__MkFloatTerm (Float dbl USES_REGS)
{
CACHE_REGS
return (Term) ((AlignGlobalForDouble ( PASS_REGS1 ), H[0] =
(CELL) FunctorDouble, *(Float *) (H + 1) = dbl, H[3] =
EndSpecials, H +=
4, AbsAppl (H - 4)));
return (Term) ((AlignGlobalForDouble ( PASS_REGS1 ), HR[0] =
(CELL) FunctorDouble, *(Float *) (HR + 1) = dbl, HR[3] =
EndSpecials, HR +=
4, AbsAppl (HR - 4)));
}
@ -314,11 +316,11 @@ INLINE_ONLY inline EXTERN Term __MkLongIntTerm (Int USES_REGS);
INLINE_ONLY inline EXTERN Term
__MkLongIntTerm (Int i USES_REGS)
{
H[0] = (CELL) FunctorLongInt;
H[1] = (CELL) (i);
H[2] = EndSpecials;
H += 3;
return AbsAppl(H - 3);
HR[0] = (CELL) FunctorLongInt;
HR[1] = (CELL) (i);
HR[2] = EndSpecials;
HR += 3;
return AbsAppl(HR - 3);
}
@ -356,13 +358,13 @@ INLINE_ONLY inline EXTERN Term __MkStringTerm (const char *s USES_REGS);
INLINE_ONLY inline EXTERN Term
__MkStringTerm (const char *s USES_REGS)
{
Term t = AbsAppl(H);
Term t = AbsAppl(HR);
size_t sz = ALIGN_YAPTYPE(strlen(s)+1,CELL);
H[0] = (CELL) FunctorString;
H[1] = (CELL) sz;
strcpy((char *)(H+2), s);
H[2+sz] = EndSpecials;
H += 3+sz;
HR[0] = (CELL) FunctorString;
HR[1] = (CELL) sz;
strcpy((char *)(HR+2), s);
HR[2+sz] = EndSpecials;
HR += 3+sz;
return t;
}
@ -691,7 +693,7 @@ unify_extension (Functor f, CELL d0, CELL * pt0, CELL d1)
{
CELL *pt1 = RepAppl (d1);
return (pt0[1] == pt1[1]
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
&& pt0[2] == pt1[2]
#endif
);
@ -723,7 +725,7 @@ CELL Yap_Int_key(Term t)
static inline
CELL Yap_DoubleP_key(CELL *pt)
{
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
#if SIZEOF_DOUBLE1 == 2*SIZEOF_INT_P
CELL val = pt[0]^pt[1];
#else
CELL val = pt[0];

View File

@ -168,7 +168,7 @@ INLINE_ONLY inline EXTERN Term MkVarTerm__ ( USES_REGS1 );
INLINE_ONLY inline EXTERN Term
MkVarTerm__ ( USES_REGS1 )
{
return (Term) ((*H = 0, H++));
return (Term) ((*HR = 0, HR++));
}
@ -191,7 +191,7 @@ INLINE_ONLY inline EXTERN Term MkVarTerm__ ( USES_REGS1 );
INLINE_ONLY inline EXTERN Term
MkVarTerm__ ( USES_REGS1 )
{
return (Term) ((*H = (CELL) H, H++));
return (Term) ((*HR = (CELL) HR, HR++));
}
@ -319,11 +319,11 @@ INLINE_ONLY EXTERN inline Term MkPairTerm__(Term head, Term tail USES_REGS );
INLINE_ONLY EXTERN inline Term
MkPairTerm__ (Term head, Term tail USES_REGS)
{
register CELL *p = H;
register CELL *p = HR;
H[0] = head;
H[1] = tail;
H += 2;
HR[0] = head;
HR[1] = tail;
HR += 2;
return (AbsPair (p));
}

View File

@ -85,12 +85,12 @@ typedef enum internal_encoding {
} encoding_t;
// string construction
#ifdef H
#ifdef HR
static inline Term
init_tstring( USES_REGS1 ) {
Term t = AbsAppl(H);
Term t = AbsAppl(HR);
H[0] = (CELL)FunctorString;
HR[0] = (CELL)FunctorString;
return t;
}
@ -102,10 +102,10 @@ buf_from_tstring( CELL *p ) {
static inline void
close_tstring( char *p USES_REGS ) {
CELL *szp = H+1;
H = (CELL *)ALIGN_YAPTYPE( p ,CELL);
*szp = (H - szp)-1;
*H++ = EndSpecials;
CELL *szp = HR+1;
HR = (CELL *)ALIGN_YAPTYPE( p ,CELL);
*szp = (HR - szp)-1;
*HR++ = EndSpecials;
}
#endif

View File

@ -769,9 +769,9 @@ Macros to check the limits of stacks
COUNT_CPS(); \
S_YREG = (CELL *)((choiceptr)((S_YREG)-(I))-1); \
/* Save Information */ \
HBREG = H; \
HBREG = HR; \
B_YREG->cp_tr = TR; \
B_YREG->cp_h = H; \
B_YREG->cp_h = HR; \
B_YREG->cp_b = B; \
store_yaam_reg_cpdepth(B_YREG); \
B_YREG->cp_cp = CPREG; \
@ -783,9 +783,9 @@ Macros to check the limits of stacks
COUNT_CPS(); \
pt1 --; /* Jump to CP_BASE */ \
/* Save Information */ \
HBREG = H; \
HBREG = HR; \
pt1->cp_tr = TR; \
pt1->cp_h = H; \
pt1->cp_h = HR; \
pt1->cp_b = B; \
store_yaam_reg_cpdepth(pt1); \
pt1->cp_cp = d0; \
@ -850,7 +850,7 @@ Macros to check the limits of stacks
#define restore_yaam_regs(AP) \
{ register CELL *x1 = B_YREG->cp_env; \
register yamop *x2; \
H = HBREG = PROTECT_FROZEN_H(B_YREG); \
HR = HBREG = PROTECT_FROZEN_H(B_YREG); \
restore_yaam_reg_cpdepth(B_YREG); \
CPREG = B_YREG->cp_cp; \
/* AP may depend on H */ \
@ -914,7 +914,7 @@ Macros to check the limits of stacks
#define pop_yaam_regs() \
{ \
H = PROTECT_FROZEN_H(B_YREG); \
HR = PROTECT_FROZEN_H(B_YREG); \
B = B_YREG->cp_b; \
pop_yaam_reg_cpdepth(B_YREG); \
CPREG = B_YREG->cp_cp; \
@ -999,20 +999,20 @@ Macros to check the limits of stacks
}
#define UnifyGlobalCellToCell(b, a) \
if ((a) < H) { /* two globals */ \
if ((a) < HR) { /* two globals */ \
UnifyGlobalCells(a,b); \
} else { \
Bind_Local((a),(CELL)(b)); \
}
#define UnifyCells(a, b) \
if ((a) < H) { /* at least one global */ \
if ((b) > H) { Bind_Local((b),(CELL)(a)); } \
if ((a) < HR) { /* at least one global */ \
if ((b) > HR) { Bind_Local((b),(CELL)(a)); } \
else { UnifyGlobalCells(a,b); } \
} else { \
if ((b) > (a)) { Bind_Local((a),(CELL)(b)); } \
else if ((a) > (b)) { \
if ((b) < H) { Bind_Local((a),(CELL)(b)); } \
if ((b) < HR) { Bind_Local((a),(CELL)(b)); } \
else { Bind_Local((b),(CELL)(a)); } \
} \
}
@ -1597,12 +1597,12 @@ void SET_ASP__(CELL *yreg, Int sz USES_REGS) {
/* l1: bind a, l2 bind b, l3 no binding */
#define UnifyAndTrailCells(a, b) \
if((a) > (b)) { \
if ((a) < H) { *(a) = (CELL)(b); DO_TRAIL((a),(CELL)(b)); } \
else if ((b) <= H) { *(a) =(CELL)(b); DO_TRAIL((a),(CELL)(b));} \
if ((a) < HR) { *(a) = (CELL)(b); DO_TRAIL((a),(CELL)(b)); } \
else if ((b) <= HR) { *(a) =(CELL)(b); DO_TRAIL((a),(CELL)(b));} \
else { *(b) = (CELL)(a); DO_TRAIL((b),(CELL)(a)); } \
} else if((a) < (b)){ \
if ((b) <= H) { *(b) = (CELL)(a); DO_TRAIL((b),(CELL)(a)); } \
else if ((a) <= H) { *(b) = (CELL) (a); DO_TRAIL((b),(CELL)(a));} \
if ((b) <= HR) { *(b) = (CELL)(a); DO_TRAIL((b),(CELL)(a)); } \
else if ((a) <= HR) { *(b) = (CELL) (a); DO_TRAIL((b),(CELL)(a));} \
else { *(a) = (CELL) (b); DO_TRAIL((a),(CELL)(b));} \
}

View File

@ -253,7 +253,7 @@ extern void Yap_WakeUp(CELL *v);
#define Bind_Local(A,D) { TRAIL_LOCAL(A,D); *(A) = (D); }
#define Bind_Global(A,D) { *(A) = (D); if (__builtin_expect(GlobalIsAttVar(A),0)) Yap_WakeUp(A); else TRAIL_GLOBAL(A,D); }
#define Bind(A,D) { *(A) = (D); if (A < H) { if (__builtin_expect(GlobalIsAttVar(A),0)) Yap_WakeUp(A); else TRAIL_GLOBAL(A,D); } else { TRAIL_LOCAL(A,D); } }
#define Bind(A,D) { *(A) = (D); if (A < HR) { if (__builtin_expect(GlobalIsAttVar(A),0)) 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_NonAtt(A,D) { *(A) = (D); TRAIL_GLOBAL(A,D); }
#define Bind_and_Trail(A,D) { *(A) = (D); DO_TRAIL(A, D); }

View File

@ -77,7 +77,7 @@ mul_overflow(Int z, Int i1, Int i2)
#ifndef OPTIMIZE_MULTIPLI
#if __clang__ && FALSE /* not in OSX yet */
#define DO_MULTI() if (__builtin_smul_overflow( i1, i2, & z ) ) { goto overflow; }
#elif SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
#elif SIZEOF_DOUBLE == 2*SIZEOF_INT_P
#define DO_MULTI() {\
int64_t w = (int64_t)i1*i2; \
if (w >= 0) {\

View File

@ -45,7 +45,7 @@
#endif
/* is ptr a pointer to the heap? */
#define ONHEAP(ptr) (CellPtr(ptr) >= H0 && CellPtr(ptr) < H)
#define ONHEAP(ptr) (CellPtr(ptr) >= H0 && CellPtr(ptr) < HR)
/* is ptr a pointer to code space? */
#if USE_SYSTEM_MALLOC

View File

@ -573,6 +573,7 @@ extern void PL_cleanup_fork(void);
extern int PL_rethrow(void);
extern void PL_get_number(term_t l, number *n);
extern int PL_unify_atomic(term_t t, PL_atomic_t a);
extern int PL_unify_termv(term_t l, va_list args);
extern int _PL_unify_atomic(term_t t, PL_atomic_t a);
extern int _PL_unify_string(term_t t, word w);
@ -882,6 +883,32 @@ extern void unallocStream(IOSTREAM *s);
extern atom_t accessLevel(void);
int currentBreakLevel(void);
#ifdef __WINDOWS__
int hasConsole(void);
int PL_wait_for_console_input(void *handle);
void PlMessage(const char *fm, ...);
const char *WinError(void);
word pl_win_exec(term_t cmd, term_t how);
foreign_t pl_win_module_file(term_t module, term_t file);
#ifdef EMULATE_DLOPEN
/* file is in UTF-8, POSIX path */
void *dlopen(const char *file, int flags);
const char *dlerror(void);
void *dlsym(void *handle, char *symbol);
int dlclose(void *handle);
#endif
int ms_snprintf(char *buffer, size_t count, const char *fmt, ...);
void getDefaultsFromRegistry(void);
DWORD RunSilent(const char* strCommand);
FILE *pt_popen(const char *cmd, const char *mode);
int pt_pclose(FILE *fd);
int PL_w32thread_raise(DWORD id, int sig);
#endif
extern const PL_extension PL_predicates_from_ctype[];
extern const PL_extension PL_predicates_from_file[];
extern const PL_extension PL_predicates_from_files[];

View File

@ -309,14 +309,14 @@ OpenList(int n USES_REGS)
Term t;
BACKUP_H();
while (H+2*n > ASP-1024) {
while (HR+2*n > ASP-1024) {
if (!Yap_dogc( 0, NULL PASS_REGS )) {
RECOVER_H();
return FALSE;
}
}
t = AbsPair(H);
H += 2*n;
t = AbsPair(HR);
HR += 2*n;
RECOVER_H();
return t;

View File

@ -111,7 +111,7 @@ typedef enum {
#define CHECK(F) { size_t r = (F); if (!r) return r; }
#define RCHECK(F) if(!(F)) { QLYR_ERROR(MISMATCH); return; }
#define AllocTempSpace() (H)
#define EnoughTempSpace(sz) ((ASP-H)*sizeof(CELL) > sz)
#define AllocTempSpace() (HR)
#define EnoughTempSpace(sz) ((ASP-HR)*sizeof(CELL) > sz)

View File

@ -1116,7 +1116,7 @@ INLINE_ONLY inline EXTERN int IsGlobal__ (CELL CACHE_TYPE);
INLINE_ONLY inline EXTERN int
IsGlobal__ (CELL reg USES_REGS)
{
return (int) (IN_BETWEEN (LOCAL_GlobalBase, reg, H));
return (int) (IN_BETWEEN (LOCAL_GlobalBase, reg, HR));
}

View File

@ -27,7 +27,7 @@
/* skip, this is a problem because we lose information,
namely active references */
pt1 = (tr_fr_ptr)pt;
} else if (IN_BETWEEN(H0,pt,H) && IsAttVar(pt)) {
} else if (IN_BETWEEN(H0,pt,HR) && IsAttVar(pt)) {
CELL val = Deref(*pt);
if (IsVarTerm(val)) {
Bind(pt, MkAtomTerm(AtomCut));

View File

@ -107,7 +107,7 @@ A contains the address of the variable that is to be trailed
#define RESET_VARIABLE(V) (*(CELL *)(V) = 0)
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P
inline EXTERN void
AlignGlobalForDouble(void)
{
@ -118,7 +118,7 @@ AlignGlobalForDouble(void)
H++;
}
}
#endif /* SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT */
#endif /* SIZEOF_DOUBLE == 2*SIZEOF_INT_P */
#ifdef YAPOR

View File

@ -43,11 +43,11 @@
gcp = NORM_CP(YENV); \
SgFr_gen_cp(SG_FR) = gcp; \
/* store generator choice point */ \
HBREG = H; \
HBREG = HR; \
store_yaam_reg_cpdepth(gcp); \
gcp->cp_tr = TR; \
gcp->cp_ap = (yamop *)(AP); \
gcp->cp_h = H; \
gcp->cp_h = HR; \
gcp->cp_b = B; \
gcp->cp_env = ENV; \
gcp->cp_cp = CPREG; \
@ -55,7 +55,7 @@
/* go local */ \
register dep_fr_ptr new_dep_fr; \
/* adjust freeze registers */ \
H_FZ = H; \
H_FZ = HR; \
B_FZ = gcp; \
TR_FZ = TR; \
/* store dependency frame */ \
@ -85,12 +85,12 @@
gcp = NORM_CP(YENV); \
SgFr_gen_cp(SG_FR) = gcp; \
/* store deterministic generator choice point */ \
HBREG = H; \
HBREG = HR; \
store_yaam_reg_cpdepth(gcp); \
gcp->cp_ap = COMPLETION; \
gcp->cp_b = B; \
gcp->cp_tr = TR; \
gcp->cp_h = H; \
gcp->cp_h = HR; \
DET_GEN_CP(gcp)->cp_sg_fr = SG_FR; \
store_low_level_trace_info(DET_GEN_CP(gcp), TAB_ENT); \
set_cut((CELL *)gcp, B); \
@ -120,11 +120,11 @@
gccp = NORM_CP(YENV); \
SgFr_gen_cp(SG_FR) = gccp; \
/* store generator choice point */ \
HBREG = H; \
HBREG = HR; \
store_yaam_reg_cpdepth(gccp); \
gccp->cp_tr = TR; \
gccp->cp_ap = ANSWER_RESOLUTION_COMPLETION; \
gccp->cp_h = H; \
gccp->cp_h = HR; \
gccp->cp_b = B; \
gccp->cp_env = ENV; \
gccp->cp_cp = CPREG; \
@ -135,7 +135,7 @@
GEN_CP(gccp)->cp_dep_fr = LOCAL_top_dep_fr; \
GEN_CP(gccp)->cp_sg_fr = SG_FR; \
/* adjust freeze registers */ \
H_FZ = H; \
H_FZ = HR; \
B_FZ = gccp; \
TR_FZ = TR; \
store_low_level_trace_info(GEN_CP(gccp), TAB_ENT); \
@ -152,7 +152,7 @@
{ register CELL *pt_args, *x_args; \
register choiceptr gcp = B; \
/* restore generator choice point */ \
H = HBREG = PROTECT_FROZEN_H(gcp); \
HR = HBREG = PROTECT_FROZEN_H(gcp); \
restore_yaam_reg_cpdepth(gcp); \
CPREG = gcp->cp_cp; \
ENV = gcp->cp_env; \
@ -174,7 +174,7 @@
{ register CELL *pt_args, *x_args; \
register choiceptr gcp = B; \
/* pop generator choice point */ \
H = PROTECT_FROZEN_H(gcp); \
HR = PROTECT_FROZEN_H(gcp); \
pop_yaam_reg_cpdepth(gcp); \
CPREG = gcp->cp_cp; \
ENV = gcp->cp_env; \
@ -202,7 +202,7 @@
YENV = (CELL *) (CONS_CP(YENV) - 1); \
ccp = NORM_CP(YENV); \
/* adjust freeze registers */ \
H_FZ = H; \
H_FZ = HR; \
B_FZ = ccp; \
TR_FZ = TR; \
/* store dependency frame */ \
@ -210,11 +210,11 @@
LEADER_CP, ccp, SG_FR, FALSE, LOCAL_top_dep_fr); \
LOCAL_top_dep_fr = new_dep_fr; \
/* store consumer choice point */ \
HBREG = H; \
HBREG = HR; \
store_yaam_reg_cpdepth(ccp); \
ccp->cp_tr = TR; \
ccp->cp_ap = ANSWER_RESOLUTION; \
ccp->cp_h = H; \
ccp->cp_h = HR; \
ccp->cp_b = B; \
ccp->cp_env= ENV; \
ccp->cp_cp = CPREG; \
@ -232,7 +232,7 @@
#define consume_answer_and_procceed(DEP_FR, ANSWER) \
{ CELL *subs_ptr; \
/* restore consumer choice point */ \
H = HBREG = PROTECT_FROZEN_H(B); \
HR = HBREG = PROTECT_FROZEN_H(B); \
restore_yaam_reg_cpdepth(B); \
CPREG = B->cp_cp; \
ENV = B->cp_env; \
@ -257,7 +257,7 @@
#define consume_answer_and_procceed(DEP_FR, ANSWER) \
{ CELL *subs_ptr; \
/* restore consumer choice point */ \
H = HBREG = PROTECT_FROZEN_H(B); \
HR = HBREG = PROTECT_FROZEN_H(B); \
restore_yaam_reg_cpdepth(B); \
CPREG = B->cp_cp; \
ENV = B->cp_env; \
@ -287,11 +287,11 @@
/* initialize lcp */ \
lcp = NORM_CP(LOAD_CP(YENV) - 1); \
/* store loader choice point */ \
HBREG = H; \
HBREG = HR; \
store_yaam_reg_cpdepth(lcp); \
lcp->cp_tr = TR; \
lcp->cp_ap = LOAD_ANSWER; \
lcp->cp_h = H; \
lcp->cp_h = HR; \
lcp->cp_b = B; \
lcp->cp_env= ENV; \
lcp->cp_cp = CPREG; \
@ -306,7 +306,7 @@
#define restore_loader_node(ANSWER) \
H = HBREG = PROTECT_FROZEN_H(B); \
HR = HBREG = PROTECT_FROZEN_H(B); \
restore_yaam_reg_cpdepth(B); \
CPREG = B->cp_cp; \
ENV = B->cp_env; \
@ -315,7 +315,7 @@
#define pop_loader_node() \
H = PROTECT_FROZEN_H(B); \
HR = PROTECT_FROZEN_H(B); \
pop_yaam_reg_cpdepth(B); \
CPREG = B->cp_cp; \
TABLING_close_alt(B); \
@ -412,7 +412,7 @@
if(ans_node) {
CELL *subs_ptr = (CELL *) (GEN_CP(B) + 1) + SgFr_arity(sg_fr);
H = HBREG = PROTECT_FROZEN_H(B);
HR = HBREG = PROTECT_FROZEN_H(B);
restore_yaam_reg_cpdepth(B);
CPREG = B->cp_cp;
ENV = B->cp_env;
@ -529,7 +529,9 @@
} else if (SgFr_state(sg_fr) == evaluating) {
/* subgoal in evaluation */
choiceptr leader_cp;
#if YAPOR
int leader_dep_on_stack;
#endif
find_dependency_node(sg_fr, leader_cp, leader_dep_on_stack);
UNLOCK_SG_FR(sg_fr);
find_leader_node(leader_cp, leader_dep_on_stack);
@ -669,7 +671,9 @@
} else if (SgFr_state(sg_fr) == evaluating) {
/* subgoal in evaluation */
choiceptr leader_cp;
int leader_dep_on_stack;
#if YAPOR
int leader_dep_on_stack;
#endif
find_dependency_node(sg_fr, leader_cp, leader_dep_on_stack);
UNLOCK_SG_FR(sg_fr);
find_leader_node(leader_cp, leader_dep_on_stack);
@ -809,7 +813,9 @@
} else if (SgFr_state(sg_fr) == evaluating) {
/* subgoal in evaluation */
choiceptr leader_cp;
#if YAPOR
int leader_dep_on_stack;
#endif
find_dependency_node(sg_fr, leader_cp, leader_dep_on_stack);
UNLOCK_SG_FR(sg_fr);
find_leader_node(leader_cp, leader_dep_on_stack);

View File

@ -289,8 +289,7 @@ typedef enum {
DepFr_init_timestamp_field(DEP_FR)
#else
#define find_dependency_node(SG_FR, LEADER_CP, DEP_ON_STACK) \
LEADER_CP = SgFr_gen_cp(SG_FR); \
DEP_ON_STACK = TRUE
LEADER_CP = SgFr_gen_cp(SG_FR)
#define find_leader_node(LEADER_CP, DEP_ON_STACK) \
{ dep_fr_ptr chain_dep_fr = LOCAL_top_dep_fr; \
while (YOUNGER_CP(DepFr_cons_cp(chain_dep_fr), LEADER_CP)) { \
@ -1127,7 +1126,7 @@ static inline void __unbind_variables(tr_fr_ptr unbind_tr, tr_fr_ptr end_tr USES
static inline void __rebind_variables(tr_fr_ptr rebind_tr, tr_fr_ptr end_tr USES_REGS) {
TABLING_ERROR_CHECKING(rebind_variables, rebind_tr < end_tr);
/* rebind loop */
Yap_NEW_MAHASH((ma_h_inner_struct *)H PASS_REGS);
Yap_NEW_MAHASH((ma_h_inner_struct *)HR PASS_REGS);
while (rebind_tr != end_tr) {
CELL ref = (CELL) TrailTerm(--rebind_tr);
/* check for global or local variables */
@ -1162,7 +1161,7 @@ static inline void __restore_bindings(tr_fr_ptr unbind_tr, tr_fr_ptr rebind_tr U
TABLING_ERROR_CHECKING(restore_variables, unbind_tr < rebind_tr);
end_tr = rebind_tr;
Yap_NEW_MAHASH((ma_h_inner_struct *)H PASS_REGS);
Yap_NEW_MAHASH((ma_h_inner_struct *)HR PASS_REGS);
while (unbind_tr != end_tr) {
/* unbind loop */
while (unbind_tr > end_tr) {

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@
#ifdef MODE_GLOBAL_TRIE_ENTRY
#define INCREMENT_GLOBAL_TRIE_REFERENCE(ENTRY) \
{ register gt_node_ptr entry_node = (gt_node_ptr) (ENTRY); \
TrNode_child(entry_node) = (gt_node_ptr) ((unsigned long int) TrNode_child(entry_node) + 1); \
TrNode_child(entry_node) = (gt_node_ptr) ((UInt) TrNode_child(entry_node) + 1); \
}
#define NEW_SUBGOAL_TRIE_NODE(NODE, ENTRY, CHILD, PARENT, NEXT) \
INCREMENT_GLOBAL_TRIE_REFERENCE(ENTRY); \

View File

@ -88,10 +88,10 @@
{ register choiceptr cp; \
TOP_STACK = (CELL *) (NORM_CP(TOP_STACK) - 1); \
cp = NORM_CP(TOP_STACK); \
HBREG = H; \
HBREG = HR; \
store_yaam_reg_cpdepth(cp); \
cp->cp_tr = TR; \
cp->cp_h = H; \
cp->cp_h = HR; \
cp->cp_b = B; \
cp->cp_cp = CPREG; \
cp->cp_ap = (yamop *) AP; \
@ -104,7 +104,7 @@
copy_aux_stack()
#define restore_trie_node(AP) \
H = HBREG = PROTECT_FROZEN_H(B); \
HR = HBREG = PROTECT_FROZEN_H(B); \
restore_yaam_reg_cpdepth(B); \
CPREG = B->cp_cp; \
ENV = B->cp_env; \
@ -116,7 +116,7 @@
#define really_pop_trie_node() \
TOP_STACK = (CELL *) PROTECT_FROZEN_B((B + 1)); \
H = PROTECT_FROZEN_H(B); \
HR = PROTECT_FROZEN_H(B); \
pop_yaam_reg_cpdepth(B); \
CPREG = B->cp_cp; \
TABLING_close_alt(B); \
@ -182,16 +182,16 @@
#define aux_stack_term_in_pair_instr() \
if (heap_arity) { \
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(H)); \
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(HR)); \
} else { \
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(H)); \
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(HR)); \
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
TOP_STACK = &aux_stack[-1]; \
TOP_STACK[HEAP_ARITY_ENTRY] = 1; \
} \
Bind_Global(H, TrNode_entry(node)); \
TOP_STACK[HEAP_ENTRY(1)] = (CELL) (H + 1); \
H += 2; \
Bind_Global(HR, TrNode_entry(node)); \
TOP_STACK[HEAP_ENTRY(1)] = (CELL) (HR + 1); \
HR += 2; \
next_trie_instruction(node)
@ -202,33 +202,33 @@
#define aux_stack_new_pair_instr() /* for term 'CompactPairInit' */ \
if (heap_arity) { \
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(H)); \
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(HR)); \
TOP_STACK = &aux_stack[-1]; \
TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity + 1; \
} else { \
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(H)); \
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(HR)); \
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
TOP_STACK = &aux_stack[-2]; \
TOP_STACK[HEAP_ARITY_ENTRY] = 2; \
} \
TOP_STACK[HEAP_ENTRY(1)] = (CELL) H; \
TOP_STACK[HEAP_ENTRY(2)] = (CELL) (H + 1); \
H += 2; \
TOP_STACK[HEAP_ENTRY(1)] = (CELL) HR; \
TOP_STACK[HEAP_ENTRY(2)] = (CELL) (HR + 1); \
HR += 2; \
next_trie_instruction(node)
#ifdef TRIE_COMPACT_PAIRS
#define aux_stack_pair_instr() /* for term 'CompactPairEndList' */ \
if (heap_arity) { \
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(H)); \
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(HR)); \
} else { \
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(H)); \
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(HR)); \
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
TOP_STACK = &aux_stack[-1]; \
TOP_STACK[HEAP_ARITY_ENTRY] = 1; \
} \
TOP_STACK[HEAP_ENTRY(1)] = (CELL) H; \
Bind_Global(H + 1, TermNil); \
H += 2; \
TOP_STACK[HEAP_ENTRY(1)] = (CELL) HR; \
Bind_Global(HR + 1, TermNil); \
HR += 2; \
next_trie_instruction(node)
#else
#define aux_stack_pair_instr() \
@ -243,43 +243,43 @@
#define aux_stack_appl_instr() \
if (heap_arity) { \
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsAppl(H)); \
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsAppl(HR)); \
TOP_STACK = &aux_stack[-func_arity + 1]; \
TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity + func_arity - 1; \
} else { \
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsAppl(H)); \
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsAppl(HR)); \
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
TOP_STACK = &aux_stack[-func_arity]; \
TOP_STACK[HEAP_ARITY_ENTRY] = func_arity; \
} \
*H = (CELL) func; \
*HR = (CELL) func; \
{ int i; \
for (i = 1; i <= func_arity; i++) \
TOP_STACK[HEAP_ENTRY(i)] = (CELL) (H + i); \
TOP_STACK[HEAP_ENTRY(i)] = (CELL) (HR + i); \
} \
H += 1 + func_arity; \
HR += 1 + func_arity; \
next_trie_instruction(node)
#define aux_stack_appl_in_pair_instr() \
if (heap_arity) { \
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(H)); \
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(HR)); \
TOP_STACK = &aux_stack[-func_arity]; \
TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity + func_arity; \
} else { \
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(H)); \
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(HR)); \
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
TOP_STACK = &aux_stack[-func_arity - 1]; \
TOP_STACK[HEAP_ARITY_ENTRY] = func_arity + 1; \
} \
TOP_STACK[HEAP_ENTRY(func_arity + 1)] = (CELL) (H + 1); \
Bind_Global(H, AbsAppl(H + 2)); \
H += 2; \
*H = (CELL) func; \
TOP_STACK[HEAP_ENTRY(func_arity + 1)] = (CELL) (HR + 1); \
Bind_Global(HR, AbsAppl(HR + 2)); \
HR += 2; \
*HR = (CELL) func; \
{ int i; \
for (i = 1; i <= func_arity; i++) \
TOP_STACK[HEAP_ENTRY(i)] = (CELL) (H + i); \
TOP_STACK[HEAP_ENTRY(i)] = (CELL) (HR + i); \
} \
H += 1 + func_arity; \
HR += 1 + func_arity; \
next_trie_instruction(node)
@ -312,23 +312,23 @@
#define aux_stack_var_in_pair_instr() \
if (heap_arity) { \
int i; \
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(H)); \
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(HR)); \
TOP_STACK = &aux_stack[-1]; \
TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity; \
TOP_STACK[HEAP_ENTRY(1)] = (CELL) (H + 1); \
TOP_STACK[HEAP_ENTRY(1)] = (CELL) (HR + 1); \
for (i = 2; i <= heap_arity; i++) \
TOP_STACK[HEAP_ENTRY(i)] = aux_stack[HEAP_ENTRY(i)]; \
} else { \
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(H)); \
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(HR)); \
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
TOP_STACK = &aux_stack[-2]; \
TOP_STACK[HEAP_ARITY_ENTRY] = 1; \
TOP_STACK[HEAP_ENTRY(1)] = (CELL) (H + 1); \
TOP_STACK[HEAP_ENTRY(1)] = (CELL) (HR + 1); \
} \
aux_stack[VARS_ARITY_ENTRY - 1] = vars_arity + 1; \
aux_stack[VARS_ENTRY(vars_arity + 1)] = (CELL) H; \
RESET_VARIABLE((CELL) H); \
H += 2; \
aux_stack[VARS_ENTRY(vars_arity + 1)] = (CELL) HR; \
RESET_VARIABLE((CELL) HR); \
HR += 2; \
next_trie_instruction(node)
@ -358,19 +358,19 @@
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
aux_var = aux_stack[VARS_ENTRY(var_index + 1)]; \
if (aux_sub > aux_var) { \
if ((CELL *) aux_sub <= H) { \
if ((CELL *) aux_sub <= HR) { \
Bind_Global((CELL *) aux_sub, aux_var); \
} else if ((CELL *) aux_var <= H) { \
} else if ((CELL *) aux_var <= HR) { \
Bind_Local((CELL *) aux_sub, aux_var); \
} else { \
Bind_Local((CELL *) aux_var, aux_sub); \
aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
} \
} else { \
if ((CELL *) aux_var <= H) { \
if ((CELL *) aux_var <= HR) { \
Bind_Global((CELL *) aux_var, aux_sub); \
aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
} else if ((CELL *) aux_sub <= H) { \
} else if ((CELL *) aux_sub <= HR) { \
Bind_Local((CELL *) aux_var, aux_sub); \
aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
} else { \
@ -382,15 +382,15 @@
#define aux_stack_val_in_pair_instr() \
if (heap_arity) { \
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(H)); \
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(HR)); \
} else { \
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(H)); \
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(HR)); \
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
TOP_STACK = &aux_stack[-1]; \
TOP_STACK[HEAP_ARITY_ENTRY] = 1; \
} \
{ CELL aux_sub, aux_var; \
aux_sub = (CELL) H; \
aux_sub = (CELL) HR; \
aux_var = aux_stack[VARS_ENTRY(var_index + 1)]; \
if (aux_sub > aux_var) { \
Bind_Global((CELL *) aux_sub, aux_var); \
@ -400,8 +400,8 @@
aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
} \
} \
TOP_STACK[HEAP_ENTRY(1)] = (CELL) (H + 1); \
H += 2; \
TOP_STACK[HEAP_ENTRY(1)] = (CELL) (HR + 1); \
HR += 2; \
next_trie_instruction(node)

24
configure vendored
View File

@ -852,7 +852,6 @@ enable_use_malloc
enable_condor
enable_chr
enable_clpqr
enable_win64
enable_april
enable_dlcompat
enable_clpbn_bp
@ -1529,7 +1528,6 @@ Optional Features:
--enable-condor allow YAP to be used from condor
--enable-chr install chr library
--enable-clpqr install clpqr library
--enable-win64 compile YAP for win64
--enable-april compile Yap to support April ILP system
--enable-dlcompat use dlcompat library for dynamic loading on Mac OS X
--enable-clpbn-bp enable belief propagation solver in CLPBN.
@ -4247,13 +4245,6 @@ else
use_clpqr=yes
fi
# Check whether --enable-win64 was given.
if test "${enable_win64+set}" = set; then :
enableval=$enable_win64; target_win64="$enableval"
else
target_win64=no
fi
# Check whether --enable-april was given.
if test "${enable_april+set}" = set; then :
@ -5096,9 +5087,7 @@ then
EXTRA_INCLUDES_FOR_WIN32="-I\$(srcdir)/packages/PLStream/windows"
if test "$cygwin" = "no" -o "$target_os" = "mingw32"
then
if test "$target_win64" = yes
then
target_cpu=x86_64
if test "$target_cpu" = x86_64; then
YAP_TARGET=amd64
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lws2_32" >&5
@ -5219,8 +5208,7 @@ _ACEOF
fi
EXTRA_LIBS_FOR_DLLS="-lws2_32"
elif test "$target_os" = "cygwin"
then
elif test "$target_os" = "cygwin"; then
CC="${CC} -mno-cygwin"
CXX="${CXX} -mno-cygwin"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lcomdlg32" >&5
@ -11721,7 +11709,7 @@ else
JAVA_TEST=Test.java
CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST
/* #line 11724 "configure" */
/* #line 11712 "configure" */
public class Test {
}
EOF
@ -11897,7 +11885,7 @@ EOF
if uudecode$EXEEXT Test.uue; then
ac_cv_prog_uudecode_base64=yes
else
echo "configure: 11900: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
echo "configure: 11888: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
echo "configure: failed file was:" >&5
cat Test.uue >&5
ac_cv_prog_uudecode_base64=no
@ -12028,7 +12016,7 @@ else
JAVA_TEST=Test.java
CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST
/* #line 12031 "configure" */
/* #line 12019 "configure" */
public class Test {
}
EOF
@ -12063,7 +12051,7 @@ JAVA_TEST=Test.java
CLASS_TEST=Test.class
TEST=Test
cat << \EOF > $JAVA_TEST
/* [#]line 12066 "configure" */
/* [#]line 12054 "configure" */
public class Test {
public static void main (String args[]) {
System.exit (0);

View File

@ -140,9 +140,6 @@ AC_ARG_ENABLE(chr,
AC_ARG_ENABLE(clpqr,
[ --enable-clpqr install clpqr library ],
use_clpqr="$enableval", use_clpqr=yes)
AC_ARG_ENABLE(win64,
[ --enable-win64 compile YAP for win64 ],
target_win64="$enableval", target_win64=no)
AC_ARG_ENABLE(april,
[ --enable-april compile Yap to support April ILP system],
@ -523,17 +520,13 @@ then
EXTRA_INCLUDES_FOR_WIN32="-I\$(srcdir)/packages/PLStream/windows"
if test "$cygwin" = "no" -o "$target_os" = "mingw32"
then
if test "$target_win64" = yes
then
dnl configure messes up badly on this.
target_cpu=x86_64
if test "$target_cpu" = x86_64; then
YAP_TARGET=amd64
AC_CHECK_LIB(ws2_32,main)
AC_CHECK_LIB(comdlg32,main)
AC_CHECK_LIB(shell32,main)
EXTRA_LIBS_FOR_DLLS="-lws2_32"
elif test "$target_os" = "cygwin"
then
elif test "$target_os" = "cygwin"; then
CC="${CC} -mno-cygwin"
CXX="${CXX} -mno-cygwin"
AC_CHECK_LIB(comdlg32,main)

View File

@ -28,6 +28,10 @@
#include "SWI-Prolog.h"
#include <signal.h>
int APP_main(int argc, char **argv);
/* decode ANSI color sequences (ESC[...m) */
void PL_w32_wrap_ansi_console(void);
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This is the simple main program of swipl.exe; the SWI-Prolog console
application. It can be used as a basis for console-based applications

View File

@ -498,7 +498,7 @@ do_complete(RlcCompleteData data)
*******************************/
rlc_console
PL_current_console()
PL_current_console(void)
{ if ( Suser_input->functions->read == Srlc_read )
return Suser_input->handle;
@ -765,7 +765,7 @@ pl_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
static TCHAR *
HiddenFrameClass()
HiddenFrameClass(void)
{ static TCHAR winclassname[32];
static WNDCLASS wndClass;
HINSTANCE instance = rlc_hinstance();
@ -842,7 +842,7 @@ fatalSignal(int sig)
static void
initSignals()
initSignals(void)
{ signal(SIGABRT, fatalSignal);
signal(SIGFPE, fatalSignal);
signal(SIGILL, fatalSignal);

View File

@ -133,7 +133,7 @@ typedef enum
}
#define LOCAL_ERROR(v) \
if (H + (v) > ASP-1024) { \
if (HR + (v) > ASP-1024) { \
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;\
LOCAL_Error_Term = t;\
LOCAL_Error_Size = 2*(v)*sizeof(CELL);\
@ -141,7 +141,7 @@ typedef enum
}
#define LOCAL_TERM_ERROR(v) \
if (H + (v) > ASP-1024) { \
if (HR + (v) > ASP-1024) { \
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;\
LOCAL_Error_Term = t;\
LOCAL_Error_Size = 2*(v)*sizeof(CELL);\

View File

@ -724,7 +724,7 @@ X_API int PL_cons_functor(term_t d, functor_t f,...)
return TRUE;
}
arity = ArityOfFunctor(ff);
if (Unsigned(H)+arity > Unsigned(ASP)-CreepFlag) {
if (Unsigned(HR)+arity > Unsigned(ASP)-CreepFlag) {
if (!do_gc(arity*sizeof(CELL))) {
return FALSE;
}
@ -757,7 +757,7 @@ X_API int PL_cons_functor_v(term_t d, functor_t f, term_t a0)
return TRUE;
}
arity = ArityOfFunctor(ff);
if (Unsigned(H) > Unsigned(ASP)-CreepFlag) {
if (Unsigned(HR) > Unsigned(ASP)-CreepFlag) {
if (!do_gc(0)) {
return FALSE;
}
@ -780,7 +780,7 @@ X_API int PL_cons_functor_v(term_t d, functor_t f, term_t a0)
X_API int PL_cons_list(term_t d, term_t h, term_t t)
{
CACHE_REGS
if (Unsigned(H) > Unsigned(ASP)-CreepFlag) {
if (Unsigned(HR) > Unsigned(ASP)-CreepFlag) {
if (!do_gc(0)) {
return FALSE;
}
@ -839,7 +839,7 @@ X_API int PL_put_functor(term_t t, functor_t f)
Yap_PutInSlot(t,(Term)ff PASS_REGS);
} else {
arity = ArityOfFunctor(ff);
if (Unsigned(H)+arity > Unsigned(ASP)-CreepFlag) {
if (Unsigned(HR)+arity > Unsigned(ASP)-CreepFlag) {
if (!do_gc(arity*sizeof(CELL))) {
return FALSE;
}
@ -888,7 +888,7 @@ X_API int PL_put_list(term_t t)
{
CACHE_REGS
Yap_PutInSlot(t,YAP_MkNewPairTerm() PASS_REGS);
if (Unsigned(H) > Unsigned(ASP)-CreepFlag) {
if (Unsigned(HR) > Unsigned(ASP)-CreepFlag) {
if (!do_gc(0)) {
return FALSE;
}
@ -1060,7 +1060,7 @@ X_API int PL_unify_functor(term_t t, functor_t f)
Term tt = Yap_GetFromSlot(t PASS_REGS);
Functor ff = SWIFunctorToFunctor(f);
if (IsVarTerm(tt)) {
if (Unsigned(H)+ArityOfFunctor(ff) > Unsigned(ASP)-CreepFlag) {
if (Unsigned(HR)+ArityOfFunctor(ff) > Unsigned(ASP)-CreepFlag) {
if (!do_gc(0)) {
return FALSE;
}
@ -1112,7 +1112,7 @@ X_API int PL_unify_list(term_t tt, term_t h, term_t tail)
{
CACHE_REGS
Term t;
if (Unsigned(H) > Unsigned(ASP)-CreepFlag) {
if (Unsigned(HR) > Unsigned(ASP)-CreepFlag) {
if (!do_gc(0)) {
return FALSE;
}
@ -1336,7 +1336,7 @@ int PL_unify_termv(term_t l, va_list ap)
stack_el stack[MAX_DEPTH];
BACKUP_MACHINE_REGS();
if (Unsigned(H) > Unsigned(ASP)-CreepFlag) {
if (Unsigned(HR) > Unsigned(ASP)-CreepFlag) {
if (!do_gc(0)) {
RECOVER_MACHINE_REGS();
return FALSE;
@ -2086,7 +2086,7 @@ PL_open_foreign_frame(void)
/* initialise a new marker choicepoint */
choiceptr cp_b = ((choiceptr)(ASP-1))-1;
cp_b->cp_tr = TR;
cp_b->cp_h = H;
cp_b->cp_h = HR;
cp_b->cp_b = B;
cp_b->cp_cp = CP;
cp_b->cp_env = ENV;
@ -2095,7 +2095,7 @@ PL_open_foreign_frame(void)
cp_b->cp_depth = DEPTH;
#endif /* DEPTH_LIMIT */
cp_b->cp_a1 = MkIntTerm(LOCAL_CurSlot);
HB = H;
HB = HR;
B = cp_b;
ASP = (CELL *)B;
Yap_StartSlots( PASS_REGS1 );

View File

@ -235,7 +235,7 @@ AccessFile(const char *path, int mode)
return access(OsPath(path, tmp), m) == 0 ? TRUE : FALSE;
#else
#error "No implementation for AccessFile()"
# error "No implementation for AccessFile()"
#endif
}

View File

@ -384,7 +384,7 @@ locale_grouping_property(PL_locale *l, term_t prop ARG_LD)
typedef struct
{ functor_t functor; /* functor of property */
int (*function)(); /* function to generate */
int (*function)(); /* function to generate */
} lprop;
static const lprop lprop_list [] =
@ -482,7 +482,7 @@ PRED_IMPL("locale_property", 2, locale_property, PL_FA_NONDETERMINISTIC)
term_t locale = A1;
term_t property = A2;
lprop_enum statebuf;
lprop_enum *state;
lprop_enum *state = NULL;
switch( CTX_CNTRL )
{ case FRG_FIRST_CALL:

View File

@ -1051,7 +1051,7 @@ PRED_IMPL("win_registry_get_value", 3, win_registry_get_value, 0)
case REG_DWORD:
return PL_unify_integer(Value, *((DWORD *)data));
default:
warning("get_registry_value/2: Unknown registery-type: %d", type);
warning("get_registry_value/2: Unknown registry-type: %d", type);
fail;
}
}

View File

@ -39,46 +39,6 @@ free_read_data(ReadData _PL_rd)
{
}
static void
ptr_to_location(const unsigned char *here, source_location *pos, ReadData _PL_rd)
{ unsigned char const *s, *ll = NULL;
int c;
*pos = _PL_rd->start_of_term;
/* update line number */
for(s=rdbase; s<here; s = utf8_get_uchar(s, &c))
{ pos->position.charno++;
if ( c == '\n' )
{ pos->position.lineno++;
ll = s+1;
}
}
/* update line position */
if ( ll )
{ s = ll;
pos->position.linepos = 0;
} else
{ s = rdbase;
}
for(; s<here; s++)
{ switch(*s)
{ case '\b':
if ( pos->position.linepos > 0 )
pos->position.linepos--;
break;
case '\t':
pos->position.linepos |= 7; /* TBD: set tab distance */
default:
pos->position.linepos++;
}
}
pos->position.byteno = 0; /* we do not know */
}
static int
read_term(term_t t, ReadData _PL_rd ARG_LD)
{

View File

@ -146,7 +146,7 @@ extern IOENC initEncoding(void);
extern int reportStreamError(IOSTREAM *s);
extern record_t PL_record(term_t t);
extern int PL_thread_self(void);
extern void unallocStream(IOSTREAM *s);
/*******************************
* BUFFER *

View File

@ -14,7 +14,7 @@
typedef void *SYM_REC_PTR;
#define heap_top H
#define heap_top HR
#define local_top ASP
#define trail_top TR
#define trail_up_addr ((tr_fr_ptr)LCL0)
@ -168,7 +168,7 @@ INLINE_ONLY extern inline int is_IDENTICAL(TERM t1, TERM t2)
#define float_psc ((YAP_Functor)FunctorDouble)
#define NEW_HEAP_FREE (*H = (CELL)H); H++
#define NEW_HEAP_FREE (*HR = (CELL)HR); HR++
#define nil_sym YAP_TermNil()

View File

@ -794,7 +794,7 @@ int pc_import_occ_switches_3(void)
#ifdef __YAP_PROLOG__
if ( heap_top + 64*1024 >= local_top ) {
H = hstart;
HR = hstart;
/* running out of stack */
extern int Yap_gcl(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop);

View File

@ -221,7 +221,7 @@ static int rlc_from_queue(RlcQueue q);
static int rlc_is_empty_queue(RlcQueue q);
static void rlc_empty_queue(RlcQueue q);
extern int main();
extern int main(void);
static RlcUpdateHook _rlc_update_hook;
static RlcTimerHook _rlc_timer_hook;
@ -551,7 +551,7 @@ rlc_kill_wnd_proc(HWND hwnd, UINT message, UINT wParam, LONG lParam)
}
static TCHAR *
rlc_kill_window_class()
rlc_kill_window_class(void)
{ static TCHAR winclassname[32];
static WNDCLASS wndClass;
HINSTANCE instance = _rlc_hinstance;
@ -1383,7 +1383,7 @@ rlc_yield()
*******************************/
static void
rlc_init_word_chars()
rlc_init_word_chars(void)
{ int i;
for(i=0; i<CHAR_MAX; i++)
@ -1411,7 +1411,7 @@ rlc_is_word_char(int chr)
* SELECTION *
*******************************/
#define SelLT(l1, c1, l2, c2) ((l1) < (l2) || (l1) == (l2) && (c1) < (c2))
#define SelLT(l1, c1, l2, c2) ((l1) < (l2) || ((l1) == (l2) && (c1) < (c2)))
#define SelEQ(l1, c1, l2, c2) ((l1) == (l2) && (c1) == (c2))
static int
@ -1652,7 +1652,7 @@ rlc_read_from_window(RlcData b, int sl, int sc, int el, int ec)
TCHAR *buf;
int i = 0;
if ( el < sl || el == sl && ec < sc )
if ( el < sl || (el == sl && ec < sc) )
return NULL; /* invalid region */
if ( !(buf = rlc_malloc(bufsize * sizeof(TCHAR))) )
return NULL; /* not enough memory */