From e35af2a352b3b1e415753026a960e9bc9f491240 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Mon, 15 Sep 2008 04:29:26 +0100 Subject: [PATCH] experiments with early completion. --- OPTYap/tab.insts.i | 24 ++++++++++++++++++++++++ OPTYap/tab.macros.h | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/OPTYap/tab.insts.i b/OPTYap/tab.insts.i index ed281aac0..36ee753e4 100644 --- a/OPTYap/tab.insts.i +++ b/OPTYap/tab.insts.i @@ -952,8 +952,31 @@ /* if the number of substitution variables is zero, an answer is sufficient to perform an early completion */ if (*subs_ptr == 0 && gcp->cp_ap != ANSWER_RESOLUTION) { + dep_fr_ptr depfr = LOCAL_top_dep_fr; gcp->cp_ap = COMPLETION; mark_as_completed(sg_fr); + if (LOCAL_top_sg_fr && gcp != SgFr_gen_cp(LOCAL_top_sg_fr)) { + fprintf(stderr,"Producer %p--%p\n",gcp,SgFr_gen_cp(LOCAL_top_sg_fr)); + } else if ((depfr = LOCAL_top_dep_fr)) { + int external_consumers = FALSE; + choiceptr gc_B = B; + while (gc_B) { + if (gc_B > DepFr_cons_cp(depfr)) { + gc_B = DepFr_cons_cp(depfr); + depfr = DepFr_next(depfr); + } + if (gc_B->cp_b >= gcp) { + if (gc_B->cp_b > gcp) + external_consumers = TRUE; + break; + } + gc_B = gc_B->cp_b; + } + if (!external_consumers) { + B = gcp; + goto complete_all; + } + } } /* fail */ goto fail; @@ -1555,6 +1578,7 @@ /* complete all */ sg_fr_ptr sg_fr; + complete_all: sg_fr = GEN_CP(B)->cp_sg_fr; private_completion(sg_fr); if (IS_BATCHED_GEN_CP(B)) { diff --git a/OPTYap/tab.macros.h b/OPTYap/tab.macros.h index c40d1aae6..ee3909b41 100644 --- a/OPTYap/tab.macros.h +++ b/OPTYap/tab.macros.h @@ -84,7 +84,7 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p void *old_top; \ UInt diff; \ CELL *NEW_STACK; \ - INFORMATION_MESSAGE("Expanding trail in 64 Mbytes"); \ + INFORMATION_MESSAGE("Expanding trail in 64 Kbytes"); \ old_top = Yap_TrailTop; \ Yap_growtrail(64 * 1024L, TRUE); \ diff = (void *)Yap_TrailTop - old_top; \