Merge branch 'master' of dmineserv2:Yap/yap-6.2

This commit is contained in:
ubu32 2011-01-21 06:07:30 -08:00
commit 03ed764580
7 changed files with 57 additions and 32 deletions

View File

@ -792,7 +792,6 @@ Yap_absmi(int inp)
noheapleft:
{
CELL cut_b = LCL0-(CELL *)(SREG[E_CB]);
#ifdef SHADOW_S
S = SREG;
#endif
@ -2535,6 +2534,7 @@ Yap_absmi(int inp)
PP = PREG->u.pp.p0;
if (ActiveSignals & YAP_CDOVF_SIGNAL) {
ASP = YREG+E_CB;
SREG = YENV;
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
ASP = (CELL *)PROTECT_FROZEN_B(B);
goto noheapleft;
@ -2690,6 +2690,7 @@ Yap_absmi(int inp)
SREG = (CELL *) PREG->u.Osbpp.p;
if (ActiveSignals & YAP_CDOVF_SIGNAL) {
ASP = (CELL *) (((char *) YREG) + PREG->u.Osbpp.s);
SREG = YENV;
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
ASP = (CELL *)PROTECT_FROZEN_B(B);
goto noheapleft;
@ -2926,6 +2927,7 @@ Yap_absmi(int inp)
ASP = (CELL *) (((char *) YREG) + PREG->u.Osbpp.s);
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
ASP = (CELL *)PROTECT_FROZEN_B(B);
SREG = YENV;
goto noheapleft;
}
if (ActiveSignals) {
@ -3049,6 +3051,7 @@ Yap_absmi(int inp)
ASP = YREG+E_CB;
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
ASP = (CELL *)PROTECT_FROZEN_B(B);
SREG = YENV;
goto noheapleft;
}
if (ActiveSignals)
@ -14558,6 +14561,7 @@ Yap_absmi(int inp)
if (ActiveSignals) {
if (ActiveSignals & YAP_CDOVF_SIGNAL) {
UNLOCK(SignalLock);
SREG = YENV;
goto noheapleft;
}
UNLOCK(SignalLock);

View File

@ -1596,14 +1596,28 @@ Yap_ExtendWorkSpaceThroughHole(UInt s)
return -1;
}
#endif
}
WorkSpaceTop = WorkSpaceTop0;
#endif
if (ExtendWorkSpace(s, 0)) {
#elif SIZEOF_INT_P==8
{
int n = 1024*1024;
while (n) {
/* progress 1 MB */
WorkSpaceTop += 512*1024;
if (ExtendWorkSpace(s, MAP_FIXED)) {
Yap_add_memory_hole((ADDR)WorkSpaceTop0, (ADDR)WorkSpaceTop-s);
Yap_ErrorMessage = NULL;
return WorkSpaceTop-WorkSpaceTop0;
}
#if defined(_WIN32)
/* 487 happens when you step over someone else's memory */
if (GetLastError() != 487) {
WorkSpaceTop = WorkSpaceTop0;
return -1;
}
#endif
}
#endif
}
WorkSpaceTop = WorkSpaceTop0;
#endif
return -1;
}

View File

@ -2430,18 +2430,15 @@ count_consts(GroupDef *grp)
static UInt
count_blobs(GroupDef *grp)
{
Term current = MkAtomTerm(AtomFoundVar);
UInt i = 0;
ClauseDef *cl = grp->FirstClause;
UInt i = 1;
ClauseDef *cl = grp->FirstClause+1;
Term current = grp->FirstClause->Tag;
while (TRUE) {
while (cl <= grp->LastClause) {
if (current != cl->Tag) {
i++;
current = cl->Tag;
}
if (cl == grp->LastClause) {
return i;
}
cl++;
}
return i;
@ -3224,7 +3221,7 @@ do_dbref_index(ClauseDef *min, ClauseDef* max, Term t, struct intermediates *cin
Yap_emit(label_op, labl, Zero, cint);
Yap_emit(index_dbref_op, Zero, Zero, cint);
sort_group(group,(CELL *)(group+1),cint);
do_blobs(group, t, cint, argno, first, fail_l, clleft, (CELL *)group+1);
do_blobs(group, t, cint, argno, first, fail_l, clleft, (CELL *)(group+1));
return labl;
}
}
@ -3261,7 +3258,7 @@ do_blob_index(ClauseDef *min, ClauseDef* max, Term t, struct intermediates *cint
else
Yap_emit(index_long_op, Zero, Zero, cint);
sort_group(group,(CELL *)(group+1),cint);
do_blobs(group, t, cint, argno, first, fail_l, clleft, (CELL *)group+1);
do_blobs(group, t, cint, argno, first, fail_l, clleft, (CELL *)(group+1));
return labl;
}
}

View File

@ -717,6 +717,9 @@ Yap_scan_num(int (*Nxtch) (int))
return TermNil;
}
ch = Nxtch(-1);
while (chtype(ch) == BS) {
ch = Nxtch(-1);
}
if (ch == '-') {
sign = -1;
ch = Nxtch(-1);

View File

@ -49,13 +49,6 @@ format_to_chars(Form, Args, OUT, L0) :-
write_to_chars(Term, OUT) :-
write_to_chars(Term, [], OUT).
write_to_chars(Term, L0, OUT) :-
open_mem_write_stream(Stream),
write(Stream, Term),
peek_mem_write_stream(Stream, L0, O),
close(Stream),
O = OUT.
atom_to_chars(Atom, OUT) :-
atom_to_chars(Atom, [], OUT).
@ -88,12 +81,6 @@ number_to_chars(Number, L0, OUT) :-
number_to_chars(Number, L0, OUT) :-
throw(error(type_error(number,Number),number_to_chars(Number, L0, OUT))).
read_from_chars(Chars, Term) :-
open_mem_read_stream(Chars, Stream),
read(Stream, T),
close(Stream),
T = Term.
open_chars_stream(Chars, Stream) :-
open_mem_read_stream(Chars, Stream).

View File

@ -1924,15 +1924,16 @@ typedef struct {
X_API int PL_unify_term(term_t l,...)
{
va_list ap;
int type;
int type, res;
int nels = 1;
int depth = 1;
Term a[1], *pt;
stack_el stack[MAX_DEPTH];
BACKUP_MACHINE_REGS();
if (Unsigned(H) > Unsigned(ASP)-CreepFlag) {
if (!Yap_gc(0, ENV, CP)) {
RECOVER_MACHINE_REGS();
return FALSE;
}
}
@ -2137,7 +2138,9 @@ X_API int PL_unify_term(term_t l,...)
}
}
va_end (ap);
return YAP_Unify(Yap_GetFromSlot(l),a[0]);
res = Yap_unify(Yap_GetFromSlot(l),a[0]);
RECOVER_MACHINE_REGS();
return res;
}
/* end PL_unify_* functions =============================*/

View File

@ -684,6 +684,23 @@ term_to_atom(Term,Atom) :-
charsio:write_to_chars(Term,S),
atom_codes(Atom,S).
%
% hack this here.
%
charsio:write_to_chars(Term, L0, OUT) :-
charsio:open_mem_write_stream(Stream),
prolog:write(Stream, Term),
charsio:peek_mem_write_stream(Stream, L0, O),
prolog:close(Stream),
O = OUT.
charsio:read_from_chars(Chars, Term) :-
charsio:open_mem_read_stream(Chars, Stream),
prolog:read(Stream, T),
prolog:close(Stream),
T = Term.
simple(V) :- var(V), !.
simple(A) :- atom(A), !.
simple(N) :- number(N).