Merge branch 'master' of gitosis@yap.dcc.fc.up.pt:yap-6
This commit is contained in:
commit
0cf7780db9
@ -51,10 +51,9 @@
|
||||
******************************************************/
|
||||
#define TRIE_COMPACT_PAIRS 1
|
||||
|
||||
/***********************************************************
|
||||
** support global trie ? (optional, define one) **
|
||||
***********************************************************/
|
||||
/* #define GLOBAL_TRIE_FOR_TERMS 1 */
|
||||
/************************************************************
|
||||
** support global trie for subterms ? (optional) **
|
||||
************************************************************/
|
||||
/* #define GLOBAL_TRIE_FOR_SUBTERMS 1 */
|
||||
|
||||
/******************************************************
|
||||
@ -189,12 +188,6 @@
|
||||
#if defined(BFZ_TRAIL_SCHEME) && defined(BBREG_TRAIL_SCHEME)
|
||||
#error Do not define multiple trail schemes
|
||||
#endif /* BFZ_TRAIL_SCHEME && BBREG_TRAIL_SCHEME */
|
||||
#if defined(GLOBAL_TRIE_FOR_TERMS) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
#error Do not define multiple global trie schemes
|
||||
#endif /* GLOBAL_TRIE_FOR_TERMS && GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
#if defined(GLOBAL_TRIE_FOR_TERMS) || defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
#define GLOBAL_TRIE
|
||||
#endif /* GLOBAL_TRIE_FOR_TERMS || GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
#endif /* TABLING */
|
||||
|
||||
#if defined(YAPOR) && defined(TABLING)
|
||||
@ -233,7 +226,6 @@
|
||||
#undef BBREG_TRAIL_SCHEME
|
||||
#undef TABLING_EARLY_COMPLETION
|
||||
#undef TRIE_COMPACT_PAIRS
|
||||
#undef GLOBAL_TRIE_FOR_TERMS
|
||||
#undef GLOBAL_TRIE_FOR_SUBTERMS
|
||||
#undef DETERMINISTIC_TABLING
|
||||
#undef LIMIT_TABLING
|
||||
|
@ -99,17 +99,15 @@ void Yap_init_global(int max_table_size, int n_workers, int sch_loop, int delay_
|
||||
INIT_PAGES(GLOBAL_PAGES_tg_ans_fr, struct table_subgoal_answer_frame);
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
#ifdef TABLING
|
||||
#ifdef GLOBAL_TRIE
|
||||
INIT_PAGES(GLOBAL_PAGES_gt_node, struct global_trie_node);
|
||||
INIT_PAGES(GLOBAL_PAGES_gt_hash, struct global_trie_hash);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
INIT_PAGES(GLOBAL_PAGES_tab_ent, struct table_entry);
|
||||
INIT_PAGES(GLOBAL_PAGES_sg_fr, struct subgoal_frame);
|
||||
INIT_PAGES(GLOBAL_PAGES_dep_fr, struct dependency_frame);
|
||||
INIT_PAGES(GLOBAL_PAGES_sg_node, struct subgoal_trie_node);
|
||||
INIT_PAGES(GLOBAL_PAGES_ans_node, struct answer_trie_node);
|
||||
INIT_PAGES(GLOBAL_PAGES_gt_node, struct global_trie_node);
|
||||
INIT_PAGES(GLOBAL_PAGES_sg_hash, struct subgoal_trie_hash);
|
||||
INIT_PAGES(GLOBAL_PAGES_ans_hash, struct answer_trie_hash);
|
||||
INIT_PAGES(GLOBAL_PAGES_dep_fr, struct dependency_frame);
|
||||
INIT_PAGES(GLOBAL_PAGES_gt_hash, struct global_trie_hash);
|
||||
#endif /* TABLING */
|
||||
#if defined(YAPOR) && defined(TABLING)
|
||||
INIT_PAGES(GLOBAL_PAGES_susp_fr, struct suspension_frame);
|
||||
@ -158,10 +156,8 @@ void Yap_init_global(int max_table_size, int n_workers, int sch_loop, int delay_
|
||||
|
||||
#ifdef TABLING
|
||||
/* global data related to tabling */
|
||||
GLOBAL_root_tab_ent = NULL;
|
||||
#ifdef GLOBAL_TRIE
|
||||
new_global_trie_node(GLOBAL_root_gt, 0, NULL, NULL, NULL);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
GLOBAL_root_tab_ent = NULL;
|
||||
#ifdef LIMIT_TABLING
|
||||
GLOBAL_first_sg_fr = NULL;
|
||||
GLOBAL_last_sg_fr = NULL;
|
||||
|
@ -45,18 +45,18 @@ extern int Yap_page_size;
|
||||
|
||||
|
||||
#ifdef MALLOC_MEMORY_ALLOC_SCHEME
|
||||
/********************************************************************************************************
|
||||
/*************************************************************************************************
|
||||
** MALLOC_MEMORY_ALLOC_SCHEME **
|
||||
********************************************************************************************************/
|
||||
*************************************************************************************************/
|
||||
#define ALLOC_BLOCK(STR, SIZE, STR_TYPE) \
|
||||
if ((STR = (STR_TYPE *) malloc(SIZE)) == NULL) \
|
||||
Yap_Error(FATAL_ERROR, TermNil, "ALLOC_BLOCK: malloc error")
|
||||
#define FREE_BLOCK(STR) \
|
||||
free(STR)
|
||||
#else
|
||||
/********************************************************************************************************
|
||||
/*************************************************************************************************
|
||||
** ! MALLOC_MEMORY_ALLOC_SCHEME **
|
||||
********************************************************************************************************/
|
||||
*************************************************************************************************/
|
||||
#define ALLOC_BLOCK(STR, SIZE, STR_TYPE) \
|
||||
{ char *block_ptr; \
|
||||
if ((block_ptr = Yap_AllocCodeSpace(SIZE + sizeof(CELL))) != NULL) \
|
||||
@ -75,13 +75,13 @@ extern int Yap_page_size;
|
||||
else \
|
||||
free(block_ptr); \
|
||||
}
|
||||
#endif /************************************************************************************************/
|
||||
#endif /*****************************************************************************************/
|
||||
|
||||
|
||||
#if defined(MALLOC_MEMORY_ALLOC_SCHEME) || defined(YAP_MEMORY_ALLOC_SCHEME)
|
||||
/********************************************************************************************************
|
||||
/*************************************************************************************************
|
||||
** MALLOC_MEMORY_ALLOC_SCHEME || YAP_MEMORY_ALLOC_SCHEME **
|
||||
********************************************************************************************************/
|
||||
*************************************************************************************************/
|
||||
#define ALLOC_STRUCT(STR, STR_PAGES, STR_TYPE) \
|
||||
UPDATE_STATS(Pg_str_in_use(STR_PAGES), 1); \
|
||||
ALLOC_BLOCK(STR, sizeof(STR_TYPE), STR_TYPE)
|
||||
@ -92,9 +92,9 @@ extern int Yap_page_size;
|
||||
FREE_BLOCK(STR)
|
||||
#elif SHM_MEMORY_ALLOC_SCHEME
|
||||
#ifdef LIMIT_TABLING
|
||||
/********************************************************************************************************
|
||||
/*************************************************************************************************
|
||||
** SHM_MEMORY_ALLOC_SCHEME && LIMIT_TABLING **
|
||||
********************************************************************************************************/
|
||||
*************************************************************************************************/
|
||||
#define INIT_PAGE(PG_HD, STR_PAGES, STR_TYPE) \
|
||||
{ int i; \
|
||||
STR_TYPE *aux_str; \
|
||||
@ -149,11 +149,12 @@ extern int Yap_page_size;
|
||||
if (SgFr_first_answer(sg_fr) && \
|
||||
SgFr_first_answer(sg_fr) != SgFr_answer_trie(sg_fr)) { \
|
||||
SgFr_state(sg_fr) = ready; \
|
||||
free_answer_trie_hash_chain(SgFr_hash_chain(sg_fr)); \
|
||||
free_answer_hash_chain(SgFr_hash_chain(sg_fr)); \
|
||||
SgFr_hash_chain(sg_fr) = NULL; \
|
||||
SgFr_first_answer(sg_fr) = NULL; \
|
||||
SgFr_last_answer(sg_fr) = NULL; \
|
||||
free_answer_trie_branch(TrNode_child(SgFr_answer_trie(sg_fr)), TRAVERSE_POSITION_FIRST); \
|
||||
free_answer_trie(TrNode_child(SgFr_answer_trie(sg_fr)), \
|
||||
TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST); \
|
||||
TrNode_child(SgFr_answer_trie(sg_fr)) = NULL; \
|
||||
} \
|
||||
} while (Pg_free_pg(GLOBAL_PAGES_void) == Pg_free_pg(STR_PAGES)); \
|
||||
@ -230,9 +231,9 @@ extern int Yap_page_size;
|
||||
} \
|
||||
LOCAL_next_free_ans_node = STRUCT_NEXT(STR)
|
||||
#else
|
||||
/********************************************************************************************************
|
||||
/*************************************************************************************************
|
||||
** SHM_MEMORY_ALLOC_SCHEME && !LIMIT_TABLING **
|
||||
********************************************************************************************************/
|
||||
*************************************************************************************************/
|
||||
#define ALLOC_PAGE(PG_HD) \
|
||||
LOCK(Pg_lock(GLOBAL_PAGES_void)); \
|
||||
if (Pg_free_pg(GLOBAL_PAGES_void) == NULL) { \
|
||||
@ -326,9 +327,9 @@ extern int Yap_page_size;
|
||||
} \
|
||||
LOCAL_next_free_ans_node = STRUCT_NEXT(STR)
|
||||
#endif /* LIMIT_TABLING */
|
||||
/********************************************************************************************************
|
||||
/*************************************************************************************************
|
||||
** SHM_MEMORY_ALLOC_SCHEME **
|
||||
********************************************************************************************************/
|
||||
*************************************************************************************************/
|
||||
#define FREE_PAGE(PG_HD) \
|
||||
LOCK(Pg_lock(GLOBAL_PAGES_void)); \
|
||||
UPDATE_STATS(Pg_str_in_use(GLOBAL_PAGES_void), -1); \
|
||||
@ -363,7 +364,7 @@ extern int Yap_page_size;
|
||||
UNLOCK(Pg_lock(STR_PAGES)); \
|
||||
} \
|
||||
}
|
||||
#endif /************************************************************************************************/
|
||||
#endif /*****************************************************************************************/
|
||||
|
||||
#define ALLOC_HASH_BUCKETS(BUCKET_PTR, NUM_BUCKETS) \
|
||||
{ int i; void **bucket_ptr; \
|
||||
|
@ -45,12 +45,10 @@ static Int p_abolish_all_tables(void);
|
||||
static Int p_show_tabled_predicates(void);
|
||||
static Int p_show_table(void);
|
||||
static Int p_show_all_tables(void);
|
||||
#ifdef GLOBAL_TRIE
|
||||
static Int p_show_global_trie(void);
|
||||
static Int p_show_statistics_global_trie(void);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
static Int p_show_statistics_table(void);
|
||||
static Int p_show_statistics_tabling(void);
|
||||
static Int p_show_statistics_global_trie(void);
|
||||
#endif /* TABLING */
|
||||
static Int p_yapor_threads(void);
|
||||
#ifdef YAPOR
|
||||
@ -84,10 +82,8 @@ static inline long show_statistics_subgoal_trie_nodes(void);
|
||||
static inline long show_statistics_answer_trie_nodes(void);
|
||||
static inline long show_statistics_subgoal_trie_hashes(void);
|
||||
static inline long show_statistics_answer_trie_hashes(void);
|
||||
#ifdef GLOBAL_TRIE
|
||||
static inline long show_statistics_global_trie_nodes(void);
|
||||
static inline long show_statistics_global_trie_hashes(void);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
#endif /* TABLING */
|
||||
#ifdef YAPOR
|
||||
static inline long show_statistics_or_frames(void);
|
||||
@ -134,12 +130,10 @@ void Yap_init_optyap_preds(void) {
|
||||
Yap_InitCPred("show_tabled_predicates", 0, p_show_tabled_predicates, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$c_show_table", 2, p_show_table, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("show_all_tables", 0, p_show_all_tables, SafePredFlag|SyncPredFlag);
|
||||
#ifdef GLOBAL_TRIE
|
||||
Yap_InitCPred("show_global_trie", 0, p_show_global_trie, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("global_trie_statistics", 0, p_show_statistics_global_trie, SafePredFlag|SyncPredFlag);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
Yap_InitCPred("$c_table_statistics", 2, p_show_statistics_table, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("tabling_statistics", 0, p_show_statistics_tabling, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("global_trie_statistics", 0, p_show_statistics_global_trie, SafePredFlag|SyncPredFlag);
|
||||
#endif /* TABLING */
|
||||
Yap_InitCPred("$c_yapor_threads", 1, p_yapor_threads, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
#ifdef YAPOR
|
||||
@ -339,15 +333,20 @@ static Int p_abolish_table(void) {
|
||||
return (FALSE);
|
||||
hash = TabEnt_hash_chain(tab_ent);
|
||||
TabEnt_hash_chain(tab_ent) = NULL;
|
||||
free_subgoal_trie_hash_chain(hash);
|
||||
free_subgoal_hash_chain(hash);
|
||||
sg_node = TrNode_child(TabEnt_subgoal_trie(tab_ent));
|
||||
if (sg_node) {
|
||||
if (TabEnt_arity(tab_ent)) {
|
||||
TrNode_child(TabEnt_subgoal_trie(tab_ent)) = NULL;
|
||||
#ifdef GLOBAL_TRIE
|
||||
free_subgoal_trie_branch(sg_node, TabEnt_arity(tab_ent), TRAVERSE_POSITION_FIRST);
|
||||
#else
|
||||
free_subgoal_trie_branch(sg_node, TabEnt_arity(tab_ent), 0, TRAVERSE_POSITION_FIRST);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
free_subgoal_trie(sg_node, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST);
|
||||
} else {
|
||||
sg_fr_ptr sg_fr = UNTAG_SUBGOAL_LEAF_NODE(sg_node);
|
||||
FREE_ANSWER_TRIE_NODE(SgFr_answer_trie(sg_fr));
|
||||
#ifdef LIMIT_TABLING
|
||||
remove_from_global_sg_fr_list(sg_fr);
|
||||
#endif /* LIMIT_TABLING */
|
||||
FREE_SUBGOAL_FRAME(sg_fr);
|
||||
}
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
@ -362,15 +361,20 @@ static Int p_abolish_all_tables(void) {
|
||||
while(tab_ent) {
|
||||
hash = TabEnt_hash_chain(tab_ent);
|
||||
TabEnt_hash_chain(tab_ent) = NULL;
|
||||
free_subgoal_trie_hash_chain(hash);
|
||||
free_subgoal_hash_chain(hash);
|
||||
sg_node = TrNode_child(TabEnt_subgoal_trie(tab_ent));
|
||||
if (sg_node) {
|
||||
if (TabEnt_arity(tab_ent)) {
|
||||
TrNode_child(TabEnt_subgoal_trie(tab_ent)) = NULL;
|
||||
#ifdef GLOBAL_TRIE
|
||||
free_subgoal_trie_branch(sg_node, TabEnt_arity(tab_ent), TRAVERSE_POSITION_FIRST);
|
||||
#else
|
||||
free_subgoal_trie_branch(sg_node, TabEnt_arity(tab_ent), 0, TRAVERSE_POSITION_FIRST);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
free_subgoal_trie(sg_node, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST);
|
||||
} else {
|
||||
sg_fr_ptr sg_fr = UNTAG_SUBGOAL_LEAF_NODE(sg_node);
|
||||
FREE_ANSWER_TRIE_NODE(SgFr_answer_trie(sg_fr));
|
||||
#ifdef LIMIT_TABLING
|
||||
remove_from_global_sg_fr_list(sg_fr);
|
||||
#endif /* LIMIT_TABLING */
|
||||
FREE_SUBGOAL_FRAME(sg_fr);
|
||||
}
|
||||
}
|
||||
tab_ent = TabEnt_next(tab_ent);
|
||||
}
|
||||
@ -423,18 +427,11 @@ static Int p_show_all_tables(void) {
|
||||
}
|
||||
|
||||
|
||||
#ifdef GLOBAL_TRIE
|
||||
static Int p_show_global_trie(void) {
|
||||
show_global_trie(SHOW_MODE_STRUCTURE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static Int p_show_statistics_global_trie(void) {
|
||||
show_global_trie(SHOW_MODE_STATISTICS);
|
||||
return (TRUE);
|
||||
}
|
||||
#endif /* GLOBAL_TRIE */
|
||||
|
||||
|
||||
static Int p_show_statistics_table(void) {
|
||||
Term mod, t;
|
||||
@ -461,31 +458,29 @@ static Int p_show_statistics_tabling(void) {
|
||||
aux_bytes += show_statistics_table_entries();
|
||||
aux_bytes += show_statistics_subgoal_frames();
|
||||
aux_bytes += show_statistics_dependency_frames();
|
||||
fprintf(Yap_stdout, " Memory in use: %10ld bytes\n", aux_bytes);
|
||||
fprintf(Yap_stdout, " Memory in use (I): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
aux_bytes = 0;
|
||||
fprintf(Yap_stdout, "\nLocal trie data structures\n");
|
||||
fprintf(Yap_stdout, "Local trie data structures\n");
|
||||
aux_bytes += show_statistics_subgoal_trie_nodes();
|
||||
aux_bytes += show_statistics_answer_trie_nodes();
|
||||
aux_bytes += show_statistics_subgoal_trie_hashes();
|
||||
aux_bytes += show_statistics_answer_trie_hashes();
|
||||
fprintf(Yap_stdout, " Memory in use: %10ld bytes\n", aux_bytes);
|
||||
fprintf(Yap_stdout, " Memory in use (II): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
#ifdef GLOBAL_TRIE
|
||||
aux_bytes = 0;
|
||||
fprintf(Yap_stdout, "\nGlobal trie data structures\n");
|
||||
fprintf(Yap_stdout, "Global trie data structures\n");
|
||||
aux_bytes += show_statistics_global_trie_nodes();
|
||||
aux_bytes += show_statistics_global_trie_hashes();
|
||||
fprintf(Yap_stdout, " Memory in use: %10ld bytes\n", aux_bytes);
|
||||
fprintf(Yap_stdout, " Memory in use (III): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
#endif /* GLOBAL_TRIE */
|
||||
#ifdef SHM_MEMORY_ALLOC_SCHEME
|
||||
fprintf(Yap_stdout, "\nTotal memory in use: %10ld bytes (%ld pages in use)\n",
|
||||
fprintf(Yap_stdout, "Total memory in use (I+II+III): %10ld bytes (%ld pages in use)\n",
|
||||
total_bytes, Pg_str_in_use(GLOBAL_PAGES_void));
|
||||
fprintf(Yap_stdout, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_void) * Yap_page_size, Pg_pg_alloc(GLOBAL_PAGES_void));
|
||||
#else
|
||||
fprintf(Yap_stdout, "\nTotal memory in use: %10ld bytes\n", total_bytes);
|
||||
fprintf(Yap_stdout, "Total memory in use (I+II+III): %10ld bytes\n", total_bytes);
|
||||
#endif /* SHM_MEMORY_ALLOC_SCHEME */
|
||||
|
||||
return (TRUE);
|
||||
@ -493,6 +488,12 @@ static Int p_show_statistics_tabling(void) {
|
||||
#endif /* TABLING */
|
||||
|
||||
|
||||
static Int p_show_statistics_global_trie(void) {
|
||||
show_global_trie(SHOW_MODE_STATISTICS);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*********************************
|
||||
** YapOr C Predicates **
|
||||
@ -703,21 +704,21 @@ static Int p_show_statistics_or(void) {
|
||||
aux_bytes = 0;
|
||||
fprintf(Yap_stdout, "Execution data structures\n");
|
||||
aux_bytes += show_statistics_or_frames();
|
||||
fprintf(Yap_stdout, " Memory in use: %10ld bytes\n", aux_bytes);
|
||||
fprintf(Yap_stdout, " Memory in use (I): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
aux_bytes = 0;
|
||||
fprintf(Yap_stdout, "\nCut support data structures\n");
|
||||
fprintf(Yap_stdout, "Cut support data structures\n");
|
||||
aux_bytes += show_statistics_query_goal_solution_frames();
|
||||
aux_bytes += show_statistics_query_goal_answer_frames();
|
||||
fprintf(Yap_stdout, " Memory in use: %10ld bytes\n", aux_bytes);
|
||||
fprintf(Yap_stdout, " Memory in use (II): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
#ifdef SHM_MEMORY_ALLOC_SCHEME
|
||||
fprintf(Yap_stdout, "\nTotal memory in use: %10ld bytes (%ld pages in use)\n",
|
||||
fprintf(Yap_stdout, "Total memory in use (I+II+III): %10ld bytes (%ld pages in use)\n",
|
||||
total_bytes, Pg_str_in_use(GLOBAL_PAGES_void));
|
||||
fprintf(Yap_stdout, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_void) * Yap_page_size, Pg_pg_alloc(GLOBAL_PAGES_void));
|
||||
#else
|
||||
fprintf(Yap_stdout, "\nTotal memory in use: %10ld bytes\n", total_bytes);
|
||||
fprintf(Yap_stdout, "Total memory in use (I+II+III): %10ld bytes\n", total_bytes);
|
||||
#endif /* SHM_MEMORY_ALLOC_SCHEME */
|
||||
|
||||
return (TRUE);
|
||||
@ -741,41 +742,39 @@ static Int p_show_statistics_opt(void) {
|
||||
aux_bytes += show_statistics_dependency_frames();
|
||||
aux_bytes += show_statistics_or_frames();
|
||||
aux_bytes += show_statistics_suspension_frames();
|
||||
fprintf(Yap_stdout, " Memory in use: %10ld bytes\n", aux_bytes);
|
||||
fprintf(Yap_stdout, " Memory in use (I): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
aux_bytes = 0;
|
||||
fprintf(Yap_stdout, "\nLocal trie data structures\n");
|
||||
fprintf(Yap_stdout, "Local trie data structures\n");
|
||||
aux_bytes += show_statistics_subgoal_trie_nodes();
|
||||
aux_bytes += show_statistics_answer_trie_nodes();
|
||||
aux_bytes += show_statistics_subgoal_trie_hashes();
|
||||
aux_bytes += show_statistics_answer_trie_hashes();
|
||||
fprintf(Yap_stdout, " Memory in use: %10ld bytes\n", aux_bytes);
|
||||
fprintf(Yap_stdout, " Memory in use (II): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
#ifdef GLOBAL_TRIE
|
||||
aux_bytes = 0;
|
||||
fprintf(Yap_stdout, "\nGlobal trie data structures\n");
|
||||
fprintf(Yap_stdout, "Global trie data structures\n");
|
||||
aux_bytes += show_statistics_global_trie_nodes();
|
||||
aux_bytes += show_statistics_global_trie_hashes();
|
||||
fprintf(Yap_stdout, " Memory in use: %10ld bytes\n", aux_bytes);
|
||||
fprintf(Yap_stdout, " Memory in use (III): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
#endif /* GLOBAL_TRIE */
|
||||
aux_bytes = 0;
|
||||
fprintf(Yap_stdout, "\nCut support data structures\n");
|
||||
fprintf(Yap_stdout, "Cut support data structures\n");
|
||||
aux_bytes += show_statistics_query_goal_solution_frames();
|
||||
aux_bytes += show_statistics_query_goal_answer_frames();
|
||||
#ifdef TABLING_INNER_CUTS
|
||||
aux_bytes += show_statistics_table_subgoal_solution_frames();
|
||||
aux_bytes += show_statistics_table_subgoal_answer_frames();
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
fprintf(Yap_stdout, " Memory in use: %10ld bytes\n", aux_bytes);
|
||||
fprintf(Yap_stdout, " Memory in use (IV): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
#ifdef SHM_MEMORY_ALLOC_SCHEME
|
||||
fprintf(Yap_stdout, "\nTotal memory in use: %10ld bytes (%ld pages in use)\n",
|
||||
fprintf(Yap_stdout, "Total memory in use (I+II+III+IV): %10ld bytes (%ld pages in use)\n",
|
||||
total_bytes, Pg_str_in_use(GLOBAL_PAGES_void));
|
||||
fprintf(Yap_stdout, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_void) * Yap_page_size, Pg_pg_alloc(GLOBAL_PAGES_void));
|
||||
#else
|
||||
fprintf(Yap_stdout, "\nTotal memory in use: %10ld bytes\n", total_bytes);
|
||||
fprintf(Yap_stdout, "Total memory in use (I+II+III+IV): %10ld bytes\n", total_bytes);
|
||||
#endif /* SHM_MEMORY_ALLOC_SCHEME */
|
||||
|
||||
return (TRUE);
|
||||
@ -798,10 +797,8 @@ static Int p_get_optyap_statistics(void) {
|
||||
bytes += Pg_str_in_use(GLOBAL_PAGES_ans_node) * sizeof(struct answer_trie_node);
|
||||
bytes += Pg_str_in_use(GLOBAL_PAGES_sg_hash) * sizeof(struct subgoal_trie_hash);
|
||||
bytes += Pg_str_in_use(GLOBAL_PAGES_ans_hash) * sizeof(struct answer_trie_hash);
|
||||
#ifdef GLOBAL_TRIE
|
||||
bytes += Pg_str_in_use(GLOBAL_PAGES_gt_node) * sizeof(struct global_trie_node);
|
||||
bytes += Pg_str_in_use(GLOBAL_PAGES_gt_hash) * sizeof(struct global_trie_hash);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
#endif /* TABLING */
|
||||
#ifdef YAPOR
|
||||
bytes += Pg_str_in_use(GLOBAL_PAGES_or_fr) * sizeof(struct or_frame);
|
||||
@ -850,7 +847,6 @@ static Int p_get_optyap_statistics(void) {
|
||||
bytes = Pg_str_in_use(GLOBAL_PAGES_ans_hash) * sizeof(struct answer_trie_hash);
|
||||
structs = Pg_str_in_use(GLOBAL_PAGES_ans_hash);
|
||||
}
|
||||
#ifdef GLOBAL_TRIE
|
||||
if (value == 10) { /* global_trie_nodes */
|
||||
bytes = Pg_str_in_use(GLOBAL_PAGES_gt_node) * sizeof(struct global_trie_node);
|
||||
structs = Pg_str_in_use(GLOBAL_PAGES_gt_node);
|
||||
@ -859,7 +855,6 @@ static Int p_get_optyap_statistics(void) {
|
||||
bytes = Pg_str_in_use(GLOBAL_PAGES_gt_hash) * sizeof(struct global_trie_hash);
|
||||
structs = Pg_str_in_use(GLOBAL_PAGES_gt_hash);
|
||||
}
|
||||
#endif /* GLOBAL_TRIE */
|
||||
#endif /* TABLING */
|
||||
#ifdef YAPOR
|
||||
if (value == 4) { /* or_frames */
|
||||
@ -1223,7 +1218,6 @@ static inline long show_statistics_answer_trie_hashes(void) {
|
||||
}
|
||||
|
||||
|
||||
#ifdef GLOBAL_TRIE
|
||||
static inline long show_statistics_global_trie_nodes(void) {
|
||||
#ifdef SHM_MEMORY_ALLOC_SCHEME
|
||||
#ifdef DEBUG_TABLING
|
||||
@ -1278,7 +1272,6 @@ static inline long show_statistics_global_trie_hashes(void) {
|
||||
#endif /* SHM_MEMORY_ALLOC_SCHEME */
|
||||
return Pg_str_in_use(GLOBAL_PAGES_gt_hash) * sizeof(struct global_trie_hash);
|
||||
}
|
||||
#endif /* GLOBAL_TRIE */
|
||||
#endif /* TABLING */
|
||||
|
||||
|
||||
|
@ -61,22 +61,14 @@ void finish_yapor(void);
|
||||
sg_fr_ptr subgoal_search(yamop *, CELL **);
|
||||
ans_node_ptr answer_search(sg_fr_ptr, CELL *);
|
||||
void load_answer(ans_node_ptr, CELL *);
|
||||
#ifdef GLOBAL_TRIE
|
||||
CELL *exec_substitution(gt_node_ptr, CELL *);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
void update_answer_trie(sg_fr_ptr);
|
||||
#ifndef GLOBAL_TRIE
|
||||
void free_subgoal_trie_branch(sg_node_ptr, int, int, int);
|
||||
#else /* GLOBAL_TRIE */
|
||||
void free_subgoal_trie_branch(sg_node_ptr, int, int);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
void free_answer_trie_branch(ans_node_ptr, int);
|
||||
void free_subgoal_trie_hash_chain(sg_hash_ptr);
|
||||
void free_answer_trie_hash_chain(ans_hash_ptr);
|
||||
void free_subgoal_trie(sg_node_ptr, int, int);
|
||||
void free_answer_trie(ans_node_ptr, int, int);
|
||||
void free_subgoal_hash_chain(sg_hash_ptr);
|
||||
void free_answer_hash_chain(ans_hash_ptr);
|
||||
void show_table(tab_ent_ptr, int);
|
||||
#ifdef GLOBAL_TRIE
|
||||
void show_global_trie(int);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
#endif /* TABLING */
|
||||
|
||||
|
||||
|
@ -111,17 +111,15 @@ struct global_pages {
|
||||
struct pages table_subgoal_answer_frame_pages;
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
#ifdef TABLING
|
||||
#ifdef GLOBAL_TRIE
|
||||
struct pages global_trie_node_pages;
|
||||
struct pages global_trie_hash_pages;
|
||||
#endif /* GLOBAL_TRIE */
|
||||
struct pages table_entry_pages;
|
||||
struct pages subgoal_frame_pages;
|
||||
struct pages dependency_frame_pages;
|
||||
struct pages subgoal_trie_node_pages;
|
||||
struct pages answer_trie_node_pages;
|
||||
struct pages global_trie_node_pages;
|
||||
struct pages subgoal_trie_hash_pages;
|
||||
struct pages answer_trie_hash_pages;
|
||||
struct pages dependency_frame_pages;
|
||||
struct pages global_trie_hash_pages;
|
||||
#endif /* TABLING */
|
||||
#if defined(YAPOR) && defined(TABLING)
|
||||
struct pages suspension_frame_pages;
|
||||
@ -203,10 +201,8 @@ struct global_data{
|
||||
|
||||
#ifdef TABLING
|
||||
/* global data related to tabling */
|
||||
struct table_entry *root_table_entry;
|
||||
#ifdef GLOBAL_TRIE
|
||||
struct global_trie_node *root_global_trie;
|
||||
#endif /* GLOBAL_TRIE */
|
||||
struct table_entry *root_table_entry;
|
||||
#ifdef LIMIT_TABLING
|
||||
struct subgoal_frame *first_subgoal_frame;
|
||||
struct subgoal_frame *last_subgoal_frame;
|
||||
@ -230,15 +226,15 @@ struct global_data{
|
||||
#define GLOBAL_PAGES_qg_ans_fr (GLOBAL.pages.query_goal_answer_frame_pages)
|
||||
#define GLOBAL_PAGES_tg_sol_fr (GLOBAL.pages.table_subgoal_solution_frame_pages)
|
||||
#define GLOBAL_PAGES_tg_ans_fr (GLOBAL.pages.table_subgoal_answer_frame_pages)
|
||||
#define GLOBAL_PAGES_gt_node (GLOBAL.pages.global_trie_node_pages)
|
||||
#define GLOBAL_PAGES_gt_hash (GLOBAL.pages.global_trie_hash_pages)
|
||||
#define GLOBAL_PAGES_tab_ent (GLOBAL.pages.table_entry_pages)
|
||||
#define GLOBAL_PAGES_sg_fr (GLOBAL.pages.subgoal_frame_pages)
|
||||
#define GLOBAL_PAGES_dep_fr (GLOBAL.pages.dependency_frame_pages)
|
||||
#define GLOBAL_PAGES_sg_node (GLOBAL.pages.subgoal_trie_node_pages)
|
||||
#define GLOBAL_PAGES_ans_node (GLOBAL.pages.answer_trie_node_pages)
|
||||
#define GLOBAL_PAGES_gt_node (GLOBAL.pages.global_trie_node_pages)
|
||||
#define GLOBAL_PAGES_sg_hash (GLOBAL.pages.subgoal_trie_hash_pages)
|
||||
#define GLOBAL_PAGES_ans_hash (GLOBAL.pages.answer_trie_hash_pages)
|
||||
#define GLOBAL_PAGES_dep_fr (GLOBAL.pages.dependency_frame_pages)
|
||||
#define GLOBAL_PAGES_gt_hash (GLOBAL.pages.global_trie_hash_pages)
|
||||
#define GLOBAL_PAGES_susp_fr (GLOBAL.pages.suspension_frame_pages)
|
||||
#define SCHEDULER_LOOP (GLOBAL.scheduler_loop)
|
||||
#define DELAYED_RELEASE_LOAD (GLOBAL.delayed_release_load)
|
||||
@ -279,8 +275,8 @@ struct global_data{
|
||||
#define GLOBAL_branch(worker, depth) (GLOBAL.branch[worker][depth])
|
||||
#define PARALLEL_EXECUTION_MODE (GLOBAL.parallel_execution_mode)
|
||||
#define GLOBAL_answers (GLOBAL.answers)
|
||||
#define GLOBAL_root_tab_ent (GLOBAL.root_table_entry)
|
||||
#define GLOBAL_root_gt (GLOBAL.root_global_trie)
|
||||
#define GLOBAL_root_tab_ent (GLOBAL.root_table_entry)
|
||||
#define GLOBAL_first_sg_fr (GLOBAL.first_subgoal_frame)
|
||||
#define GLOBAL_last_sg_fr (GLOBAL.last_subgoal_frame)
|
||||
#define GLOBAL_check_sg_fr (GLOBAL.check_subgoal_frame)
|
||||
|
@ -89,8 +89,6 @@ static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames(tg_sol_fr_ptr, int);
|
||||
|
||||
#define SHOW_MODE_STRUCTURE 0
|
||||
#define SHOW_MODE_STATISTICS 1
|
||||
#define TRAVERSE_TYPE_SUBGOAL 0
|
||||
#define TRAVERSE_TYPE_ANSWER 1
|
||||
#define TRAVERSE_MODE_NORMAL 0
|
||||
#define TRAVERSE_MODE_DOUBLE 1
|
||||
#define TRAVERSE_MODE_DOUBLE2 2
|
||||
@ -98,6 +96,11 @@ static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames(tg_sol_fr_ptr, int);
|
||||
#define TRAVERSE_MODE_LONGINT 4
|
||||
#define TRAVERSE_MODE_LONGINT_END 5
|
||||
/* do not change order !!! */
|
||||
#define TRAVERSE_TYPE_SUBGOAL 0
|
||||
#define TRAVERSE_TYPE_ANSWER 1
|
||||
#define TRAVERSE_TYPE_GT_SUBGOAL 2
|
||||
#define TRAVERSE_TYPE_GT_ANSWER 3
|
||||
/* do not change order !!! */
|
||||
#define TRAVERSE_POSITION_NEXT 0
|
||||
#define TRAVERSE_POSITION_FIRST 1
|
||||
#define TRAVERSE_POSITION_LAST 2
|
||||
@ -131,6 +134,9 @@ static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames(tg_sol_fr_ptr, int);
|
||||
#define IS_BATCHED_GEN_CP(CP) (GEN_CP(CP)->cp_dep_fr == NULL)
|
||||
#endif /* DETERMINISTIC_TABLING */
|
||||
|
||||
#define TAG_AS_SUBGOAL_LEAF_NODE(NODE) TrNode_child(NODE) = (sg_node_ptr)((unsigned long int) TrNode_child(NODE) | 0x1)
|
||||
#define UNTAG_SUBGOAL_LEAF_NODE(NODE) ((sg_fr_ptr)((unsigned long int) (NODE) & ~(0x1)))
|
||||
#define IS_SUBGOAL_LEAF_NODE(NODE) ((unsigned long int) TrNode_child(NODE) & 0x1)
|
||||
#define TAG_AS_ANSWER_LEAF_NODE(NODE) TrNode_parent(NODE) = (ans_node_ptr)((unsigned long int) TrNode_parent(NODE) | 0x1)
|
||||
#define UNTAG_ANSWER_LEAF_NODE(NODE) ((ans_node_ptr)((unsigned long int) (NODE) & ~(0x1)))
|
||||
#define IS_ANSWER_LEAF_NODE(NODE) ((unsigned long int) TrNode_parent(NODE) & 0x1)
|
||||
@ -139,14 +145,12 @@ static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames(tg_sol_fr_ptr, int);
|
||||
#define MAX_NODES_PER_BUCKET (MAX_NODES_PER_TRIE_LEVEL / 2)
|
||||
#define BASE_HASH_BUCKETS 64
|
||||
#define HASH_ENTRY(ENTRY, SEED) ((((unsigned long int) ENTRY) >> NumberOfLowTagBits) & (SEED))
|
||||
#ifdef GLOBAL_TRIE
|
||||
#define GLOBAL_TRIE_HASH_MARK ((Term) MakeTableVarTerm(MAX_TABLE_VARS))
|
||||
#define IS_GLOBAL_TRIE_HASH(NODE) (TrNode_entry(NODE) == GLOBAL_TRIE_HASH_MARK)
|
||||
#endif /* GLOBAL_TRIE */
|
||||
#define SUBGOAL_TRIE_HASH_MARK ((Term) MakeTableVarTerm(MAX_TABLE_VARS))
|
||||
#define IS_SUBGOAL_TRIE_HASH(NODE) (TrNode_entry(NODE) == SUBGOAL_TRIE_HASH_MARK)
|
||||
#define ANSWER_TRIE_HASH_MARK 0
|
||||
#define IS_ANSWER_TRIE_HASH(NODE) (TrNode_instr(NODE) == ANSWER_TRIE_HASH_MARK)
|
||||
#define GLOBAL_TRIE_HASH_MARK ((Term) MakeTableVarTerm(MAX_TABLE_VARS))
|
||||
#define IS_GLOBAL_TRIE_HASH(NODE) (TrNode_entry(NODE) == GLOBAL_TRIE_HASH_MARK)
|
||||
|
||||
#define HASH_TABLE_LOCK(NODE) ((((unsigned long int) (NODE)) >> 5) & (TABLE_LOCK_BUCKETS - 1))
|
||||
#define LOCK_TABLE(NODE) LOCK(GLOBAL_table_lock(HASH_TABLE_LOCK(NODE)))
|
||||
@ -660,14 +664,14 @@ static inline void abolish_incomplete_subgoals(choiceptr prune_cp) {
|
||||
#else
|
||||
ans_node_ptr node;
|
||||
SgFr_state(sg_fr) = ready;
|
||||
free_answer_trie_hash_chain(SgFr_hash_chain(sg_fr));
|
||||
free_answer_hash_chain(SgFr_hash_chain(sg_fr));
|
||||
SgFr_hash_chain(sg_fr) = NULL;
|
||||
SgFr_first_answer(sg_fr) = NULL;
|
||||
SgFr_last_answer(sg_fr) = NULL;
|
||||
node = TrNode_child(SgFr_answer_trie(sg_fr));
|
||||
TrNode_child(SgFr_answer_trie(sg_fr)) = NULL;
|
||||
UNLOCK(SgFr_lock(sg_fr));
|
||||
free_answer_trie_branch(node, TRAVERSE_POSITION_FIRST);
|
||||
free_answer_trie(node, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST);
|
||||
#endif /* INCOMPLETE_TABLING */
|
||||
}
|
||||
#ifdef LIMIT_TABLING
|
||||
|
@ -49,18 +49,6 @@ typedef struct table_entry {
|
||||
** global_trie_node, subgoal_trie_node and answer_trie_node **
|
||||
***********************************************************************/
|
||||
|
||||
#ifdef GLOBAL_TRIE
|
||||
typedef struct global_trie_node {
|
||||
Term entry;
|
||||
struct global_trie_node *parent;
|
||||
struct global_trie_node *child;
|
||||
struct global_trie_node *next;
|
||||
#ifdef TABLE_LOCK_AT_NODE_LEVEL
|
||||
lockvar lock;
|
||||
#endif /* TABLE_LOCK_AT_NODE_LEVEL */
|
||||
} *gt_node_ptr;
|
||||
#endif /* GLOBAL_TRIE */
|
||||
|
||||
typedef struct subgoal_trie_node {
|
||||
Term entry;
|
||||
struct subgoal_trie_node *parent;
|
||||
@ -85,6 +73,16 @@ typedef struct answer_trie_node {
|
||||
#endif /* TABLE_LOCK_AT_NODE_LEVEL */
|
||||
} *ans_node_ptr;
|
||||
|
||||
typedef struct global_trie_node {
|
||||
Term entry;
|
||||
struct global_trie_node *parent;
|
||||
struct global_trie_node *child;
|
||||
struct global_trie_node *next;
|
||||
#ifdef TABLE_LOCK_AT_NODE_LEVEL
|
||||
lockvar lock;
|
||||
#endif /* TABLE_LOCK_AT_NODE_LEVEL */
|
||||
} *gt_node_ptr;
|
||||
|
||||
#define TrNode_instr(X) ((X)->trie_instruction)
|
||||
#define TrNode_or_arg(X) ((X)->or_arg)
|
||||
#define TrNode_entry(X) ((X)->entry)
|
||||
@ -100,17 +98,6 @@ typedef struct answer_trie_node {
|
||||
** global_trie_hash, subgoal_trie_hash and answer_trie_hash **
|
||||
***********************************************************************/
|
||||
|
||||
#ifdef GLOBAL_TRIE
|
||||
typedef struct global_trie_hash {
|
||||
/* the first field is used for compatibility **
|
||||
** with the global_trie_node data structure */
|
||||
Term mark;
|
||||
int number_of_buckets;
|
||||
struct global_trie_node **buckets;
|
||||
int number_of_nodes;
|
||||
} *gt_hash_ptr;
|
||||
#endif /* GLOBAL_TRIE */
|
||||
|
||||
typedef struct subgoal_trie_hash {
|
||||
/* the first field is used for compatibility **
|
||||
** with the subgoal_trie_node data structure */
|
||||
@ -131,6 +118,15 @@ typedef struct answer_trie_hash {
|
||||
struct answer_trie_hash *next;
|
||||
} *ans_hash_ptr;
|
||||
|
||||
typedef struct global_trie_hash {
|
||||
/* the first field is used for compatibility **
|
||||
** with the global_trie_node data structure */
|
||||
Term mark;
|
||||
int number_of_buckets;
|
||||
struct global_trie_node **buckets;
|
||||
int number_of_nodes;
|
||||
} *gt_hash_ptr;
|
||||
|
||||
#define Hash_mark(X) ((X)->mark)
|
||||
#define Hash_num_buckets(X) ((X)->number_of_buckets)
|
||||
#define Hash_seed(X) ((X)->number_of_buckets - 1)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -773,18 +773,22 @@ static inline gt_node_ptr global_trie_check_insert_entry(gt_node_ptr parent_node
|
||||
|
||||
|
||||
/************************************************************************
|
||||
** subgoal_search_loop(_gt_(sub)term) **
|
||||
** subgoal_search(_global_trie)(_terms)_loop **
|
||||
************************************************************************/
|
||||
|
||||
#ifdef INCLUDE_SUBGOAL_SEARCH_LOOP
|
||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||
#ifdef GLOBAL_TRIE_FOR_TERMS
|
||||
static inline gt_node_ptr subgoal_search_loop_gt_term(Term t, int *subs_arity_ptr, CELL **stack_vars_ptr) {
|
||||
#elif GLOBAL_TRIE_FOR_SUBTERMS
|
||||
static inline gt_node_ptr subgoal_search_loop_gt_subterm(Term t, int *subs_arity_ptr, CELL **stack_vars_ptr, CELL *stack_terms) {
|
||||
#endif
|
||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
||||
static inline gt_node_ptr subgoal_search_global_trie_terms_loop(Term t, int *subs_arity_ptr, CELL **stack_vars_ptr, CELL *stack_terms) {
|
||||
#else
|
||||
static inline gt_node_ptr subgoal_search_global_trie_loop(Term t, int *subs_arity_ptr, CELL **stack_vars_ptr) {
|
||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
#else
|
||||
#ifdef MODE_TERMS_LOOP
|
||||
static inline sg_node_ptr subgoal_search_terms_loop(tab_ent_ptr tab_ent, sg_node_ptr current_node, Term t, int *subs_arity_ptr, CELL **stack_vars_ptr) {
|
||||
#else
|
||||
static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr current_node, Term t, int *subs_arity_ptr, CELL **stack_vars_ptr) {
|
||||
#endif /* MODE_TERMS_LOOP */
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||
/************************************************************************
|
||||
===========
|
||||
@ -830,13 +834,18 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||
int subs_arity = *subs_arity_ptr;
|
||||
CELL *stack_vars = *stack_vars_ptr;
|
||||
#if !defined(MODE_GLOBAL_TRIE_LOOP) || !defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
#if ! defined(MODE_GLOBAL_TRIE_LOOP) || ! defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
CELL *stack_terms = (CELL *) Yap_TrailTop;
|
||||
#endif /* ! MODE_GLOBAL_TRIE_LOOP || ! GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
CELL *stack_terms_limit = (CELL *) TR;
|
||||
AUX_STACK_CHECK_EXPAND(stack_terms, stack_terms_limit + 1); /* + 1 because initially we stiil haven't done any STACK_POP_DOWN */
|
||||
STACK_PUSH_UP(NULL, stack_terms);
|
||||
|
||||
#if defined(MODE_GLOBAL_TRIE_LOOP)
|
||||
/* for the global trie, it is safe to skip the IsVarTerm() and IsAtomOrIntTerm() tests in the first iteration */
|
||||
goto subgoal_search_loop_non_atomic;
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||
|
||||
do {
|
||||
if (IsVarTerm(t)) {
|
||||
if (IsTableVarTerm(t)) {
|
||||
@ -844,7 +853,7 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
|
||||
SUBGOAL_CHECK_INSERT_ENTRY(tab_ent, current_node, t);
|
||||
} else {
|
||||
if (subs_arity == MAX_TABLE_VARS)
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "subgoal_search_loop(_gt_(sub)term): MAX_TABLE_VARS exceeded");
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "subgoal_search_loop: MAX_TABLE_VARS exceeded");
|
||||
STACK_PUSH_UP(t, stack_vars);
|
||||
*((CELL *)t) = GLOBAL_table_var_enumerator(subs_arity);
|
||||
t = MakeTableVarTerm(subs_arity);
|
||||
@ -853,19 +862,23 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
|
||||
}
|
||||
} else if (IsAtomOrIntTerm(t)) {
|
||||
SUBGOAL_CHECK_INSERT_ENTRY(tab_ent, current_node, t);
|
||||
#if !defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE)
|
||||
#ifdef MODE_TERMS_LOOP
|
||||
} else {
|
||||
gt_node_ptr entry_node;
|
||||
#ifdef GLOBAL_TRIE_FOR_TERMS
|
||||
entry_node = subgoal_search_loop_gt_term(t, &subs_arity, &stack_vars);
|
||||
#elif GLOBAL_TRIE_FOR_SUBTERMS
|
||||
entry_node = subgoal_search_loop_gt_subterm(t, &subs_arity, &stack_vars, stack_terms);
|
||||
#endif
|
||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
||||
entry_node = subgoal_search_global_trie_terms_loop(t, &subs_arity, &stack_vars, stack_terms);
|
||||
#else
|
||||
entry_node = subgoal_search_global_trie_loop(t, &subs_arity, &stack_vars);
|
||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
current_node = subgoal_trie_check_insert_gt_entry(tab_ent, current_node, (Term) entry_node);
|
||||
}
|
||||
#else /* MODE_GLOBAL_TRIE_LOOP || ! GLOBAL_TRIE */
|
||||
#else /* ! MODE_TERMS_LOOP */
|
||||
} else
|
||||
#if defined(MODE_GLOBAL_TRIE_LOOP)
|
||||
/* for the global trie, it is safe to start here in the first iteration */
|
||||
subgoal_search_loop_non_atomic:
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
} else if (IsPairTerm(t)) {
|
||||
if (IsPairTerm(t)) {
|
||||
CELL *aux_pair = RepPair(t);
|
||||
if (aux_pair == PairTermMark) {
|
||||
t = STACK_POP_DOWN(stack_terms);
|
||||
@ -888,7 +901,7 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
|
||||
}
|
||||
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
} else if (current_node != GLOBAL_root_gt) {
|
||||
gt_node_ptr entry_node = subgoal_search_loop_gt_subterm(t, &subs_arity, &stack_vars, stack_terms);
|
||||
gt_node_ptr entry_node = subgoal_search_global_trie_terms_loop(t, &subs_arity, &stack_vars, stack_terms);
|
||||
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
} else {
|
||||
@ -905,16 +918,17 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
|
||||
}
|
||||
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
} else if (current_node != GLOBAL_root_gt) {
|
||||
gt_node_ptr entry_node = subgoal_search_loop_gt_subterm(t, &subs_arity, &stack_vars, stack_terms);
|
||||
gt_node_ptr entry_node = subgoal_search_global_trie_terms_loop(t, &subs_arity, &stack_vars, stack_terms);
|
||||
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
#else
|
||||
#else /* ! TRIE_COMPACT_PAIRS */
|
||||
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
} else if (current_node != GLOBAL_root_gt) {
|
||||
gt_node_ptr entry_node = subgoal_search_loop_gt_subterm(t, &subs_arity, &stack_vars, stack_terms);
|
||||
if (current_node != GLOBAL_root_gt) {
|
||||
gt_node_ptr entry_node = subgoal_search_global_trie_terms_loop(t, &subs_arity, &stack_vars, stack_terms);
|
||||
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
|
||||
} else
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
} else if (IsPairTerm(t)) {
|
||||
if (IsPairTerm(t)) {
|
||||
CELL *aux_pair = RepPair(t);
|
||||
SUBGOAL_CHECK_INSERT_ENTRY(tab_ent, current_node, AbsPair(NULL));
|
||||
AUX_STACK_CHECK_EXPAND(stack_terms, stack_terms_limit + 1);
|
||||
@ -942,9 +956,9 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
|
||||
SUBGOAL_CHECK_INSERT_ENTRY(tab_ent, current_node, AbsAppl((Term *)f));
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||
} else if (f == FunctorDBRef) {
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "subgoal_search_loop(_gt_(sub)term): unsupported type tag FunctorDBRef");
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "subgoal_search_loop: unsupported type tag FunctorDBRef");
|
||||
} else if (f == FunctorBigInt) {
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "subgoal_search_loop(_gt_(sub)term): unsupported type tag FunctorBigInt");
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "subgoal_search_loop: unsupported type tag FunctorBigInt");
|
||||
} else {
|
||||
int i;
|
||||
CELL *aux_appl = RepAppl(t);
|
||||
@ -954,9 +968,9 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
|
||||
STACK_PUSH_UP(Deref(aux_appl[i]), stack_terms);
|
||||
}
|
||||
} else {
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "subgoal_search_loop(_gt_(sub)term): unknown type tag");
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "subgoal_search_loop: unknown type tag");
|
||||
#endif /* MODE_TERMS_LOOP */
|
||||
}
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP + GLOBAL_TRIE + */
|
||||
t = STACK_POP_DOWN(stack_terms);
|
||||
} while (t);
|
||||
|
||||
@ -969,18 +983,22 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
|
||||
|
||||
|
||||
/************************************************************************
|
||||
** answer_search_loop(_gt_(sub)term) **
|
||||
** answer_search(_global_trie)(_terms)_loop **
|
||||
************************************************************************/
|
||||
|
||||
#ifdef INCLUDE_ANSWER_SEARCH_LOOP
|
||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||
#ifdef GLOBAL_TRIE_FOR_TERMS
|
||||
static inline gt_node_ptr answer_search_loop_gt_term(Term t, int *vars_arity_ptr) {
|
||||
#elif GLOBAL_TRIE_FOR_SUBTERMS
|
||||
static inline gt_node_ptr answer_search_loop_gt_subterm(Term t, int *vars_arity_ptr, CELL *stack_terms) {
|
||||
#endif
|
||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
||||
static inline gt_node_ptr answer_search_global_trie_terms_loop(Term t, int *vars_arity_ptr, CELL *stack_terms) {
|
||||
#else
|
||||
static inline gt_node_ptr answer_search_global_trie_loop(Term t, int *vars_arity_ptr) {
|
||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
#else
|
||||
#ifdef MODE_TERMS_LOOP
|
||||
static inline ans_node_ptr answer_search_terms_loop(sg_fr_ptr sg_fr, ans_node_ptr current_node, Term t, int *vars_arity_ptr) {
|
||||
#else
|
||||
static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr current_node, Term t, int *vars_arity_ptr) {
|
||||
#endif /* MODE_TERMS_LOOP */
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||
/************************************************************************
|
||||
===========
|
||||
@ -1015,7 +1033,7 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
|
||||
gt_node_ptr current_node = GLOBAL_root_gt;
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||
int vars_arity = *vars_arity_ptr;
|
||||
#if !defined(MODE_GLOBAL_TRIE_LOOP) || !defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
#if ! defined(MODE_GLOBAL_TRIE_LOOP) || ! defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
CELL *stack_terms = (CELL *) Yap_TrailTop;
|
||||
#endif /* ! MODE_GLOBAL_TRIE_LOOP || ! GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
CELL *stack_vars_base = (CELL *) TR;
|
||||
@ -1028,6 +1046,11 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
|
||||
AUX_STACK_CHECK_EXPAND(stack_terms, stack_terms_limit + 1); /* + 1 because initially we stiil haven't done any STACK_POP_DOWN */
|
||||
STACK_PUSH_UP(NULL, stack_terms);
|
||||
|
||||
#if defined(MODE_GLOBAL_TRIE_LOOP)
|
||||
/* for the global trie, it is safe to skip the IsVarTerm() and IsAtomOrIntTerm() tests in the first iteration */
|
||||
goto answer_search_loop_non_atomic;
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||
|
||||
do {
|
||||
if (IsVarTerm(t)) {
|
||||
t = Deref(t);
|
||||
@ -1036,7 +1059,7 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
|
||||
ANSWER_CHECK_INSERT_ENTRY(sg_fr, current_node, t, _trie_retry_val + in_pair);
|
||||
} else {
|
||||
if (vars_arity == MAX_TABLE_VARS)
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "answer_search_loop(_gt_(sub)term): MAX_TABLE_VARS exceeded");
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "answer_search_loop: MAX_TABLE_VARS exceeded");
|
||||
stack_vars_base[vars_arity] = t;
|
||||
*((CELL *)t) = GLOBAL_table_var_enumerator(vars_arity);
|
||||
t = MakeTableVarTerm(vars_arity);
|
||||
@ -1048,20 +1071,26 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
} else if (IsAtomOrIntTerm(t)) {
|
||||
ANSWER_CHECK_INSERT_ENTRY(sg_fr, current_node, t, _trie_retry_atom + in_pair);
|
||||
#if !defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE)
|
||||
} else {
|
||||
gt_node_ptr entry_node;
|
||||
#ifdef GLOBAL_TRIE_FOR_TERMS
|
||||
entry_node = answer_search_loop_gt_term(t, &vars_arity);
|
||||
#elif GLOBAL_TRIE_FOR_SUBTERMS
|
||||
entry_node = answer_search_loop_gt_subterm(t, &vars_arity, stack_terms);
|
||||
#endif
|
||||
current_node = answer_trie_check_insert_gt_entry(sg_fr, current_node, (Term) entry_node, _trie_retry_gterm + in_pair);
|
||||
}
|
||||
#else /* MODE_GLOBAL_TRIE_LOOP || ! GLOBAL_TRIE */
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
in_pair = 0;
|
||||
} else if (IsPairTerm(t)) {
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
#ifdef MODE_TERMS_LOOP
|
||||
} else {
|
||||
gt_node_ptr entry_node;
|
||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
||||
entry_node = answer_search_global_trie_terms_loop(t, &vars_arity, stack_terms);
|
||||
#else
|
||||
entry_node = answer_search_global_trie_loop(t, &vars_arity);
|
||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
current_node = answer_trie_check_insert_gt_entry(sg_fr, current_node, (Term) entry_node, _trie_retry_gterm + in_pair);
|
||||
#else /* ! MODE_TERMS_LOOP */
|
||||
} else
|
||||
#if defined(MODE_GLOBAL_TRIE_LOOP)
|
||||
/* for the global trie, it is safe to start here in the first iteration */
|
||||
answer_search_loop_non_atomic:
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
if (IsPairTerm(t)) {
|
||||
CELL *aux_pair = RepPair(t);
|
||||
if (aux_pair == PairTermMark) {
|
||||
t = STACK_POP_DOWN(stack_terms);
|
||||
@ -1085,7 +1114,7 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
|
||||
}
|
||||
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
} else if (current_node != GLOBAL_root_gt) {
|
||||
gt_node_ptr entry_node = answer_search_loop_gt_subterm(t, &vars_arity, stack_terms);
|
||||
gt_node_ptr entry_node = answer_search_global_trie_terms_loop(t, &vars_arity, stack_terms);
|
||||
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
} else {
|
||||
@ -1104,16 +1133,17 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
|
||||
}
|
||||
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
} else if (current_node != GLOBAL_root_gt) {
|
||||
gt_node_ptr entry_node = answer_search_loop_gt_subterm(t, &vars_arity, stack_terms);
|
||||
gt_node_ptr entry_node = answer_search_global_trie_terms_loop(t, &vars_arity, stack_terms);
|
||||
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
#else
|
||||
#else /* ! TRIE_COMPACT_PAIRS */
|
||||
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
} else if (current_node != GLOBAL_root_gt) {
|
||||
gt_node_ptr entry_node = answer_search_loop_gt_subterm(t, &vars_arity, stack_terms);
|
||||
if (current_node != GLOBAL_root_gt) {
|
||||
gt_node_ptr entry_node = answer_search_global_trie_terms_loop(t, &vars_arity, stack_terms);
|
||||
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
|
||||
} else
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
} else if (IsPairTerm(t)) {
|
||||
if (IsPairTerm(t)) {
|
||||
CELL *aux_pair = RepPair(t);
|
||||
ANSWER_CHECK_INSERT_ENTRY(sg_fr, current_node, AbsPair(NULL), _trie_retry_pair);
|
||||
AUX_STACK_CHECK_EXPAND(stack_terms, stack_terms_limit + 1);
|
||||
@ -1137,9 +1167,9 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
|
||||
ANSWER_CHECK_INSERT_ENTRY(sg_fr, current_node, li, _trie_retry_extension);
|
||||
ANSWER_CHECK_INSERT_ENTRY(sg_fr, current_node, AbsAppl((Term *)f), _trie_retry_longint);
|
||||
} else if (f == FunctorDBRef) {
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "answer_search_loop(_gt_(sub)term): unsupported type tag FunctorDBRef");
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "answer_search_loop: unsupported type tag FunctorDBRef");
|
||||
} else if (f == FunctorBigInt) {
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "answer_search_loop(_gt_(sub)term): unsupported type tag FunctorBigInt");
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "answer_search_loop: unsupported type tag FunctorBigInt");
|
||||
} else {
|
||||
int i;
|
||||
CELL *aux_appl = RepAppl(t);
|
||||
@ -1152,9 +1182,9 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
|
||||
in_pair = 0;
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
} else {
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "answer_search_loop(_gt_(sub)term): unknown type tag");
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "answer_search_loop: unknown type tag");
|
||||
#endif /* MODE_TERMS_LOOP */
|
||||
}
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP + GLOBAL_TRIE */
|
||||
t = STACK_POP_DOWN(stack_terms);
|
||||
} while (t);
|
||||
|
||||
@ -1215,10 +1245,10 @@ static inline CELL *load_answer_loop(ans_node_ptr current_node) {
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||
CELL *stack_vars_base = (CELL *) TR;
|
||||
#define stack_terms_limit (stack_vars_base + vars_arity)
|
||||
#if defined(TRIE_COMPACT_PAIRS) && (defined(MODE_GLOBAL_TRIE_LOOP) || !defined(GLOBAL_TRIE))
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
#define stack_terms_base ((CELL *) Yap_TrailTop)
|
||||
int stack_terms_pair_offset = 0;
|
||||
#endif /* TRIE_COMPACT_PAIRS && (MODE_GLOBAL_TRIE_LOOP || ! GLOBAL_TRIE) */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
Term t = TrNode_entry(current_node);
|
||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||
current_node = TrNode_parent(current_node);
|
||||
@ -1228,11 +1258,11 @@ static inline CELL *load_answer_loop(ans_node_ptr current_node) {
|
||||
|
||||
do {
|
||||
if (IsVarTerm(t)) {
|
||||
#if (!defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE)) || defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
#if ! defined(MODE_GLOBAL_TRIE_LOOP) || defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
if (t > VarIndexOfTableTerm(MAX_TABLE_VARS)) {
|
||||
stack_terms = load_substitution_loop((gt_node_ptr) t, &vars_arity, stack_terms);
|
||||
} else
|
||||
#endif /* (! MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE) || GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
#endif /* ! MODE_GLOBAL_TRIE_LOOP || GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
{ int var_index = VarIndexOfTableTerm(t);
|
||||
AUX_STACK_CHECK_EXPAND(stack_terms, stack_terms_limit - vars_arity + var_index + 1);
|
||||
if (var_index >= vars_arity) {
|
||||
@ -1246,7 +1276,6 @@ static inline CELL *load_answer_loop(ans_node_ptr current_node) {
|
||||
} else if (IsAtomOrIntTerm(t)) {
|
||||
AUX_STACK_CHECK_EXPAND(stack_terms, stack_terms_limit);
|
||||
STACK_PUSH_UP(t, stack_terms);
|
||||
#if defined(MODE_GLOBAL_TRIE_LOOP) || !defined(GLOBAL_TRIE)
|
||||
} else if (IsPairTerm(t)) {
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
if (t == CompactPairInit) {
|
||||
@ -1269,7 +1298,7 @@ static inline CELL *load_answer_loop(ans_node_ptr current_node) {
|
||||
STACK_PUSH_UP(TermNil, stack_terms);
|
||||
STACK_PUSH_UP(last, stack_terms);
|
||||
}
|
||||
#else
|
||||
#else /* ! TRIE_COMPACT_PAIRS */
|
||||
Term head = STACK_POP_DOWN(stack_terms);
|
||||
Term tail = STACK_POP_DOWN(stack_terms);
|
||||
t = MkPairTerm(head, tail);
|
||||
@ -1302,7 +1331,6 @@ static inline CELL *load_answer_loop(ans_node_ptr current_node) {
|
||||
}
|
||||
AUX_STACK_CHECK_EXPAND(stack_terms, stack_terms_limit);
|
||||
STACK_PUSH_UP(t, stack_terms);
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP || ! GLOBAL_TRIE */
|
||||
}
|
||||
t = TrNode_entry(current_node);
|
||||
current_node = TrNode_parent(current_node);
|
||||
|
@ -19,7 +19,7 @@
|
||||
------------------- --
|
||||
| heap ptr 1 | |
|
||||
------------------- |
|
||||
| ... | -- heap_arity (0 if GLOBAL_TRIE)
|
||||
| ... | -- heap_arity (0 if in global trie)
|
||||
------------------- |
|
||||
| heap ptr ha | |
|
||||
------------------- --
|
||||
@ -458,7 +458,7 @@
|
||||
|
||||
|
||||
PBOp(trie_do_var_in_pair, e)
|
||||
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
register ans_node_ptr node = (ans_node_ptr) PREG;
|
||||
register CELL *aux_stack = TOP_STACK;
|
||||
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
||||
@ -468,12 +468,12 @@
|
||||
aux_stack_var_in_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_var_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
PBOp(trie_trust_var_in_pair, e)
|
||||
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
register ans_node_ptr node = (ans_node_ptr) PREG;
|
||||
register CELL *aux_stack = (CELL *) (B + 1);
|
||||
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
||||
@ -484,12 +484,12 @@
|
||||
aux_stack_var_in_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_var_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
PBOp(trie_try_var_in_pair, e)
|
||||
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
register ans_node_ptr node = (ans_node_ptr) PREG;
|
||||
register CELL *aux_stack = TOP_STACK;
|
||||
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
||||
@ -500,12 +500,12 @@
|
||||
aux_stack_var_in_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_var_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
PBOp(trie_retry_var_in_pair, e)
|
||||
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
register ans_node_ptr node = (ans_node_ptr) PREG;
|
||||
register CELL *aux_stack = (CELL *) (B + 1);
|
||||
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
||||
@ -516,7 +516,7 @@
|
||||
aux_stack_var_in_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_var_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
@ -572,7 +572,7 @@
|
||||
|
||||
|
||||
PBOp(trie_do_val_in_pair, e)
|
||||
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
register ans_node_ptr node = (ans_node_ptr) PREG;
|
||||
register CELL *aux_stack = TOP_STACK;
|
||||
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
||||
@ -583,12 +583,12 @@
|
||||
aux_stack_val_in_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_val_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
PBOp(trie_trust_val_in_pair, e)
|
||||
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
register ans_node_ptr node = (ans_node_ptr) PREG;
|
||||
register CELL *aux_stack = (CELL *) (B + 1);
|
||||
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
||||
@ -600,12 +600,12 @@
|
||||
aux_stack_val_in_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_val_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
PBOp(trie_try_val_in_pair, e)
|
||||
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
register ans_node_ptr node = (ans_node_ptr) PREG;
|
||||
register CELL *aux_stack = TOP_STACK;
|
||||
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
||||
@ -617,12 +617,12 @@
|
||||
aux_stack_val_in_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_val_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
PBOp(trie_retry_val_in_pair, e)
|
||||
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
register ans_node_ptr node = (ans_node_ptr) PREG;
|
||||
register CELL *aux_stack = (CELL *) (B + 1);
|
||||
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
||||
@ -634,7 +634,7 @@
|
||||
aux_stack_val_in_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_val_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
@ -690,7 +690,7 @@
|
||||
|
||||
|
||||
PBOp(trie_do_atom_in_pair, e)
|
||||
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
register ans_node_ptr node = (ans_node_ptr) PREG;
|
||||
register CELL *aux_stack = TOP_STACK;
|
||||
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
||||
@ -700,12 +700,12 @@
|
||||
aux_stack_term_in_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_atom_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
PBOp(trie_trust_atom_in_pair, e)
|
||||
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
register ans_node_ptr node = (ans_node_ptr) PREG;
|
||||
register CELL *aux_stack = (CELL *) (B + 1);
|
||||
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
||||
@ -716,12 +716,12 @@
|
||||
aux_stack_term_in_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_atom_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
PBOp(trie_try_atom_in_pair, e)
|
||||
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
register ans_node_ptr node = (ans_node_ptr) PREG;
|
||||
register CELL *aux_stack = TOP_STACK;
|
||||
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
||||
@ -732,12 +732,12 @@
|
||||
aux_stack_term_in_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_atom_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
PBOp(trie_retry_atom_in_pair, e)
|
||||
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
||||
#ifdef TRIE_COMPACT_PAIRS
|
||||
register ans_node_ptr node = (ans_node_ptr) PREG;
|
||||
register CELL *aux_stack = (CELL *) (B + 1);
|
||||
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
||||
@ -748,7 +748,7 @@
|
||||
aux_stack_term_in_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_atom_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
@ -806,7 +806,7 @@
|
||||
aux_stack_new_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_null_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
@ -822,7 +822,7 @@
|
||||
aux_stack_new_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_null_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
@ -838,7 +838,7 @@
|
||||
aux_stack_new_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_null_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
@ -854,7 +854,7 @@
|
||||
aux_stack_new_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_null_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
@ -973,7 +973,7 @@
|
||||
aux_stack_appl_in_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_appl_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
@ -991,7 +991,7 @@
|
||||
aux_stack_appl_in_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_appl_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
@ -1009,7 +1009,7 @@
|
||||
aux_stack_appl_in_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_appl_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
@ -1027,7 +1027,7 @@
|
||||
aux_stack_appl_in_pair_instr();
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_appl_in_pair: invalid instruction");
|
||||
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
@ -1148,7 +1148,6 @@
|
||||
|
||||
|
||||
PBOp(trie_do_gterm, e)
|
||||
#ifdef GLOBAL_TRIE
|
||||
register ans_node_ptr node = (ans_node_ptr) PREG;
|
||||
register CELL *aux_stack = TOP_STACK;
|
||||
int heap_arity = 0;
|
||||
@ -1157,14 +1156,10 @@
|
||||
|
||||
TOP_STACK = exec_substitution((gt_node_ptr)TrNode_entry(node), aux_stack);
|
||||
next_instruction(subs_arity - 1 , node);
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_gterm: invalid instruction");
|
||||
#endif /* GLOBAL_TRIE */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
PBOp(trie_trust_gterm, e)
|
||||
#ifdef GLOBAL_TRIE
|
||||
register ans_node_ptr node = (ans_node_ptr) PREG;
|
||||
register CELL *aux_stack = (CELL *) (B + 1);
|
||||
int heap_arity = 0;
|
||||
@ -1174,14 +1169,10 @@
|
||||
pop_trie_node();
|
||||
TOP_STACK = exec_substitution((gt_node_ptr)TrNode_entry(node), aux_stack);
|
||||
next_instruction(subs_arity - 1 , node);
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_gterm: invalid instruction");
|
||||
#endif /* GLOBAL_TRIE */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
PBOp(trie_try_gterm, e)
|
||||
#ifdef GLOBAL_TRIE
|
||||
register ans_node_ptr node = (ans_node_ptr) PREG;
|
||||
register CELL *aux_stack = TOP_STACK;
|
||||
int heap_arity = 0;
|
||||
@ -1191,14 +1182,10 @@
|
||||
store_trie_node(TrNode_next(node));
|
||||
TOP_STACK = exec_substitution((gt_node_ptr)TrNode_entry(node), aux_stack);
|
||||
next_instruction(subs_arity - 1, node);
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_gterm: invalid instruction");
|
||||
#endif /* GLOBAL_TRIE */
|
||||
ENDPBOp();
|
||||
|
||||
|
||||
PBOp(trie_retry_gterm, e)
|
||||
#ifdef GLOBAL_TRIE
|
||||
register ans_node_ptr node = (ans_node_ptr) PREG;
|
||||
register CELL *aux_stack = (CELL *) (B + 1);
|
||||
int heap_arity = 0;
|
||||
@ -1208,7 +1195,4 @@
|
||||
restore_trie_node(TrNode_next(node));
|
||||
TOP_STACK = exec_substitution((gt_node_ptr)TrNode_entry(node), aux_stack);
|
||||
next_instruction(subs_arity - 1, node);
|
||||
#else
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_gterm: invalid instruction");
|
||||
#endif /* GLOBAL_TRIE */
|
||||
ENDPBOp();
|
||||
|
@ -22,6 +22,7 @@
|
||||
%% or_statistics/2 %%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
%% should match with code in OPTYap/opt.preds.c
|
||||
or_statistics(total_memory,[BytesInUse,BytesAllocated]) :-
|
||||
'$c_get_optyap_statistics'(0,BytesInUse,BytesAllocated).
|
||||
or_statistics(or_frames,[BytesInUse,StructsInUse]) :-
|
||||
@ -37,6 +38,7 @@ or_statistics(query_goal_answer_frames,[BytesInUse,StructsInUse]) :-
|
||||
%% opt_statistics/2 %%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
%% should match with code in OPTYap/opt.preds.c
|
||||
opt_statistics(total_memory,[BytesInUse,BytesAllocated]) :-
|
||||
'$c_get_optyap_statistics'(0,BytesInUse,BytesAllocated).
|
||||
opt_statistics(table_entries,[BytesInUse,StructsInUse]) :-
|
||||
|
Reference in New Issue
Block a user