diff --git a/C/amasm.c b/C/amasm.c index 6e88e177f..24929a225 100644 --- a/C/amasm.c +++ b/C/amasm.c @@ -11,8 +11,11 @@ * File: amasm.c * * comments: abstract machine assembler * * * -* Last rev: $Date: 2004-12-07 16:54:57 $ * +* Last rev: $Date: 2004-12-20 21:44:56 $ * * $Log: not supported by cvs2svn $ +* Revision 1.68 2004/12/07 16:54:57 vsc +* fix memory overflow +* * Revision 1.67 2004/12/05 05:01:23 vsc * try to reduce overheads when running with goal expansion enabled. * CLPBN fixes @@ -3029,8 +3032,9 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates DBTerm *x; LogUpdClause *cl; - if(!(x = fetch_clause_space(&t,size,cip))) + if(!(x = fetch_clause_space(&t,size,cip))){ return NULL; + } cl = (LogUpdClause *)((CODEADDR)x-(UInt)size); cl->ClSource = x; cip->code_addr = (yamop *)cl; @@ -3040,8 +3044,9 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates !is_fact) { DBTerm *x; StaticClause *cl; - if(!(x = fetch_clause_space(&t,size,cip))) + if(!(x = fetch_clause_space(&t,size,cip))) { return NULL; + } cl = (StaticClause *)((CODEADDR)x-(UInt)size); cip->code_addr = (yamop *)cl; code_p = do_pass(1, &entry_code, mode, &clause_has_blobs, cip, size); @@ -3054,6 +3059,7 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates if (!Yap_growheap(TRUE, size, cip)) { Yap_Error_TYPE = OUT_OF_HEAP_ERROR; + Yap_Error_Size = size; return NULL; } } diff --git a/C/cdmgr.c b/C/cdmgr.c index 17c391b08..e1cb2cebe 100644 --- a/C/cdmgr.c +++ b/C/cdmgr.c @@ -11,8 +11,11 @@ * File: cdmgr.c * * comments: Code manager * * * -* Last rev: $Date: 2004-12-16 05:57:23 $,$Author: vsc $ * +* Last rev: $Date: 2004-12-20 21:44:57 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.145 2004/12/16 05:57:23 vsc +* fix overflows +* * Revision 1.144 2004/12/08 00:10:48 vsc * more grow fixes * @@ -2033,10 +2036,13 @@ p_compile_dynamic(void) addclause(t, code_adr, (int) (IntOfTerm(t1) & 3), mod, &ARG5); } if (Yap_ErrorMessage) { + if (!Yap_Error_Term) + Yap_Error_Term = TermNil; if (IntOfTerm(t1) & 4) { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, "line %d, %s", Yap_FirstLineInParse(), Yap_ErrorMessage); - } else + } else { Yap_Error(Yap_Error_TYPE, Yap_Error_Term, Yap_ErrorMessage); + } YAPLeaveCriticalSection(); return FALSE; } diff --git a/C/compiler.c b/C/compiler.c index 390e465a0..21a244a7e 100644 --- a/C/compiler.c +++ b/C/compiler.c @@ -11,8 +11,11 @@ * File: compiler.c * * comments: Clause compiler * * * -* Last rev: $Date: 2004-12-16 05:57:32 $,$Author: vsc $ * +* Last rev: $Date: 2004-12-20 21:44:57 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.56 2004/12/16 05:57:32 vsc +* fix overflows +* * Revision 1.55 2004/12/05 05:01:23 vsc * try to reduce overheads when running with goal expansion enabled. * CLPBN fixes @@ -2949,16 +2952,7 @@ Yap_cclause(volatile Term inp_clause, int NOfArgs, int mod, volatile Term src) /* check first if there was space for us */ if (acode == NULL) { - /* make sure we have enough space */ - if (!Yap_growheap(FALSE, Yap_Error_Size, NULL)) { - save_machine_regs(); - my_clause = Deref(ARG1); - longjmp(cglobs.cint.CompilerBotch, 2); - return(NULL); - } else { - my_clause = Deref(ARG1); - goto restart_compilation; - } + return NULL; } else { #ifdef LOW_PROF if (ProfilerOn) { diff --git a/CLPBN/clpbn.yap b/CLPBN/clpbn.yap index dac87c070..5f29d69d9 100644 --- a/CLPBN/clpbn.yap +++ b/CLPBN/clpbn.yap @@ -48,8 +48,8 @@ solver(vel). %output(xbif(user_error)). -output(gviz(user_error)). -%output(no). +%output(gviz(user_error)). +output(no). clpbn_flag(Flag,Option) :- clpbn_flag(Flag, Option, Option). diff --git a/CLPBN/clpbn/vel.yap b/CLPBN/clpbn/vel.yap index b604f7218..69f5ac585 100644 --- a/CLPBN/clpbn/vel.yap +++ b/CLPBN/clpbn/vel.yap @@ -53,10 +53,10 @@ vel(LVs,Vs0,AllDiffs) :- find_all_clpbn_vars([], [], [], []) :- !. find_all_clpbn_vars([V|Vs], [Var|LV], ProcessedVars, [table(I,Table,Deps,Sizes)|Tables]) :- var_with_deps(V, Table, Deps, Sizes, Ev, Vals), !, - Var = var(V,I,Sz,Vals,Ev,_,_), - get_dist_size(V,Sz), % variables with evidence should not be processed. (var(Ev) -> + Var = var(V,I,Sz,Vals,Ev,_,_), + get_dist_size(V,Sz), ProcessedVars = [Var|ProcessedVars0] ; ProcessedVars = ProcessedVars0 @@ -132,6 +132,7 @@ add_table_deps_to_variables([], []). add_table_deps_to_variables([var(V,_,_,_,_,Deps,K)|LV], DepGraph) :- steal_deps_for_variable(DepGraph, V, NDepGraph, Deps), compute_size(Deps,[],K), +% ( clpbn:get_atts(V,[key(Key)]) -> write(Key:K), nl ; true), add_table_deps_to_variables(LV, NDepGraph). steal_deps_for_variable([V-Info|DepGraph], V0, NDepGraph, [Info|Deps]) :- @@ -141,8 +142,8 @@ steal_deps_for_variable(DepGraph, _, DepGraph, []). compute_size([],Vs,K) :- % use sizes now - length(Vs,K). -% multiply_sizes(Vs,1,K). +% length(Vs,K). + multiply_sizes(Vs,1,K). compute_size([tab(_,Vs,_)|Tabs],Vs0,K) :- ord_union(Vs,Vs0,VsI), compute_size(Tabs,VsI,K). @@ -154,7 +155,7 @@ multiply_sizes([V|Vs],K0,K) :- multiply_sizes(Vs,KI,K). process(LV0, InputVs, Out) :- - find_best(LV0, V0, 10000, V, WorkTables, LVI, InputVs), + find_best(LV0, V0, -1, V, WorkTables, LVI, InputVs), V \== V0, !, multiply_tables(WorkTables, Table), propagate_evidence(V, Evs), @@ -165,9 +166,11 @@ process(LV0, _, Out) :- fetch_tables(LV0, WorkTables), multiply_tables(WorkTables, Out). -find_best([], V, _, V, _, [], _). +find_best([], V, _TF, V, _, [], _). +%:- +% clpbn:get_atts(V,[key(K)]), write(chosen:K:TF), nl. find_best([var(V,I,Sz,Vals,Ev,Deps,K)|LV], _, Threshold, VF, NWorktables, LVF, Inputs) :- - K < Threshold, + ( K < Threshold ; Threshold < 0), clpbn_not_var_member(Inputs, V), !, find_best(LV, V, K, VF, WorkTables,LV0, Inputs), (V == VF -> @@ -310,19 +313,17 @@ include([var(V,P,VSz,D,Ev,Tabs,Est)|LV],tab(T,Vs,Sz),V1,[var(V,P,VSz,D,Ev,Tabs,E clpbn_not_var_member(Vs,V), !, include(LV,tab(T,Vs,Sz),V1,NLV). include([var(V,P,VSz,D,Ev,Tabs,_)|LV],Table,NV,[var(V,P,VSz,D,Ev,NTabs,NEst)|NLV]) :- - update_tables(Tabs,NTabs,Table,NV,[],NEst), + update_tables(Tabs,NTabs,Table,NV), + compute_size(NTabs, [], NEst), +% ( clpbn:get_atts(V,[key(Key)]) -> write(Key:NEst), nl ; true), include(LV,Table,NV,NLV). -update_tables([],[Table],Table,_,AVs,NS) :- - Table = tab(_,Vs,_), - ord_union(Vs,AVs,TVs), - length(TVs,NS). -update_tables([tab(Tab0,Vs,Sz)|Tabs],[tab(Tab0,Vs,Sz)|NTabs],Table,V,AVs0,NS) :- +update_tables([],[Table],Table,_). +update_tables([tab(Tab0,Vs,Sz)|Tabs],[tab(Tab0,Vs,Sz)|NTabs],Table,V) :- clpbn_not_var_member(Vs,V), !, - ord_union(Vs,AVs0,AVsI), - update_tables(Tabs,NTabs,Table,V,AVsI,NS). -update_tables([_|Tabs],NTabs,Table,V,AVs0,NS) :- - update_tables(Tabs,NTabs,Table,V,AVs0,NS). + update_tables(Tabs,NTabs,Table,V). +update_tables([_|Tabs],NTabs,Table,V) :- + update_tables(Tabs,NTabs,Table,V). bind_vals([],_,_) :- !. % simple case, we want a distribution on a single variable.