handle stack overflow within =..

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@466 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2002-05-07 21:19:52 +00:00
parent 97f7414cd2
commit d2a6f16e4a
3 changed files with 21 additions and 6 deletions

View File

@ -21,6 +21,7 @@ static char SccsId[] = "%W% %G%";
#include "absmi.h" #include "absmi.h"
#include "yapio.h" #include "yapio.h"
#define EARLY_RESET 1 #define EARLY_RESET 1
#if !defined(TABLING) #if !defined(TABLING)
#define EASY_SHUNTING 1 #define EASY_SHUNTING 1

View File

@ -1152,12 +1152,20 @@ p_univ(void)
} }
return (unify_constant(ARG1, MkAtomTerm(at))); return (unify_constant(ARG1, MkAtomTerm(at)));
} }
build_compound:
/* build the term directly on the heap */ /* build the term directly on the heap */
Ar = H; Ar = H;
H++; H++;
while (!IsVarTerm(twork) && IsPairTerm(twork)) { while (!IsVarTerm(twork) && IsPairTerm(twork)) {
*H++ = HeadOfTerm(twork); *H++ = HeadOfTerm(twork);
if (H > ASP - 1024) {
/* restore space */
H = Ar;
gc(2, ENV, P);
twork = TailOfTerm(Deref(ARG2));
goto build_compound;
}
twork = TailOfTerm(twork); twork = TailOfTerm(twork);
} }
if (IsVarTerm(twork)) { if (IsVarTerm(twork)) {
@ -1217,7 +1225,13 @@ p_univ(void)
twork = ArrayToList(CellPtr(TR), argno - 1); twork = ArrayToList(CellPtr(TR), argno - 1);
} else } else
#endif #endif
twork = ArrayToList(RepAppl(tin) + 1, arity); {
if (H+arity*2 > ASP-1024) {
gc(2, ENV, P);
tin = Deref(ARG1);
}
twork = ArrayToList(RepAppl(tin) + 1, arity);
}
} else { } else {
/* We found a list */ /* We found a list */
at = AtomDot; at = AtomDot;
@ -2133,7 +2147,7 @@ InitCPreds(void)
InitCPred("number_atom", 2, p_number_atom, SafePredFlag); InitCPred("number_atom", 2, p_number_atom, SafePredFlag);
InitCPred("number_codes", 2, p_number_codes, SafePredFlag); InitCPred("number_codes", 2, p_number_codes, SafePredFlag);
InitCPred("atom_concat", 2, p_atom_concat, SafePredFlag); InitCPred("atom_concat", 2, p_atom_concat, SafePredFlag);
InitCPred("=..", 2, p_univ, SafePredFlag); InitCPred("=..", 2, p_univ, 0);
InitCPred("$statistics_trail_max", 1, p_statistics_trail_max, SafePredFlag|SyncPredFlag); InitCPred("$statistics_trail_max", 1, p_statistics_trail_max, SafePredFlag|SyncPredFlag);
InitCPred("$statistics_heap_max", 1, p_statistics_heap_max, SafePredFlag|SyncPredFlag); InitCPred("$statistics_heap_max", 1, p_statistics_heap_max, SafePredFlag|SyncPredFlag);
InitCPred("$statistics_global_max", 1, p_statistics_global_max, SafePredFlag|SyncPredFlag); InitCPred("$statistics_global_max", 1, p_statistics_global_max, SafePredFlag|SyncPredFlag);

View File

@ -861,10 +861,10 @@ debugging :-
'$action'(60,_,_,_,_,_) :- !, % <Depth '$action'(60,_,_,_,_,_) :- !, % <Depth
'$new_deb_depth', '$new_deb_depth',
fail. fail.
'$action'(94,_,_,G,M,_) :- !, '$action'(94,_,_,G,_) :- !,
'$print_deb_sterm'(G,M), fail. '$print_deb_sterm'(G), fail.
'$action'(0'a,_,_,_,_,_) :- !, abort. % a abort '$action'(0'a,_,_,_,_,_) :- !, abort. % a abort
'$action'(0'd,_,_,_,_,_) :- !, break, % b break '$action'(0'b,_,_,_,_,_) :- !, break, % b break
fail. fail.
'$action'(0'c,call,_,_,_,_) :- !, % c creep '$action'(0'c,call,_,_,_,_) :- !, % c creep
'$set_yap_flags'(10,1). '$set_yap_flags'(10,1).
@ -946,7 +946,7 @@ debugging :-
'$get_sterm_list'(L), !, '$get_sterm_list'(L), !,
'$deb_get_sterm_in_g'(L,G,A), '$deb_get_sterm_in_g'(L,G,A),
recorda('$debug_sub_skel',L,_), recorda('$debug_sub_skel',L,_),
nl(user_error), write(user_error,A), nl(user_error), nl(user_error). '$format'(user_error,"~n~w~n~n",[A]).
'$print_deb_sterm'(_) :- '$skipeol'(94). '$print_deb_sterm'(_) :- '$skipeol'(94).
'$get_sterm_list'(L) :- '$get_sterm_list'(L) :-