From 13d609867ce0376fa91c3c7c5e5c8b34f8db3e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Fri, 21 Sep 2018 13:31:22 +0100 Subject: [PATCH] recover space on foreign exec --- C/c_interface.c | 26 ++++++---------------- packages/ProbLog/problog_learning_lbdd.yap | 4 ++-- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/C/c_interface.c b/C/c_interface.c index b56bb2677..40695bafa 100755 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -1836,40 +1836,28 @@ X_API bool YAP_LeaveGoal(bool successful, YAP_dogoalinfo *dgi) { } handler = B; while (handler - //&& LOCAL_CBorder > LCL0 - (CELL *)handler + && LCL0-LOCAL_CBorder > (CELL *)handler //&& handler->cp_ap != NOCODE && handler->cp_b != NULL - && handler <= myB + && handler != myB ) { - if (handler < myB) + if (handler < myB ) { handler->cp_ap = TRUSTFAILCODE; + } B = handler; handler = handler->cp_b; if (successful) { Yap_TrimTrail(); - } else { + } else if (!(LOCAL_PrologMode & AsyncIntMode)) { P=FAILCODE; Yap_exec_absmi(true, YAP_EXEC_ABSMI); } } - if (successful) { - CP = dgi->cp; - P = dgi->p; - - } else { - LOCAL_CurSlot = dgi->CurSlot; - ENV = YENV = B->cp_env; - HR = B->cp_h; - TR = B->cp_tr; - // use the current choicepoint - // B=B->cp_b; - ASP=(CELL*)B; - } - if (B) - B = B->cp_b; if (LOCAL_PrologMode & AsyncIntMode) { Yap_signal(YAP_FAIL_SIGNAL); } + P=dgi->p; + CP = dgi->cp; RECOVER_MACHINE_REGS(); // fprintf(stderr,"LeftGoal success=%d: H=%d ENV=%p B=%d TR=%d P=%p CP=%p Slots=%d\n", successful,HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, CP, LOCAL_CurSlot); return TRUE; diff --git a/packages/ProbLog/problog_learning_lbdd.yap b/packages/ProbLog/problog_learning_lbdd.yap index a68b2f199..05b663176 100644 --- a/packages/ProbLog/problog_learning_lbdd.yap +++ b/packages/ProbLog/problog_learning_lbdd.yap @@ -641,7 +641,7 @@ init_one_query(QueryID,Query,Type) :- rb_new(H0), maplist_to_hash(MapList, H0, Hash), Tree \= [], - tree_to_grad(Tree, Hash, [], Grad), + tree_to_grad(Tree, Hash, [], Grad) ; Bdd = bdd(-1,[],[]), Grad=[] @@ -669,7 +669,7 @@ init_one_query(_QueryID,_Query,_Type) :- %======================================================================== -%= updates all values of query_probability/2 and query_gradient/4 +%= Updates all values of query_probability/2 and query_gradient/4 %= should be called always before these predicates are accessed %= if the old values are still valid, nothing happens %========================================================================