From 23d44f959d9402e3392582e412093cac0f343911 Mon Sep 17 00:00:00 2001 From: Ricardo Rocha Date: Sun, 9 Aug 2009 03:38:07 +0100 Subject: [PATCH] include cp_h field in deterministic choice points, otherwise we get in trouble --- C/heapgc.c | 21 +-------------------- H/amidefs.h | 1 + OPTYap/opt.config.h | 18 +++++++++--------- OPTYap/tab.insts.i | 5 ++++- 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/C/heapgc.c b/C/heapgc.c index 7e8db09db..a3107873f 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -1914,10 +1914,7 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose) current_B = gc_B; prev_HB = HB; #endif -#ifdef DETERMINISTIC_TABLING - if (!IS_DET_GEN_CP(gc_B)) -#endif /* DETERMINISTIC_TABLING */ - HB = gc_B->cp_h; + HB = gc_B->cp_h; #ifdef INSTRUMENT_GC num_bs++; #endif @@ -1960,9 +1957,6 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose) } #endif } -#ifdef DETERMINISTIC_TABLING - if (!IS_DET_GEN_CP(gc_B)) -#endif /* DETERMINISTIC_TABLING */ { /* find out how many cells are still alive in the trail */ mark_trail(saved_TR, gc_B->cp_tr, gc_B->cp_h, gc_B); @@ -3181,15 +3175,6 @@ update_B_H( choiceptr gc_B, CELL *current, CELL *dest, CELL *odest dep_fr_ptr depfr = *depfrp; #endif /* TABLING */ -#ifdef DETERMINISTIC_TABLING - while (IS_DET_GEN_CP(gc_B)) - gc_B = gc_B->cp_b; - /* make sure we include consumers */ - if (depfr && gc_B >= DepFr_cons_cp(depfr)) { - gc_B = DepFr_cons_cp(depfr); - *depfrp = depfr = DepFr_next(depfr); - } -#endif /* DETERMINISTIC_TABLING */ while (gc_B && current <= gc_B->cp_h) { if (gc_B->cp_h == current) { gc_B->cp_h = dest; @@ -3198,10 +3183,6 @@ update_B_H( choiceptr gc_B, CELL *current, CELL *dest, CELL *odest } gc_B = gc_B->cp_b; #ifdef TABLING -#ifdef DETERMINISTIC_TABLING - while (IS_DET_GEN_CP(gc_B)) - gc_B = gc_B->cp_b; -#endif /* DETERMINISTIC_TABLING */ /* make sure we include consumers */ if (depfr && gc_B >= DepFr_cons_cp(depfr)) { gc_B = DepFr_cons_cp(depfr); diff --git a/H/amidefs.h b/H/amidefs.h index ac92af3bf..0b1d88122 100644 --- a/H/amidefs.h +++ b/H/amidefs.h @@ -816,6 +816,7 @@ struct deterministic_choicept { int cp_lub; /* local untried branches */ struct or_frame *cp_or_fr; /* or-frame pointer */ #endif /* YAPOR */ + CELL *cp_h; /* necessary, otherwise we get in trouble */ }; typedef struct choicept { diff --git a/OPTYap/opt.config.h b/OPTYap/opt.config.h index f92e17837..5f23d85a1 100644 --- a/OPTYap/opt.config.h +++ b/OPTYap/opt.config.h @@ -39,15 +39,20 @@ #define BFZ_TRAIL_SCHEME 1 /* #define BBREG_TRAIL_SCHEME 1 */ +/* ----------------------------------------------- ** +** support early completion ? (optional) ** +** ----------------------------------------------- */ +#define TABLING_EARLY_COMPLETION 1 + /* ------------------------------------------------ ** ** support trie compact pairs? (optional) ** ** ------------------------------------------------ */ /* #define TRIE_COMPACT_PAIRS 1 */ -/* ----------------------------------------------- ** -** support early completion ? (optional) ** -** ----------------------------------------------- */ -#define TABLING_EARLY_COMPLETION 1 +/* --------------------------------------------------- ** +** support deterministic tabling? (optional) ** +** --------------------------------------------------- */ +/* #define DETERMINISTIC_TABLING 1 */ /* ------------------------------------------------ ** ** limit the table space size? (optional) ** @@ -59,11 +64,6 @@ ** ------------------------------------------------ */ /* #define INCOMPLETE_TABLING 1 */ -/* --------------------------------------------------- ** -** support deterministic tabling? (optional) ** -** --------------------------------------------------- */ -/* #define DETERMINISTIC_TABLING 1 */ - /* ---------------------------------------- -- ** ** enable error checking? (optional) ** ** ------------------------------------------- */ diff --git a/OPTYap/tab.insts.i b/OPTYap/tab.insts.i index 769951aa9..8ca819423 100644 --- a/OPTYap/tab.insts.i +++ b/OPTYap/tab.insts.i @@ -95,9 +95,10 @@ /* store deterministic generator choice point */ \ HBREG = H; \ store_yaam_reg_cpdepth(gcp); \ - gcp->cp_tr = TR; \ gcp->cp_ap = COMPLETION; \ gcp->cp_b = B; \ + gcp->cp_tr = TR; \ + gcp->cp_h = H; \ DET_GEN_CP(gcp)->cp_sg_fr = SG_FR; \ store_low_level_trace_info(DET_GEN_CP(gcp), TAB_ENT); \ set_cut((CELL *)gcp, B); \ @@ -748,6 +749,7 @@ choiceptr gcp = NORM_CP(DET_GEN_CP(subs_ptr) - 1); sg_fr_ptr sg_fr = GEN_CP(B)->cp_sg_fr; DET_GEN_CP(gcp)->cp_sg_fr = sg_fr; + gcp->cp_h = B->cp_h; #ifdef DEPTH_LIMIT gcp->cp_depth = B->cp_depth; #endif /* DEPTH_LIMIT */ @@ -775,6 +777,7 @@ choiceptr gcp = NORM_CP(DET_GEN_CP(subs_ptr) - 1); sg_fr_ptr sg_fr = GEN_CP(B)->cp_sg_fr; DET_GEN_CP(gcp)->cp_sg_fr = sg_fr; + gcp->cp_h = B->cp_h; #ifdef DEPTH_LIMIT gcp->cp_depth = B->cp_depth; #endif /* DEPTH_LIMIT */