experiments with early completion.

This commit is contained in:
Vitor Santos Costa 2008-09-15 04:29:26 +01:00
parent 537dbb19fa
commit e35af2a352
2 changed files with 25 additions and 1 deletions

View File

@ -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)) {

View File

@ -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; \