Merge ../yap-6.2

This commit is contained in:
Vitor Santos Costa 2011-01-21 08:16:41 -06:00
commit 67ec597966
10 changed files with 64 additions and 41 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

@ -1595,15 +1595,29 @@ Yap_ExtendWorkSpaceThroughHole(UInt s)
WorkSpaceTop = WorkSpaceTop0;
return -1;
}
#endif
#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
if (ExtendWorkSpace(s, 0)) {
Yap_add_memory_hole((ADDR)WorkSpaceTop0, (ADDR)WorkSpaceTop-s);
Yap_ErrorMessage = NULL;
return WorkSpaceTop-WorkSpaceTop0;
}
#endif
return -1;
}

View File

@ -3174,7 +3174,6 @@ YAP_Record(Term t)
dbt->prev_rec = NULL;
dbt->dbrecord = dbterm;
Yap_Records = dbt;
fprintf(stderr,"adding %p\n", dbt);
return dbt;
}
@ -3182,7 +3181,6 @@ X_API Term
YAP_Recorded(void *handle)
{
Term t;
fprintf(stderr,"reading %p\n", handle);
DBTerm *dbterm = ((DBRecordList *)handle)->dbrecord;
BACKUP_MACHINE_REGS();
@ -3215,7 +3213,6 @@ YAP_Recorded(void *handle)
X_API int
YAP_Erase(void *handle)
{
fprintf(stderr,"erasing %p\n", handle);
DBRecordList *dbr = (DBRecordList *)handle;
Yap_ReleaseTermFromDB(dbr->dbrecord);
if (dbr->next_rec)

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

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% $Date: 2010-12-15 11:12:48 +0100 (Wed, 15 Dec 2010) $
% $Revision: 5138 $
% $Date: 2011-01-16 19:24:10 +0100 (Sun, 16 Jan 2011) $
% $Revision: 5260 $
%
% This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog
@ -521,6 +521,7 @@ init_global_params :-
problog_define_flag(bdd_result, problog_flag_validate_file, 'file to store result calculated from BDD', example_bdd_res, bdd, flags:working_file_handler),
problog_define_flag(bdd_file, problog_flag_validate_file, 'file for BDD script', example_bdd, bdd, flags:bdd_file_handler),
problog_define_flag(static_order_file, problog_flag_validate_file, 'file for BDD static order', example_bdd_order, bdd, flags:working_file_handler),
problog_define_flag(map_file, problog_flag_validate_file, 'the file to output the variable map', map_file, output, flags:working_file_handler),
%%%%%%%%%%%%
% montecarlo: recalculate current approximation after N samples
% montecarlo: write log to this file
@ -2458,6 +2459,7 @@ montecarlo(Goal,Delta,K,File) :-
format(Log,'# goal: ~q~n#delta: ~w~n',[Goal,Delta]),
format(Log,'# num_programs prob low high diff time~2n',[]),
close(Log),
timer_reset(monte_carlo),
timer_start(monte_carlo),
format_if_verbose(user,'search for ~q~n',[Goal]),
montecarlo(Goal,Delta,K,0,File,0),

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% $Date: 2010-12-20 12:35:25 +0100 (Mon, 20 Dec 2010) $
% $Revision: 5161 $
% $Date: 2011-01-16 19:24:10 +0100 (Sun, 16 Jan 2011) $
% $Revision: 5260 $
%
% This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog
@ -283,8 +283,7 @@
problog_define_flag(use_old_trie, problog_flag_validate_boolean, 'use the old trie 2 trie transformation no nested', true),
problog_define_flag(use_dec_trie, problog_flag_validate_boolean, 'use the decomposition method', false),
problog_define_flag(deref_terms, problog_flag_validate_boolean, 'deref BDD terms after last use', false),
problog_define_flag(export_map_file, problog_flag_validate_boolean, 'activates export of a variable map file', false, output),
problog_define_flag(map_file, problog_flag_validate_file, 'the file to output the variable map', map_file, output)
problog_define_flag(export_map_file, problog_flag_validate_boolean, 'activates export of a variable map file', false, output)
)).

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).