adptation of the memory allocator based on pages to work with threads
This commit is contained in:
parent
f3f9c75cf7
commit
1dcc8bd393
23
C/threads.c
23
C/threads.c
@ -187,10 +187,30 @@ thread_die(int wid, int always_die)
|
|||||||
tab_ent = TabEnt_next(tab_ent);
|
tab_ent = TabEnt_next(tab_ent);
|
||||||
}
|
}
|
||||||
FREE_DEPENDENCY_FRAME(LOCAL_top_dep_fr);
|
FREE_DEPENDENCY_FRAME(LOCAL_top_dep_fr);
|
||||||
#endif /* TABLING */
|
LOCAL_top_dep_fr = NULL;
|
||||||
|
#ifdef USE_PAGES_MALLOC
|
||||||
|
DETACH_PAGES(_pages_void);
|
||||||
|
DETACH_PAGES(_pages_tab_ent);
|
||||||
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
|
DETACH_PAGES(_pages_sg_ent);
|
||||||
|
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
||||||
|
DETACH_PAGES(_pages_sg_fr);
|
||||||
|
DETACH_PAGES(_pages_dep_fr);
|
||||||
|
DETACH_PAGES(_pages_sg_node);
|
||||||
|
DETACH_PAGES(_pages_sg_hash);
|
||||||
|
DETACH_PAGES(_pages_ans_node);
|
||||||
|
DETACH_PAGES(_pages_ans_hash);
|
||||||
|
#if defined(THREADS_FULL_SHARING)
|
||||||
|
DETACH_PAGES(_pages_ans_ref_node);
|
||||||
|
#endif /* THREADS_FULL_SHARING */
|
||||||
|
DETACH_PAGES(_pages_gt_node);
|
||||||
|
DETACH_PAGES(_pages_gt_hash);
|
||||||
|
#endif /* USE_PAGES_MALLOC */
|
||||||
#ifdef OUTPUT_THREADS_TABLING
|
#ifdef OUTPUT_THREADS_TABLING
|
||||||
fclose(LOCAL_thread_output);
|
fclose(LOCAL_thread_output);
|
||||||
#endif /* OUTPUT_THREADS_TABLING */
|
#endif /* OUTPUT_THREADS_TABLING */
|
||||||
|
#endif /* TABLING */
|
||||||
|
GLOBAL_NOfThreads--;
|
||||||
if (!always_die) {
|
if (!always_die) {
|
||||||
/* called by thread itself */
|
/* called by thread itself */
|
||||||
GLOBAL_ThreadsTotalTime += Yap_cputime();
|
GLOBAL_ThreadsTotalTime += Yap_cputime();
|
||||||
@ -222,6 +242,7 @@ setup_engine(int myworker_id, int init_thread)
|
|||||||
Yap_ReleasePreAllocCodeSpace(Yap_PreAllocCodeSpace());
|
Yap_ReleasePreAllocCodeSpace(Yap_PreAllocCodeSpace());
|
||||||
/* I exist */
|
/* I exist */
|
||||||
GLOBAL_NOfThreadsCreated++;
|
GLOBAL_NOfThreadsCreated++;
|
||||||
|
GLOBAL_NOfThreads++;
|
||||||
DEBUG_TLOCK_ACCESS(2, myworker_id);
|
DEBUG_TLOCK_ACCESS(2, myworker_id);
|
||||||
pthread_mutex_unlock(&(REMOTE_ThreadHandle(myworker_id).tlock));
|
pthread_mutex_unlock(&(REMOTE_ThreadHandle(myworker_id).tlock));
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
|
@ -43,14 +43,22 @@
|
|||||||
#ifdef USE_PAGES_MALLOC
|
#ifdef USE_PAGES_MALLOC
|
||||||
#define STRUCTS_PER_PAGE(STR_TYPE) ((Yap_page_size - ADJUST_SIZE(sizeof(struct page_header))) / ADJUST_SIZE(sizeof(STR_TYPE)))
|
#define STRUCTS_PER_PAGE(STR_TYPE) ((Yap_page_size - ADJUST_SIZE(sizeof(struct page_header))) / ADJUST_SIZE(sizeof(STR_TYPE)))
|
||||||
|
|
||||||
#define INIT_PAGES(PG, STR_TYPE) \
|
#define INIT_GLOBAL_PAGE_ENTRY(PG,STR_TYPE) \
|
||||||
INIT_LOCK(Pg_lock(PG)); \
|
INIT_LOCK(PgEnt_lock(PG)); \
|
||||||
Pg_pg_alloc(PG) = 0; \
|
PgEnt_pages_in_use(PG) = 0; \
|
||||||
Pg_str_in_use(PG) = 0; \
|
PgEnt_strs_in_use(PG) = 0; \
|
||||||
Pg_str_per_pg(PG) = STRUCTS_PER_PAGE(STR_TYPE); \
|
PgEnt_strs_per_page(PG) = STRUCTS_PER_PAGE(STR_TYPE); \
|
||||||
Pg_free_pg(PG) = NULL
|
PgEnt_first(PG) = NULL; \
|
||||||
|
PgEnt_last(PG) = NULL;
|
||||||
|
#define INIT_LOCAL_PAGE_ENTRY(PG,STR_TYPE) \
|
||||||
|
PgEnt_pages_in_use(PG) = 0; \
|
||||||
|
PgEnt_strs_in_use(PG) = 0; \
|
||||||
|
PgEnt_strs_per_page(PG) = STRUCTS_PER_PAGE(STR_TYPE); \
|
||||||
|
PgEnt_first(PG) = NULL; \
|
||||||
|
PgEnt_last(PG) = NULL;
|
||||||
#else
|
#else
|
||||||
#define INIT_PAGES(PG, STR_TYPE) Pg_str_in_use(PG) = 0
|
#define INIT_GLOBAL_PAGE_ENTRY(PG,STR_TYPE) PgEnt_strs_in_use(PG) = 0
|
||||||
|
#define INIT_LOCAL_PAGE_ENTRY(PG,STR_TYPE) PgEnt_strs_in_use(PG) = 0
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
|
|
||||||
|
|
||||||
@ -63,39 +71,37 @@ void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* global data related to memory management */
|
/* global data related to memory management */
|
||||||
INIT_PAGES(GLOBAL_pages_void, void *);
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_alloc, void *);
|
||||||
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_void, void *);
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
INIT_PAGES(GLOBAL_pages_tab_ent, struct table_entry);
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_tab_ent, struct table_entry);
|
||||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
INIT_PAGES(GLOBAL_pages_sg_ent, struct subgoal_entry);
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_sg_ent, struct subgoal_entry);
|
||||||
#endif
|
#endif
|
||||||
#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING)
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_sg_fr, struct subgoal_frame);
|
||||||
INIT_PAGES(GLOBAL_pages_sg_fr, struct subgoal_frame);
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_dep_fr, struct dependency_frame);
|
||||||
INIT_PAGES(GLOBAL_pages_dep_fr, struct dependency_frame);
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_sg_node, struct subgoal_trie_node);
|
||||||
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_sg_hash, struct subgoal_trie_hash);
|
||||||
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_ans_node, struct answer_trie_node);
|
||||||
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_ans_hash, struct answer_trie_hash);
|
||||||
|
#if defined(THREADS_FULL_SHARING)
|
||||||
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_ans_ref_node, struct answer_ref_node);
|
||||||
#endif
|
#endif
|
||||||
#if !defined(THREADS_NO_SHARING)
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_gt_node, struct global_trie_node);
|
||||||
INIT_PAGES(GLOBAL_pages_sg_node, struct subgoal_trie_node);
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_gt_hash, struct global_trie_hash);
|
||||||
INIT_PAGES(GLOBAL_pages_sg_hash, struct subgoal_trie_hash);
|
|
||||||
#endif
|
|
||||||
#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING)
|
|
||||||
INIT_PAGES(GLOBAL_pages_ans_node, struct answer_trie_node);
|
|
||||||
INIT_PAGES(GLOBAL_pages_ans_hash, struct answer_trie_hash);
|
|
||||||
#endif
|
|
||||||
INIT_PAGES(GLOBAL_pages_gt_node, struct global_trie_node);
|
|
||||||
INIT_PAGES(GLOBAL_pages_gt_hash, struct global_trie_hash);
|
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
INIT_PAGES(GLOBAL_pages_or_fr, struct or_frame);
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_or_fr, struct or_frame);
|
||||||
INIT_PAGES(GLOBAL_pages_qg_sol_fr, struct query_goal_solution_frame);
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_qg_sol_fr, struct query_goal_solution_frame);
|
||||||
INIT_PAGES(GLOBAL_pages_qg_ans_fr, struct query_goal_answer_frame);
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_qg_ans_fr, struct query_goal_answer_frame);
|
||||||
#endif /* YAPOR */
|
#ifdef TABLING
|
||||||
#if defined(YAPOR) && defined(TABLING)
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_susp_fr, struct suspension_frame);
|
||||||
INIT_PAGES(GLOBAL_pages_susp_fr, struct suspension_frame);
|
#endif
|
||||||
#endif /* YAPOR && TABLING */
|
|
||||||
#ifdef TABLING_INNER_CUTS
|
#ifdef TABLING_INNER_CUTS
|
||||||
INIT_PAGES(GLOBAL_pages_tg_sol_fr, struct table_subgoal_solution_frame);
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_tg_sol_fr, struct table_subgoal_solution_frame);
|
||||||
INIT_PAGES(GLOBAL_pages_tg_ans_fr, struct table_subgoal_answer_frame);
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_tg_ans_fr, struct table_subgoal_answer_frame);
|
||||||
#endif /* TABLING_INNER_CUTS */
|
#endif
|
||||||
|
#endif /* YAPOR */
|
||||||
|
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
/* global static data */
|
/* global static data */
|
||||||
@ -136,7 +142,7 @@ void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop
|
|||||||
|
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
/* global data related to tabling */
|
/* global data related to tabling */
|
||||||
new_global_trie_node(GLOBAL_root_gt, 0, NULL, NULL, NULL);
|
GLOBAL_root_gt = NULL;
|
||||||
GLOBAL_root_tab_ent = NULL;
|
GLOBAL_root_tab_ent = NULL;
|
||||||
#ifdef LIMIT_TABLING
|
#ifdef LIMIT_TABLING
|
||||||
if (max_table_size)
|
if (max_table_size)
|
||||||
@ -171,30 +177,26 @@ void Yap_init_local_optyap_data(int wid) {
|
|||||||
|
|
||||||
#if defined(TABLING) && (defined(YAPOR) || defined(THREADS))
|
#if defined(TABLING) && (defined(YAPOR) || defined(THREADS))
|
||||||
/* local data related to memory management */
|
/* local data related to memory management */
|
||||||
#if defined(YAPOR)
|
#ifdef YAPOR
|
||||||
REMOTE_next_free_ans_node(wid) = NULL;
|
REMOTE_next_free_ans_node(wid) = NULL;
|
||||||
#elif defined(THREADS)
|
#elif THREADS
|
||||||
INIT_PAGES(REMOTE_pages_void(wid), void *);
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_void(wid), void *);
|
||||||
INIT_PAGES(REMOTE_pages_sg_fr(wid), struct subgoal_frame);
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_tab_ent(wid), struct table_entry);
|
||||||
INIT_PAGES(REMOTE_pages_dep_fr(wid), struct dependency_frame);
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
#if defined(THREADS_NO_SHARING)
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_sg_ent(wid), struct subgoal_entry);
|
||||||
INIT_PAGES(REMOTE_pages_sg_node(wid), struct subgoal_trie_node);
|
|
||||||
INIT_PAGES(REMOTE_pages_sg_hash(wid), struct subgoal_trie_hash);
|
|
||||||
#elif defined(THREADS_SUBGOAL_SHARING) || defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
|
||||||
REMOTE_next_free_sg_node(wid) = NULL;
|
|
||||||
REMOTE_next_free_sg_hash(wid) = NULL;
|
|
||||||
#endif
|
|
||||||
#if defined(THREADS_NO_SHARING) || defined(THREADS_SUBGOAL_SHARING)
|
|
||||||
INIT_PAGES(REMOTE_pages_ans_node(wid), struct answer_trie_node);
|
|
||||||
INIT_PAGES(REMOTE_pages_ans_hash(wid), struct answer_trie_hash);
|
|
||||||
#elif defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
|
||||||
REMOTE_next_free_ans_node(wid) = NULL;
|
|
||||||
REMOTE_next_free_ans_hash(wid) = NULL;
|
|
||||||
#endif
|
#endif
|
||||||
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_sg_fr(wid), struct subgoal_frame);
|
||||||
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_dep_fr(wid), struct dependency_frame);
|
||||||
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_sg_node(wid), struct subgoal_trie_node);
|
||||||
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_sg_hash(wid), struct subgoal_trie_hash);
|
||||||
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_ans_node(wid), struct answer_trie_node);
|
||||||
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_ans_hash(wid), struct answer_trie_hash);
|
||||||
#if defined(THREADS_FULL_SHARING)
|
#if defined(THREADS_FULL_SHARING)
|
||||||
INIT_PAGES(REMOTE_pages_ans_ref_node(wid), struct answer_ref_node);
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_ans_ref_node(wid), struct answer_ref_node);
|
||||||
|
#endif
|
||||||
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_gt_node(wid), struct global_trie_node);
|
||||||
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_gt_hash(wid), struct global_trie_hash);
|
||||||
#endif
|
#endif
|
||||||
#endif /* YAPOR - THREADS */
|
|
||||||
#endif /* TABLING && (YAPOR || THREADS) */
|
#endif /* TABLING && (YAPOR || THREADS) */
|
||||||
|
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
@ -214,6 +216,7 @@ void Yap_init_local_optyap_data(int wid) {
|
|||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
/* local data related to tabling */
|
/* local data related to tabling */
|
||||||
REMOTE_top_sg_fr(wid) = NULL;
|
REMOTE_top_sg_fr(wid) = NULL;
|
||||||
|
REMOTE_top_dep_fr(wid) = NULL;
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
REMOTE_top_dep_fr(wid) = GLOBAL_root_dep_fr;
|
REMOTE_top_dep_fr(wid) = GLOBAL_root_dep_fr;
|
||||||
Set_REMOTE_top_cp_on_stack(wid, (choiceptr) LOCAL_LocalBase); /* ??? */
|
Set_REMOTE_top_cp_on_stack(wid, (choiceptr) LOCAL_LocalBase); /* ??? */
|
||||||
@ -258,6 +261,8 @@ void Yap_init_root_frames(void) {
|
|||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
|
/* root global trie node */
|
||||||
|
new_global_trie_node(GLOBAL_root_gt, 0, NULL, NULL, NULL);
|
||||||
/* root dependency frame */
|
/* root dependency frame */
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
DepFr_cons_cp(GLOBAL_root_dep_fr) = B; /* with YAPOR, at that point, LOCAL_top_dep_fr shouldn't be the same as GLOBAL_root_dep_fr ? */
|
DepFr_cons_cp(GLOBAL_root_dep_fr) = B; /* with YAPOR, at that point, LOCAL_top_dep_fr shouldn't be the same as GLOBAL_root_dep_fr ? */
|
||||||
|
@ -40,348 +40,443 @@ extern int Yap_page_size;
|
|||||||
#define ADJUST_SIZE_TO_PAGE(SIZE) ((SIZE) - (SIZE) % Yap_page_size + Yap_page_size)
|
#define ADJUST_SIZE_TO_PAGE(SIZE) ((SIZE) - (SIZE) % Yap_page_size + Yap_page_size)
|
||||||
#define PAGE_HEADER(STR) (pg_hd_ptr)((unsigned long int)STR - (unsigned long int)STR % Yap_page_size)
|
#define PAGE_HEADER(STR) (pg_hd_ptr)((unsigned long int)STR - (unsigned long int)STR % Yap_page_size)
|
||||||
#define STRUCT_NEXT(STR) ((STR)->next)
|
#define STRUCT_NEXT(STR) ((STR)->next)
|
||||||
|
|
||||||
#define UPDATE_STATS(STAT, VALUE) STAT += VALUE
|
#define UPDATE_STATS(STAT, VALUE) STAT += VALUE
|
||||||
|
|
||||||
|
#ifdef YAPOR
|
||||||
|
#define LOCK_PAGE_ENTRY(PG_ENT) LOCK(PgEnt_lock(PG_ENT))
|
||||||
|
#define UNLOCK_PAGE_ENTRY(PG_ENT) UNLOCK(PgEnt_lock(PG_ENT))
|
||||||
|
#else
|
||||||
|
#define LOCK_PAGE_ENTRY(PG_ENT)
|
||||||
|
#define UNLOCK_PAGE_ENTRY(PG_ENT)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_SYSTEM_MALLOC
|
#ifdef USE_SYSTEM_MALLOC
|
||||||
/**************************************************************************************
|
/*******************************************************************************************
|
||||||
** USE_SYSTEM_MALLOC **
|
** USE_SYSTEM_MALLOC **
|
||||||
**************************************************************************************/
|
*******************************************************************************************/
|
||||||
#define ALLOC_BLOCK(STR, SIZE, STR_TYPE) \
|
#define ALLOC_BLOCK(STR, SIZE, STR_TYPE) \
|
||||||
if ((STR = (STR_TYPE *) malloc(SIZE)) == NULL) \
|
if ((STR = (STR_TYPE *) malloc(SIZE)) == NULL) \
|
||||||
Yap_Error(FATAL_ERROR, TermNil, "ALLOC_BLOCK: malloc error")
|
Yap_Error(FATAL_ERROR, TermNil, "ALLOC_BLOCK: malloc error")
|
||||||
#define FREE_BLOCK(STR) \
|
#define FREE_BLOCK(STR) \
|
||||||
free(STR)
|
free(STR)
|
||||||
#else
|
#else
|
||||||
/**************************************************************************************
|
/*******************************************************************************************
|
||||||
** ! USE_SYSTEM_MALLOC **
|
** ! USE_SYSTEM_MALLOC **
|
||||||
**************************************************************************************/
|
*******************************************************************************************/
|
||||||
#define ALLOC_BLOCK(STR, SIZE, STR_TYPE) \
|
#define ALLOC_BLOCK(STR, SIZE, STR_TYPE) \
|
||||||
{ char *block_ptr; \
|
{ char *block_ptr; \
|
||||||
if ((block_ptr = Yap_AllocCodeSpace(SIZE + sizeof(CELL))) != NULL) \
|
if ((block_ptr = Yap_AllocCodeSpace(SIZE + sizeof(CELL))) != NULL) \
|
||||||
*block_ptr = 'y'; \
|
*block_ptr = 'y'; \
|
||||||
else if ((block_ptr = (char *) malloc(SIZE + sizeof(CELL))) != NULL) \
|
else if ((block_ptr = (char *) malloc(SIZE + sizeof(CELL))) != NULL) \
|
||||||
*block_ptr = 'm'; \
|
*block_ptr = 'm'; \
|
||||||
else \
|
else \
|
||||||
Yap_Error(FATAL_ERROR, TermNil, "ALLOC_BLOCK: malloc error"); \
|
Yap_Error(FATAL_ERROR, TermNil, "ALLOC_BLOCK: malloc error"); \
|
||||||
block_ptr += sizeof(CELL); \
|
block_ptr += sizeof(CELL); \
|
||||||
STR = (STR_TYPE *) block_ptr; \
|
STR = (STR_TYPE *) block_ptr; \
|
||||||
}
|
}
|
||||||
#define FREE_BLOCK(STR) \
|
#define FREE_BLOCK(STR) \
|
||||||
{ char *block_ptr = (char *)(STR) - sizeof(CELL); \
|
{ char *block_ptr = (char *)(STR) - sizeof(CELL); \
|
||||||
if (block_ptr[0] == 'y') \
|
if (block_ptr[0] == 'y') \
|
||||||
Yap_FreeCodeSpace(block_ptr); \
|
Yap_FreeCodeSpace(block_ptr); \
|
||||||
else \
|
else \
|
||||||
free(block_ptr); \
|
free(block_ptr); \
|
||||||
}
|
}
|
||||||
#endif /******************************************************************************/
|
#endif /***********************************************************************************/
|
||||||
#define INIT_BUCKETS(BUCKET_PTR, NUM_BUCKETS) \
|
|
||||||
{ int i; void **init_bucket_ptr; \
|
#define INIT_BUCKETS(BUCKET_PTR, NUM_BUCKETS) \
|
||||||
init_bucket_ptr = (void **) BUCKET_PTR; \
|
{ int i; void **init_bucket_ptr; \
|
||||||
for (i = NUM_BUCKETS; i != 0; i--) \
|
init_bucket_ptr = (void **) BUCKET_PTR; \
|
||||||
*init_bucket_ptr++ = NULL; \
|
for (i = NUM_BUCKETS; i != 0; i--) \
|
||||||
|
*init_bucket_ptr++ = NULL; \
|
||||||
}
|
}
|
||||||
#define ALLOC_BUCKETS(BUCKET_PTR, NUM_BUCKETS) \
|
#define ALLOC_BUCKETS(BUCKET_PTR, NUM_BUCKETS) \
|
||||||
{ void **alloc_bucket_ptr; \
|
{ void **alloc_bucket_ptr; \
|
||||||
ALLOC_BLOCK(alloc_bucket_ptr, NUM_BUCKETS * sizeof(void *), void *); \
|
ALLOC_BLOCK(alloc_bucket_ptr, NUM_BUCKETS * sizeof(void *), void *); \
|
||||||
INIT_BUCKETS(alloc_bucket_ptr, NUM_BUCKETS); \
|
INIT_BUCKETS(alloc_bucket_ptr, NUM_BUCKETS); \
|
||||||
BUCKET_PTR = (void *) alloc_bucket_ptr; \
|
BUCKET_PTR = (void *) alloc_bucket_ptr; \
|
||||||
}
|
}
|
||||||
#define FREE_BUCKETS(BUCKET_PTR) FREE_BLOCK(BUCKET_PTR)
|
#define FREE_BUCKETS(BUCKET_PTR) FREE_BLOCK(BUCKET_PTR)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef USE_PAGES_MALLOC
|
#ifndef USE_PAGES_MALLOC
|
||||||
/**************************************************************************************
|
/*******************************************************************************************
|
||||||
** ! USE_PAGES_MALLOC **
|
** ! USE_PAGES_MALLOC **
|
||||||
**************************************************************************************/
|
*******************************************************************************************/
|
||||||
#define ALLOC_STRUCT(STR, STR_TYPE, STR_PAGES, VOID_PAGES) \
|
#define GET_FREE_STRUCT(STR, STR_TYPE, PG_ENT, EXTRA_PG_ENT) \
|
||||||
LOCK(Pg_lock(STR_PAGES)); \
|
LOCK_PAGE_ENTRY(PG_ENT); \
|
||||||
UPDATE_STATS(Pg_str_in_use(STR_PAGES), 1); \
|
UPDATE_STATS(PgEnt_strs_in_use(PG_ENT), 1); \
|
||||||
UNLOCK(Pg_lock(STR_PAGES)); \
|
UNLOCK_PAGE_ENTRY(PG_ENT); \
|
||||||
ALLOC_BLOCK(STR, sizeof(STR_TYPE), STR_TYPE)
|
ALLOC_BLOCK(STR, sizeof(STR_TYPE), STR_TYPE)
|
||||||
#define LOCAL_NEXT_ALLOC_STRUCT(STR, LOCAL_STR, STR_TYPE, STR_PAGES, VOID_PAGES) \
|
#define GET_NEXT_FREE_STRUCT(LOCAL_STR, STR, STR_TYPE, PG_ENT) \
|
||||||
ALLOC_STRUCT(STR, STR_TYPE, STR_PAGES, VOID_PAGES)
|
GET_FREE_STRUCT(STR, STR_TYPE, PG_ENT, ___NOT_USED___)
|
||||||
#define FREE_STRUCT(STR, STR_TYPE, STR_PAGES, VOID_PAGES) \
|
#define PUT_FREE_STRUCT(STR, STR_TYPE, PG_ENT) \
|
||||||
LOCK(Pg_lock(STR_PAGES)); \
|
LOCK_PAGE_ENTRY(PG_ENT); \
|
||||||
UPDATE_STATS(Pg_str_in_use(STR_PAGES), -1); \
|
UPDATE_STATS(PgEnt_strs_in_use(PG_ENT), -1); \
|
||||||
UNLOCK(Pg_lock(STR_PAGES)); \
|
UNLOCK_PAGE_ENTRY(PG_ENT); \
|
||||||
FREE_BLOCK(STR)
|
FREE_BLOCK(STR)
|
||||||
#else
|
#else
|
||||||
/**************************************************************************************
|
/*******************************************************************************************
|
||||||
** USE_PAGES_MALLOC && ! LIMIT_TABLING **
|
** USE_PAGES_MALLOC **
|
||||||
**************************************************************************************/
|
*******************************************************************************************/
|
||||||
#ifndef LIMIT_TABLING
|
#define MOVE_PAGES(FROM_PG_ENT, TO_PG_ENT) \
|
||||||
#define ALLOC_STRUCT_TEST_PAGE if
|
if (PgEnt_first(TO_PG_ENT)) { \
|
||||||
#define ALLOC_STRUCT_RECOVER_SPACE(PG_HD, STR_PAGES, VOID_PAGES)
|
PgHd_next(PgEnt_last(TO_PG_ENT)) = PgEnt_first(FROM_PG_ENT); \
|
||||||
|
PgHd_previous(PgEnt_first(FROM_PG_ENT)) = PgEnt_last(TO_PG_ENT); \
|
||||||
|
} else \
|
||||||
|
PgEnt_first(TO_PG_ENT) = PgEnt_first(FROM_PG_ENT); \
|
||||||
|
PgEnt_last(TO_PG_ENT) = PgEnt_last(FROM_PG_ENT); \
|
||||||
|
UPDATE_STATS(PgEnt_pages_in_use(TO_PG_ENT), PgEnt_pages_in_use(FROM_PG_ENT)); \
|
||||||
|
UPDATE_STATS(PgEnt_strs_in_use(TO_PG_ENT), PgEnt_strs_in_use(FROM_PG_ENT)); \
|
||||||
|
PgEnt_first(FROM_PG_ENT) = PgEnt_last(FROM_PG_ENT) = NULL; \
|
||||||
|
PgEnt_pages_in_use(FROM_PG_ENT) = PgEnt_strs_in_use(FROM_PG_ENT) = 0
|
||||||
|
|
||||||
|
#define DETACH_PAGES(_PG_ENT) \
|
||||||
|
if (PgEnt_first(LOCAL##_PG_ENT)) { \
|
||||||
|
LOCK(PgEnt_lock(GLOBAL##_PG_ENT)); \
|
||||||
|
MOVE_PAGES(LOCAL##_PG_ENT, GLOBAL##_PG_ENT); \
|
||||||
|
UNLOCK(PgEnt_lock(GLOBAL##_PG_ENT)); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ATTACH_PAGES(_PG_ENT) \
|
||||||
|
if (PgEnt_first(GLOBAL##_PG_ENT)) { \
|
||||||
|
MOVE_PAGES(GLOBAL##_PG_ENT, LOCAL##_PG_ENT); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GET_PAGE_FIRST_LEVEL(PG_HD) GET_ALLOC_PAGE(PG_HD)
|
||||||
|
#define GET_ALLOC_PAGE_NEXT_LEVEL(PG_HD) GET_VOID_PAGE(PG_HD)
|
||||||
|
#define GET_VOID_PAGE_NEXT_LEVEL(PG_HD)
|
||||||
|
/*******************************************************************************************
|
||||||
|
#define GET_PAGE_FIRST_LEVEL(PG_HD) GET_VOID_PAGE(PG_HD)
|
||||||
|
#define GET_VOID_PAGE_NEXT_LEVEL(PG_HD) GET_ALLOC_PAGE(PG_HD)
|
||||||
|
#define GET_ALLOC_PAGE_NEXT_LEVEL(PG_HD)
|
||||||
|
*******************************************************************************************/
|
||||||
|
|
||||||
|
#define GET_ALLOC_PAGE(PG_HD) \
|
||||||
|
LOCK(PgEnt_lock(GLOBAL_pages_alloc)); \
|
||||||
|
if ((PG_HD = PgEnt_first(GLOBAL_pages_alloc)) == NULL) { \
|
||||||
|
UNLOCK(PgEnt_lock(GLOBAL_pages_alloc)); \
|
||||||
|
GET_ALLOC_PAGE_NEXT_LEVEL(PG_HD); \
|
||||||
|
} else { \
|
||||||
|
PgEnt_first(GLOBAL_pages_alloc) = (pg_hd_ptr)(((void *)PG_HD) + Yap_page_size); \
|
||||||
|
if (PgEnt_first(GLOBAL_pages_alloc) == PgEnt_last(GLOBAL_pages_alloc)) \
|
||||||
|
PgEnt_first(GLOBAL_pages_alloc) = NULL; \
|
||||||
|
UNLOCK(PgEnt_lock(GLOBAL_pages_alloc)); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GET_VOID_PAGE(PG_HD) \
|
||||||
|
LOCK(PgEnt_lock(GLOBAL_pages_void)); \
|
||||||
|
if ((PG_HD = PgEnt_first(GLOBAL_pages_void)) == NULL) { \
|
||||||
|
UNLOCK(PgEnt_lock(GLOBAL_pages_void)); \
|
||||||
|
GET_VOID_PAGE_NEXT_LEVEL(PG_HD); \
|
||||||
|
} else { \
|
||||||
|
if ((PgEnt_first(GLOBAL_pages_void) = PgHd_next(PG_HD)) == NULL) \
|
||||||
|
PgEnt_last(GLOBAL_pages_void) = NULL; \
|
||||||
|
UNLOCK(PgEnt_lock(GLOBAL_pages_void)); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define PUT_PAGE(PG_HD, PG_ENT) \
|
||||||
|
if ((PgHd_next(PG_HD) = PgEnt_first(PG_ENT)) == NULL) \
|
||||||
|
PgEnt_last(PG_ENT) = PG_HD; \
|
||||||
|
else \
|
||||||
|
PgHd_previous(PgHd_next(PG_HD)) = PG_HD; \
|
||||||
|
PgEnt_first(PG_ENT) = PG_HD; \
|
||||||
|
UPDATE_STATS(PgEnt_pages_in_use(PG_ENT), 1)
|
||||||
|
|
||||||
|
#define PUT_VOID_PAGE(PG_HD, PG_ENT) \
|
||||||
|
if ((PgHd_next(PG_HD) = PgEnt_first(PG_ENT)) == NULL) \
|
||||||
|
PgEnt_last(PG_ENT) = PG_HD; \
|
||||||
|
PgEnt_first(PG_ENT) = PG_HD
|
||||||
|
|
||||||
|
#ifdef THREADS
|
||||||
|
#define GET_FREE_PAGE(PG_HD) \
|
||||||
|
if ((PG_HD = PgEnt_first(LOCAL_pages_void)) == NULL) { \
|
||||||
|
GET_PAGE_FIRST_LEVEL(PG_HD); \
|
||||||
|
} else { \
|
||||||
|
if ((PgEnt_first(LOCAL_pages_void) = PgHd_next(PG_HD)) == NULL) \
|
||||||
|
PgEnt_last(LOCAL_pages_void) = NULL; \
|
||||||
|
}
|
||||||
|
#define PUT_FREE_PAGE(PG_HD) \
|
||||||
|
PUT_VOID_PAGE(PG_HD, LOCAL_pages_void)
|
||||||
#else
|
#else
|
||||||
/**************************************************************************************
|
#define GET_FREE_PAGE(PG_HD) \
|
||||||
** USE_PAGES_MALLOC && LIMIT_TABLING **
|
GET_PAGE_FIRST_LEVEL(PG_HD)
|
||||||
**************************************************************************************/
|
#define PUT_FREE_PAGE(PG_HD) \
|
||||||
#define ALLOC_STRUCT_TEST_PAGE while
|
PUT_VOID_PAGE(PG_HD, GLOBAL_pages_void)
|
||||||
#define ALLOC_STRUCT_RECOVER_SPACE(PG_HD, STR_PAGES, VOID_PAGES) \
|
|
||||||
if (Pg_free_pg(VOID_PAGES) == NULL && \
|
|
||||||
GLOBAL_max_pages == Pg_pg_alloc(VOID_PAGES)) { \
|
|
||||||
sg_fr_ptr sg_fr = GLOBAL_check_sg_fr; \
|
|
||||||
UNLOCK(Pg_lock(VOID_PAGES)); \
|
|
||||||
do { \
|
|
||||||
if (sg_fr) \
|
|
||||||
sg_fr = SgFr_next(sg_fr); \
|
|
||||||
else \
|
|
||||||
sg_fr = GLOBAL_first_sg_fr; \
|
|
||||||
if (sg_fr == NULL) \
|
|
||||||
Yap_Error(FATAL_ERROR, TermNil, "no space left (RECOVER_SPACE)"); \
|
|
||||||
/* see function 'InteractSIGINT' in file 'sysbits.c' */ \
|
|
||||||
/* Yap_Error(PURE_ABORT, TermNil, ""); */ \
|
|
||||||
/* restore_absmi_regs(&Yap_standard_regs); */ \
|
|
||||||
/* siglongjmp (LOCAL_RestartEnv, 1); */ \
|
|
||||||
if (SgFr_first_answer(sg_fr) && \
|
|
||||||
SgFr_first_answer(sg_fr) != SgFr_answer_trie(sg_fr)) { \
|
|
||||||
SgFr_state(sg_fr) = ready; \
|
|
||||||
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(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(VOID_PAGES) == Pg_free_pg(STR_PAGES)); \
|
|
||||||
GLOBAL_check_sg_fr = sg_fr; \
|
|
||||||
LOCK(Pg_lock(STR_PAGES)); \
|
|
||||||
PG_HD = Pg_free_pg(STR_PAGES); \
|
|
||||||
} else
|
|
||||||
#endif
|
#endif
|
||||||
/**************************************************************************************
|
|
||||||
** USE_PAGES_MALLOC **
|
#define INIT_PAGE(PG_HD, STR_TYPE, PG_ENT) \
|
||||||
**************************************************************************************/
|
PgHd_strs_in_use(PG_HD) = 0; \
|
||||||
#define ALLOC_VOID_PAGES(PG_HD, VOID_PAGES) \
|
PgHd_previous(PG_HD) = NULL; \
|
||||||
{ int i, shmid; \
|
PgHd_next(PG_HD) = NULL; \
|
||||||
pg_hd_ptr aux_pg_hd; \
|
PgHd_first_str(PG_HD) = NULL; \
|
||||||
if ((shmid = shmget(IPC_PRIVATE, SHMMAX, SHM_R|SHM_W)) == -1) \
|
PgHd_alloc_area(PG_HD) = (void *) (PG_HD + 1); \
|
||||||
Yap_Error(FATAL_ERROR, TermNil, "shmget error (ALLOC_VOID_PAGES)"); \
|
PgHd_alloc_area(PG_HD) += sizeof(STR_TYPE) * PgEnt_strs_per_page(PG_ENT)
|
||||||
if ((PG_HD = (pg_hd_ptr) shmat(shmid, NULL, 0)) == (void *) -1) \
|
|
||||||
Yap_Error(FATAL_ERROR, TermNil, "shmat error (ALLOC_VOID_PAGES)"); \
|
/*******************************************************************************************
|
||||||
if (shmctl(shmid, IPC_RMID, 0) != 0) \
|
#define OLD_INIT_PAGE(PG_HD, STR_TYPE, PG_ENT) \
|
||||||
Yap_Error(FATAL_ERROR, TermNil, "shmctl error (ALLOC_VOID_PAGES)"); \
|
{ int i; \
|
||||||
aux_pg_hd = (pg_hd_ptr)(((void *)PG_HD) + Yap_page_size); \
|
STR_TYPE *aux_str; \
|
||||||
Pg_free_pg(VOID_PAGES) = aux_pg_hd; \
|
PgHd_strs_in_use(PG_HD) = 0; \
|
||||||
for (i = 2; i < SHMMAX / Yap_page_size; i++) { \
|
PgHd_previous(PG_HD) = NULL; \
|
||||||
PgHd_next(aux_pg_hd) = (pg_hd_ptr)(((void *)aux_pg_hd) + Yap_page_size); \
|
PgHd_next(PG_HD) = NULL; \
|
||||||
aux_pg_hd = PgHd_next(aux_pg_hd); \
|
PgHd_alloc_area(PG_HD) = NULL; \
|
||||||
} \
|
PgHd_first_str(PG_HD) = (void *) (PG_HD + 1); \
|
||||||
PgHd_next(aux_pg_hd) = NULL; \
|
aux_str = (STR_TYPE *) PgHd_first_str(PG_HD); \
|
||||||
UPDATE_STATS(Pg_pg_alloc(VOID_PAGES), SHMMAX / Yap_page_size); \
|
for (i = 1; i < PgEnt_strs_per_page(PG_ENT); i++) { \
|
||||||
UPDATE_STATS(Pg_str_in_use(VOID_PAGES), 1); \
|
STRUCT_NEXT(aux_str) = aux_str + 1; \
|
||||||
|
aux_str++; \
|
||||||
|
} \
|
||||||
|
STRUCT_NEXT(aux_str) = NULL; \
|
||||||
|
}
|
||||||
|
*******************************************************************************************/
|
||||||
|
|
||||||
|
#define ALLOC_SPACE() \
|
||||||
|
LOCK(PgEnt_lock(GLOBAL_pages_alloc)); \
|
||||||
|
if (PgEnt_first(GLOBAL_pages_alloc) == NULL) { \
|
||||||
|
int shmid; \
|
||||||
|
void *mem_block; \
|
||||||
|
if ((shmid = shmget(IPC_PRIVATE, SHMMAX, SHM_R|SHM_W)) == -1) \
|
||||||
|
Yap_Error(FATAL_ERROR, TermNil, "shmget error (ALLOC_PAGE)"); \
|
||||||
|
if ((mem_block = shmat(shmid, NULL, 0)) == (void *) -1) \
|
||||||
|
Yap_Error(FATAL_ERROR, TermNil, "shmat error (ALLOC_PAGE)"); \
|
||||||
|
if (shmctl(shmid, IPC_RMID, 0) != 0) \
|
||||||
|
Yap_Error(FATAL_ERROR, TermNil, "shmctl error (ALLOC_PAGE)"); \
|
||||||
|
PgEnt_first(GLOBAL_pages_alloc) = (pg_hd_ptr)(mem_block + Yap_page_size); \
|
||||||
|
PgEnt_last(GLOBAL_pages_alloc) = (pg_hd_ptr)(mem_block + SHMMAX); \
|
||||||
|
UPDATE_STATS(PgEnt_pages_in_use(GLOBAL_pages_alloc), SHMMAX / Yap_page_size); \
|
||||||
|
} \
|
||||||
|
UNLOCK(PgEnt_lock(GLOBAL_pages_alloc))
|
||||||
|
|
||||||
|
#ifdef LIMIT_TABLING
|
||||||
|
#define RECOVER_ALLOC_SPACE(PG_ENT, EXTRA_PG_ENT) \
|
||||||
|
if (GLOBAL_max_pages == PgEnt_pages_in_use(GLOBAL_pages_alloc)) { \
|
||||||
|
sg_fr_ptr sg_fr = GLOBAL_check_sg_fr; \
|
||||||
|
do { \
|
||||||
|
if (sg_fr) \
|
||||||
|
sg_fr = SgFr_next(sg_fr); \
|
||||||
|
else \
|
||||||
|
sg_fr = GLOBAL_first_sg_fr; \
|
||||||
|
if (sg_fr == NULL) \
|
||||||
|
Yap_Error(FATAL_ERROR, TermNil, "no space left (RECOVER_SPACE)"); \
|
||||||
|
/* see function 'InteractSIGINT' in file 'sysbits.c' */ \
|
||||||
|
/* Yap_Error(PURE_ABORT, TermNil, ""); */ \
|
||||||
|
/* restore_absmi_regs(&Yap_standard_regs); */ \
|
||||||
|
/* siglongjmp (LOCAL_RestartEnv, 1); */ \
|
||||||
|
if (SgFr_first_answer(sg_fr) && \
|
||||||
|
SgFr_first_answer(sg_fr) != SgFr_answer_trie(sg_fr)) { \
|
||||||
|
SgFr_state(sg_fr) = ready; \
|
||||||
|
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(TrNode_child(SgFr_answer_trie(sg_fr)), \
|
||||||
|
TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST); \
|
||||||
|
TrNode_child(SgFr_answer_trie(sg_fr)) = NULL; \
|
||||||
|
} \
|
||||||
|
} while (PgEnt_first(GLOBAL_pages_void) == PgEnt_first(PG_ENT)); \
|
||||||
|
GLOBAL_check_sg_fr = sg_fr; \
|
||||||
|
} else { \
|
||||||
|
ALLOC_SPACE(); \
|
||||||
|
}
|
||||||
|
#elif THREADS
|
||||||
|
#define RECOVER_ALLOC_SPACE(PG_ENT, EXTRA_PG_ENT) \
|
||||||
|
LOCK(PgEnt_lock(EXTRA_PG_ENT)); \
|
||||||
|
if (PgEnt_first(EXTRA_PG_ENT)) { \
|
||||||
|
MOVE_PAGES(EXTRA_PG_ENT, PG_ENT); \
|
||||||
|
UNLOCK(PgEnt_lock(EXTRA_PG_ENT)); \
|
||||||
|
} else { \
|
||||||
|
UNLOCK(PgEnt_lock(EXTRA_PG_ENT)); \
|
||||||
|
ALLOC_SPACE(); \
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define RECOVER_ALLOC_SPACE(PG_ENT, EXTRA_PG_ENT) \
|
||||||
|
ALLOC_SPACE()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TEST_GET_FREE_PAGE(PG_HD, STR_TYPE, PG_ENT, EXTRA_PG_ENT) \
|
||||||
|
while (PG_HD == NULL) { \
|
||||||
|
UNLOCK_PAGE_ENTRY(PG_ENT); \
|
||||||
|
GET_FREE_PAGE(PG_HD); \
|
||||||
|
if (PG_HD) { \
|
||||||
|
INIT_PAGE(PG_HD, STR_TYPE, PG_ENT); \
|
||||||
|
LOCK_PAGE_ENTRY(PG_ENT); \
|
||||||
|
PUT_PAGE(PG_HD, PG_ENT); \
|
||||||
|
} else { \
|
||||||
|
RECOVER_ALLOC_SPACE(PG_ENT, EXTRA_PG_ENT); \
|
||||||
|
LOCK_PAGE_ENTRY(PG_ENT); \
|
||||||
|
PG_HD = PgEnt_first(PG_ENT); \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define INIT_PAGE(PG_HD, STR_TYPE, STR_PAGES) \
|
#define GET_FREE_STRUCT(STR, STR_TYPE, PG_ENT, EXTRA_PG_ENT) \
|
||||||
{ int i; \
|
{ pg_hd_ptr pg_hd; \
|
||||||
STR_TYPE *aux_str; \
|
LOCK_PAGE_ENTRY(PG_ENT); \
|
||||||
PgHd_str_in_use(PG_HD) = 0; \
|
pg_hd = PgEnt_first(PG_ENT); \
|
||||||
PgHd_previous(PG_HD) = NULL; \
|
TEST_GET_FREE_PAGE(pg_hd, STR_TYPE, PG_ENT, EXTRA_PG_ENT); \
|
||||||
PgHd_next(PG_HD) = NULL; \
|
if (PgHd_alloc_area(pg_hd)) { \
|
||||||
PgHd_free_str(PG_HD) = (void *) (PG_HD + 1); \
|
STR = ((STR_TYPE *) PgHd_alloc_area(pg_hd)) - 1; \
|
||||||
aux_str = (STR_TYPE *) PgHd_free_str(PG_HD); \
|
if (STR == (STR_TYPE *) (pg_hd + 1)) \
|
||||||
for (i = 1; i < Pg_str_per_pg(STR_PAGES); i++) { \
|
PgHd_alloc_area(pg_hd) = NULL; \
|
||||||
STRUCT_NEXT(aux_str) = aux_str + 1; \
|
else \
|
||||||
aux_str++; \
|
PgHd_alloc_area(pg_hd) = (void *) STR; \
|
||||||
} \
|
} else { \
|
||||||
STRUCT_NEXT(aux_str) = NULL; \
|
STR = (STR_TYPE *) PgHd_first_str(pg_hd); \
|
||||||
}
|
PgHd_first_str(pg_hd) = (void *) STRUCT_NEXT(STR); \
|
||||||
|
} \
|
||||||
#define ALLOC_STRUCT_TEST_ALLOC_PAGE(PG_HD, STR_TYPE, STR_PAGES, VOID_PAGES) \
|
if (PgHd_alloc_area(pg_hd) == NULL && PgHd_first_str(pg_hd) == NULL) { \
|
||||||
ALLOC_STRUCT_TEST_PAGE (PG_HD == NULL) { /* if / while */ \
|
if ((PgEnt_first(PG_ENT) = PgHd_next(pg_hd)) == NULL) \
|
||||||
UNLOCK(Pg_lock(STR_PAGES)); \
|
PgEnt_last(PG_ENT) = NULL; \
|
||||||
LOCK(Pg_lock(VOID_PAGES)); \
|
else \
|
||||||
/* if (...) { ... */ \
|
PgHd_previous(PgHd_next(pg_hd)) = NULL; \
|
||||||
ALLOC_STRUCT_RECOVER_SPACE(PG_HD, STR_PAGES, VOID_PAGES) \
|
} \
|
||||||
/* } else */ \
|
UPDATE_STATS(PgHd_strs_in_use(pg_hd), 1); \
|
||||||
{ \
|
UPDATE_STATS(PgEnt_strs_in_use(PG_ENT), 1); \
|
||||||
PG_HD = Pg_free_pg(VOID_PAGES); \
|
UNLOCK_PAGE_ENTRY(PG_ENT); \
|
||||||
if (PG_HD == NULL) { \
|
|
||||||
ALLOC_VOID_PAGES(PG_HD, VOID_PAGES); \
|
|
||||||
} else { \
|
|
||||||
Pg_free_pg(VOID_PAGES) = PgHd_next(PG_HD); \
|
|
||||||
UPDATE_STATS(Pg_str_in_use(VOID_PAGES), 1); \
|
|
||||||
} \
|
|
||||||
UNLOCK(Pg_lock(VOID_PAGES)); \
|
|
||||||
INIT_PAGE(PG_HD, STR_TYPE, STR_PAGES); \
|
|
||||||
LOCK(Pg_lock(STR_PAGES)); \
|
|
||||||
if ((PgHd_next(PG_HD) = Pg_free_pg(STR_PAGES)) != NULL) \
|
|
||||||
PgHd_previous(PgHd_next(PG_HD)) = PG_HD; \
|
|
||||||
Pg_free_pg(STR_PAGES) = PG_HD; \
|
|
||||||
UPDATE_STATS(Pg_pg_alloc(STR_PAGES), 1); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ALLOC_STRUCT(STR, STR_TYPE, STR_PAGES, VOID_PAGES) \
|
|
||||||
{ pg_hd_ptr pg_hd; \
|
|
||||||
LOCK(Pg_lock(STR_PAGES)); \
|
|
||||||
pg_hd = Pg_free_pg(STR_PAGES); \
|
|
||||||
ALLOC_STRUCT_TEST_ALLOC_PAGE(pg_hd, STR_TYPE, STR_PAGES, VOID_PAGES); \
|
|
||||||
STR = (STR_TYPE *) PgHd_free_str(pg_hd); \
|
|
||||||
if ((PgHd_free_str(pg_hd) = (void *) STRUCT_NEXT(STR)) == NULL) \
|
|
||||||
if ((Pg_free_pg(STR_PAGES) = PgHd_next(pg_hd)) != NULL) \
|
|
||||||
PgHd_previous(PgHd_next(pg_hd)) = NULL; \
|
|
||||||
UPDATE_STATS(PgHd_str_in_use(pg_hd), 1); \
|
|
||||||
UPDATE_STATS(Pg_str_in_use(STR_PAGES), 1); \
|
|
||||||
UNLOCK(Pg_lock(STR_PAGES)); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LOCAL_NEXT_ALLOC_STRUCT(STR, LOCAL_STR, STR_TYPE, STR_PAGES, VOID_PAGES) \
|
/*******************************************************************************************
|
||||||
STR = LOCAL_STR; \
|
#define OLD_GET_FREE_STRUCT(STR, STR_TYPE, PG_ENT, EXTRA_PG_ENT) \
|
||||||
if (STR == NULL) { \
|
{ pg_hd_ptr pg_hd; \
|
||||||
pg_hd_ptr pg_hd; \
|
LOCK_PAGE_ENTRY(PG_ENT); \
|
||||||
LOCK(Pg_lock(STR_PAGES)); \
|
pg_hd = PgEnt_first(PG_ENT); \
|
||||||
pg_hd = Pg_free_pg(STR_PAGES); \
|
TEST_GET_FREE_PAGE(pg_hd, STR_TYPE, PG_ENT, EXTRA_PG_ENT); \
|
||||||
ALLOC_STRUCT_TEST_ALLOC_PAGE(pg_hd, STR_TYPE, STR_PAGES, VOID_PAGES); \
|
STR = (STR_TYPE *) PgHd_first_str(pg_hd); \
|
||||||
if ((Pg_free_pg(STR_PAGES) = PgHd_next(pg_hd)) != NULL) \
|
if ((PgHd_first_str(pg_hd) = (void *) STRUCT_NEXT(STR)) == NULL) { \
|
||||||
PgHd_previous(PgHd_next(pg_hd)) = NULL; \
|
if ((PgEnt_first(PG_ENT) = PgHd_next(pg_hd)) == NULL) \
|
||||||
UPDATE_STATS(Pg_str_in_use(STR_PAGES), -PgHd_str_in_use(pg_hd)); \
|
PgEnt_last(PG_ENT) = NULL; \
|
||||||
UPDATE_STATS(Pg_str_in_use(STR_PAGES), Pg_str_per_pg(STR_PAGES)); \
|
else \
|
||||||
UNLOCK(Pg_lock(STR_PAGES)); \
|
PgHd_previous(PgHd_next(pg_hd)) = NULL; \
|
||||||
STR = (STR_TYPE *) PgHd_free_str(pg_hd); \
|
} \
|
||||||
PgHd_free_str(pg_hd) = NULL; \
|
UPDATE_STATS(PgHd_strs_in_use(pg_hd), 1); \
|
||||||
PgHd_str_in_use(pg_hd) = Pg_str_per_pg(STR_PAGES); \
|
UPDATE_STATS(PgEnt_strs_in_use(PG_ENT), 1); \
|
||||||
} \
|
UNLOCK_PAGE_ENTRY(PG_ENT); \
|
||||||
|
}
|
||||||
|
*******************************************************************************************/
|
||||||
|
|
||||||
|
#define GET_NEXT_FREE_STRUCT(LOCAL_STR, STR, STR_TYPE, PG_ENT) \
|
||||||
|
STR = LOCAL_STR; \
|
||||||
|
if (STR == NULL) { \
|
||||||
|
pg_hd_ptr pg_hd; \
|
||||||
|
LOCK_PAGE_ENTRY(PG_ENT); \
|
||||||
|
pg_hd = PgEnt_first(PG_ENT); \
|
||||||
|
TEST_GET_FREE_PAGE(pg_hd, STR_TYPE, PG_ENT, ___NOT_USED___); \
|
||||||
|
STR = (STR_TYPE *) PgHd_first_str(pg_hd); \
|
||||||
|
PgHd_first_str(pg_hd) = NULL; \
|
||||||
|
PgHd_strs_in_use(pg_hd) = PgEnt_strs_per_page(PG_ENT); \
|
||||||
|
if ((PgEnt_first(PG_ENT) = PgHd_next(pg_hd)) == NULL) \
|
||||||
|
PgEnt_last(PG_ENT) = NULL; \
|
||||||
|
else \
|
||||||
|
PgHd_previous(PgHd_next(pg_hd)) = NULL; \
|
||||||
|
UPDATE_STATS(PgEnt_strs_in_use(PG_ENT), -PgHd_strs_in_use(pg_hd)); \
|
||||||
|
UPDATE_STATS(PgEnt_strs_in_use(PG_ENT), PgEnt_strs_per_page(PG_ENT)); \
|
||||||
|
UNLOCK_PAGE_ENTRY(PG_ENT); \
|
||||||
|
} \
|
||||||
LOCAL_STR = STRUCT_NEXT(STR)
|
LOCAL_STR = STRUCT_NEXT(STR)
|
||||||
|
|
||||||
#define FREE_PAGE(PG_HD, VOID_PAGES) \
|
#define PUT_FREE_STRUCT(STR, STR_TYPE, PG_ENT) \
|
||||||
LOCK(Pg_lock(VOID_PAGES)); \
|
{ pg_hd_ptr pg_hd; \
|
||||||
PgHd_next(PG_HD) = Pg_free_pg(VOID_PAGES); \
|
pg_hd = PAGE_HEADER(STR); \
|
||||||
Pg_free_pg(VOID_PAGES) = PG_HD; \
|
LOCK_PAGE_ENTRY(PG_ENT); \
|
||||||
UPDATE_STATS(Pg_str_in_use(VOID_PAGES), -1); \
|
UPDATE_STATS(PgEnt_strs_in_use(PG_ENT), -1); \
|
||||||
UNLOCK(Pg_lock(VOID_PAGES))
|
if (--PgHd_strs_in_use(pg_hd) == 0) { \
|
||||||
|
UPDATE_STATS(PgEnt_pages_in_use(PG_ENT), -1); \
|
||||||
#define FREE_STRUCT(STR, STR_TYPE, STR_PAGES, VOID_PAGES) \
|
if (PgHd_previous(pg_hd)) { \
|
||||||
{ pg_hd_ptr pg_hd; \
|
if ((PgHd_next(PgHd_previous(pg_hd)) = PgHd_next(pg_hd)) == NULL) \
|
||||||
pg_hd = PAGE_HEADER(STR); \
|
PgEnt_last(PG_ENT) = PgHd_previous(pg_hd); \
|
||||||
LOCK(Pg_lock(STR_PAGES)); \
|
else \
|
||||||
UPDATE_STATS(Pg_str_in_use(STR_PAGES), -1); \
|
PgHd_previous(PgHd_next(pg_hd)) = PgHd_previous(pg_hd); \
|
||||||
if (--PgHd_str_in_use(pg_hd) == 0) { \
|
} else { \
|
||||||
UPDATE_STATS(Pg_pg_alloc(STR_PAGES), -1); \
|
if ((PgEnt_first(PG_ENT) = PgHd_next(pg_hd)) == NULL) \
|
||||||
if (PgHd_previous(pg_hd)) { \
|
PgEnt_last(PG_ENT) = NULL; \
|
||||||
if ((PgHd_next(PgHd_previous(pg_hd)) = PgHd_next(pg_hd)) != NULL) \
|
else \
|
||||||
PgHd_previous(PgHd_next(pg_hd)) = PgHd_previous(pg_hd); \
|
PgHd_previous(PgHd_next(pg_hd)) = NULL; \
|
||||||
} else { \
|
} \
|
||||||
if ((Pg_free_pg(STR_PAGES) = PgHd_next(pg_hd)) != NULL) \
|
UNLOCK_PAGE_ENTRY(PG_ENT); \
|
||||||
PgHd_previous(PgHd_next(pg_hd)) = NULL; \
|
LOCK_PAGE_ENTRY(GLOBAL_pages_void); \
|
||||||
} \
|
PUT_FREE_PAGE(pg_hd); \
|
||||||
UNLOCK(Pg_lock(STR_PAGES)); \
|
UNLOCK_PAGE_ENTRY(GLOBAL_pages_void); \
|
||||||
FREE_PAGE(pg_hd, VOID_PAGES); \
|
} else { \
|
||||||
} else { \
|
STRUCT_NEXT(STR) = (STR_TYPE *) PgHd_first_str(pg_hd); \
|
||||||
if ((STRUCT_NEXT(STR) = (STR_TYPE *) PgHd_free_str(pg_hd)) == NULL) { \
|
if (PgHd_alloc_area(pg_hd) == NULL && PgHd_first_str(pg_hd) == NULL) { \
|
||||||
PgHd_previous(pg_hd) = NULL; \
|
PgHd_next(pg_hd) = NULL; \
|
||||||
if ((PgHd_next(pg_hd) = Pg_free_pg(STR_PAGES)) != NULL) \
|
if ((PgHd_previous(pg_hd) = PgEnt_last(PG_ENT)) != NULL) \
|
||||||
PgHd_previous(PgHd_next(pg_hd)) = pg_hd; \
|
PgHd_next(PgHd_previous(pg_hd)) = pg_hd; \
|
||||||
Pg_free_pg(STR_PAGES) = pg_hd; \
|
PgEnt_last(PG_ENT) = pg_hd; \
|
||||||
} \
|
} \
|
||||||
PgHd_free_str(pg_hd) = (void *) STR; \
|
PgHd_first_str(pg_hd) = (void *) STR; \
|
||||||
UNLOCK(Pg_lock(STR_PAGES)); \
|
UNLOCK_PAGE_ENTRY(PG_ENT); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
#endif /******************************************************************************/
|
#endif /***********************************************************************************/
|
||||||
|
|
||||||
|
#ifdef THREADS
|
||||||
#define ALLOC_TABLE_ENTRY(STR) ALLOC_STRUCT(STR, struct table_entry, GLOBAL_pages_tab_ent, GLOBAL_pages_void)
|
#define ALLOC_STRUCT(STR, STR_TYPE, _PG_ENT) \
|
||||||
#define FREE_TABLE_ENTRY(STR) FREE_STRUCT(STR, struct table_entry, GLOBAL_pages_tab_ent, GLOBAL_pages_void)
|
GET_FREE_STRUCT(STR, STR_TYPE, LOCAL##_PG_ENT, GLOBAL##_PG_ENT)
|
||||||
|
#define FREE_STRUCT(STR, STR_TYPE, _PG_ENT) \
|
||||||
#define ALLOC_SUBGOAL_ENTRY(STR) ALLOC_STRUCT(STR, struct subgoal_entry, GLOBAL_pages_sg_ent, GLOBAL_pages_void)
|
PUT_FREE_STRUCT(STR, STR_TYPE, LOCAL##_PG_ENT)
|
||||||
#define FREE_SUBGOAL_ENTRY(STR) FREE_STRUCT(STR, struct subgoal_entry, GLOBAL_pages_sg_ent, GLOBAL_pages_void)
|
|
||||||
|
|
||||||
#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING)
|
|
||||||
#define ALLOC_SUBGOAL_FRAME(STR) ALLOC_STRUCT(STR, struct subgoal_frame, GLOBAL_pages_sg_fr, GLOBAL_pages_void)
|
|
||||||
#define FREE_SUBGOAL_FRAME(STR) FREE_STRUCT(STR, struct subgoal_frame, GLOBAL_pages_sg_fr, GLOBAL_pages_void)
|
|
||||||
#else
|
#else
|
||||||
#define ALLOC_SUBGOAL_FRAME(STR) ALLOC_STRUCT(STR, struct subgoal_frame, LOCAL_pages_sg_fr, LOCAL_pages_void)
|
#define ALLOC_STRUCT(STR, STR_TYPE, _PG_ENT) \
|
||||||
#define FREE_SUBGOAL_FRAME(STR) FREE_STRUCT(STR, struct subgoal_frame, LOCAL_pages_sg_fr, LOCAL_pages_void)
|
GET_FREE_STRUCT(STR, STR_TYPE, GLOBAL##_PG_ENT, ___NOT_USED___)
|
||||||
|
#define FREE_STRUCT(STR, STR_TYPE, _PG_ENT) \
|
||||||
|
PUT_FREE_STRUCT(STR, STR_TYPE, GLOBAL##_PG_ENT)
|
||||||
#endif
|
#endif
|
||||||
|
#define ALLOC_NEXT_STRUCT(LOCAL_STR, STR, STR_TYPE, _PG_ENT) \
|
||||||
|
GET_NEXT_FREE_STRUCT(LOCAL_STR, STR, STR_TYPE, GLOBAL##_PG_ENT)
|
||||||
|
|
||||||
#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING)
|
#define ALLOC_TABLE_ENTRY(STR) ALLOC_STRUCT(STR, struct table_entry, _pages_tab_ent)
|
||||||
#define ALLOC_DEPENDENCY_FRAME(STR) ALLOC_STRUCT(STR, struct dependency_frame, GLOBAL_pages_dep_fr, GLOBAL_pages_void)
|
#define FREE_TABLE_ENTRY(STR) FREE_STRUCT(STR, struct table_entry, _pages_tab_ent)
|
||||||
#define FREE_DEPENDENCY_FRAME(STR) FREE_STRUCT(STR, struct dependency_frame, GLOBAL_pages_dep_fr, GLOBAL_pages_void)
|
|
||||||
|
#define ALLOC_SUBGOAL_ENTRY(STR) ALLOC_STRUCT(STR, struct subgoal_entry, _pages_sg_ent)
|
||||||
|
#define FREE_SUBGOAL_ENTRY(STR) FREE_STRUCT(STR, struct subgoal_entry, _pages_sg_ent)
|
||||||
|
|
||||||
|
#define ALLOC_SUBGOAL_FRAME(STR) ALLOC_STRUCT(STR, struct subgoal_frame, _pages_sg_fr)
|
||||||
|
#define FREE_SUBGOAL_FRAME(STR) FREE_STRUCT(STR, struct subgoal_frame, _pages_sg_fr)
|
||||||
|
|
||||||
|
#define ALLOC_DEPENDENCY_FRAME(STR) ALLOC_STRUCT(STR, struct dependency_frame, _pages_dep_fr)
|
||||||
|
#define FREE_DEPENDENCY_FRAME(STR) FREE_STRUCT(STR, struct dependency_frame, _pages_dep_fr)
|
||||||
|
|
||||||
|
#define ALLOC_SUBGOAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, struct subgoal_trie_node, _pages_sg_node)
|
||||||
|
#define FREE_SUBGOAL_TRIE_NODE(STR) FREE_STRUCT(STR, struct subgoal_trie_node, _pages_sg_node)
|
||||||
|
|
||||||
|
#define ALLOC_SUBGOAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, struct subgoal_trie_hash, _pages_sg_hash)
|
||||||
|
#define FREE_SUBGOAL_TRIE_HASH(STR) FREE_STRUCT(STR, struct subgoal_trie_hash, _pages_sg_hash)
|
||||||
|
|
||||||
|
#ifdef YAPOR
|
||||||
|
#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_NEXT_STRUCT(LOCAL_next_free_ans_node, STR, struct answer_trie_node, _pages_ans_node)
|
||||||
#else
|
#else
|
||||||
#define ALLOC_DEPENDENCY_FRAME(STR) ALLOC_STRUCT(STR, struct dependency_frame, LOCAL_pages_dep_fr, LOCAL_pages_void)
|
#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_STRUCT(STR, struct answer_trie_node, _pages_ans_node)
|
||||||
#define FREE_DEPENDENCY_FRAME(STR) FREE_STRUCT(STR, struct dependency_frame, LOCAL_pages_dep_fr, LOCAL_pages_void)
|
|
||||||
#endif
|
#endif
|
||||||
|
#define FREE_ANSWER_TRIE_NODE(STR) FREE_STRUCT(STR, struct answer_trie_node, _pages_ans_node)
|
||||||
|
|
||||||
#if !defined(THREADS_NO_SHARING)
|
#define ALLOC_ANSWER_TRIE_HASH(STR) ALLOC_STRUCT(STR, struct answer_trie_hash, _pages_ans_hash)
|
||||||
#if defined(THREADS_SUBGOAL_SHARING) || defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#define FREE_ANSWER_TRIE_HASH(STR) FREE_STRUCT(STR, struct answer_trie_hash, _pages_ans_hash)
|
||||||
#define ALLOC_SUBGOAL_TRIE_NODE(STR) LOCAL_NEXT_ALLOC_STRUCT(STR, LOCAL_next_free_sg_node, struct subgoal_trie_node, GLOBAL_pages_sg_node, GLOBAL_pages_void)
|
|
||||||
#else
|
|
||||||
#define ALLOC_SUBGOAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, struct subgoal_trie_node, GLOBAL_pages_sg_node, GLOBAL_pages_void)
|
|
||||||
#endif
|
|
||||||
#define FREE_SUBGOAL_TRIE_NODE(STR) FREE_STRUCT(STR, struct subgoal_trie_node, GLOBAL_pages_sg_node, GLOBAL_pages_void)
|
|
||||||
#else
|
|
||||||
#define ALLOC_SUBGOAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, struct subgoal_trie_node, LOCAL_pages_sg_node, LOCAL_pages_void)
|
|
||||||
#define FREE_SUBGOAL_TRIE_NODE(STR) FREE_STRUCT(STR, struct subgoal_trie_node, LOCAL_pages_sg_node, LOCAL_pages_void)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(THREADS_NO_SHARING)
|
#define ALLOC_ANSWER_REF_NODE(STR) ALLOC_STRUCT(STR, struct answer_ref_node, _pages_ans_ref_node)
|
||||||
#if defined(THREADS_SUBGOAL_SHARING) || defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#define FREE_ANSWER_REF_NODE(STR) FREE_STRUCT(STR, struct answer_ref_node, _pages_ans_ref_node)
|
||||||
#define ALLOC_SUBGOAL_TRIE_HASH(STR) LOCAL_NEXT_ALLOC_STRUCT(STR, LOCAL_next_free_sg_hash, struct subgoal_trie_hash, GLOBAL_pages_sg_hash, GLOBAL_pages_void)
|
|
||||||
#else
|
|
||||||
#define ALLOC_SUBGOAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, struct subgoal_trie_hash, GLOBAL_pages_sg_hash, GLOBAL_pages_void)
|
|
||||||
#endif
|
|
||||||
#define FREE_SUBGOAL_TRIE_HASH(STR) FREE_STRUCT(STR, struct subgoal_trie_hash, GLOBAL_pages_sg_hash, GLOBAL_pages_void)
|
|
||||||
#else
|
|
||||||
#define ALLOC_SUBGOAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, struct subgoal_trie_hash, LOCAL_pages_sg_hash, LOCAL_pages_void)
|
|
||||||
#define FREE_SUBGOAL_TRIE_HASH(STR) FREE_STRUCT(STR, struct subgoal_trie_hash, LOCAL_pages_sg_hash, LOCAL_pages_void)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING)
|
#define ALLOC_GLOBAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, struct global_trie_node, _pages_gt_node)
|
||||||
#if defined(YAPOR) || defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#define FREE_GLOBAL_TRIE_NODE(STR) FREE_STRUCT(STR, struct global_trie_node, _pages_gt_node)
|
||||||
#define ALLOC_ANSWER_TRIE_NODE(STR) LOCAL_NEXT_ALLOC_STRUCT(STR, LOCAL_next_free_ans_node, struct answer_trie_node, GLOBAL_pages_ans_node, GLOBAL_pages_void)
|
|
||||||
#else
|
|
||||||
#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_STRUCT(STR, struct answer_trie_node, GLOBAL_pages_ans_node, GLOBAL_pages_void)
|
|
||||||
#endif
|
|
||||||
#define FREE_ANSWER_TRIE_NODE(STR) FREE_STRUCT(STR, struct answer_trie_node, GLOBAL_pages_ans_node, GLOBAL_pages_void)
|
|
||||||
#else
|
|
||||||
#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_STRUCT(STR, struct answer_trie_node, LOCAL_pages_ans_node, LOCAL_pages_void)
|
|
||||||
#define FREE_ANSWER_TRIE_NODE(STR) FREE_STRUCT(STR, struct answer_trie_node, LOCAL_pages_ans_node, LOCAL_pages_void)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING)
|
#define ALLOC_GLOBAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, struct global_trie_hash, _pages_gt_hash)
|
||||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#define FREE_GLOBAL_TRIE_HASH(STR) FREE_STRUCT(STR, struct global_trie_hash, _pages_gt_hash)
|
||||||
#define ALLOC_ANSWER_TRIE_HASH(STR) LOCAL_NEXT_ALLOC_STRUCT(STR, LOCAL_next_free_ans_hash, struct answer_trie_hash, GLOBAL_pages_ans_hash, GLOBAL_pages_void)
|
|
||||||
#else
|
|
||||||
#define ALLOC_ANSWER_TRIE_HASH(STR) ALLOC_STRUCT(STR, struct answer_trie_hash, GLOBAL_pages_ans_hash, GLOBAL_pages_void)
|
|
||||||
#endif
|
|
||||||
#define FREE_ANSWER_TRIE_HASH(STR) FREE_STRUCT(STR, struct answer_trie_hash, GLOBAL_pages_ans_hash, GLOBAL_pages_void)
|
|
||||||
#else
|
|
||||||
#define ALLOC_ANSWER_TRIE_HASH(STR) ALLOC_STRUCT(STR, struct answer_trie_hash, LOCAL_pages_ans_hash, LOCAL_pages_void)
|
|
||||||
#define FREE_ANSWER_TRIE_HASH(STR) FREE_STRUCT(STR, struct answer_trie_hash, LOCAL_pages_ans_hash, LOCAL_pages_void)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ALLOC_ANSWER_REF_NODE(STR) ALLOC_STRUCT(STR, struct answer_ref_node, LOCAL_pages_ans_ref_node, LOCAL_pages_void)
|
#define ALLOC_OR_FRAME(STR) ALLOC_STRUCT(STR, struct or_frame, _pages_or_fr)
|
||||||
#define FREE_ANSWER_REF_NODE(STR) FREE_STRUCT(STR, struct answer_ref_node, LOCAL_pages_ans_ref_node, LOCAL_pages_void)
|
#define FREE_OR_FRAME(STR) FREE_STRUCT(STR, struct or_frame, _pages_or_fr)
|
||||||
|
|
||||||
#define ALLOC_GLOBAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, struct global_trie_node, GLOBAL_pages_gt_node, GLOBAL_pages_void)
|
#define ALLOC_QG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, struct query_goal_solution_frame, _pages_qg_sol_fr)
|
||||||
#define FREE_GLOBAL_TRIE_NODE(STR) FREE_STRUCT(STR, struct global_trie_node, GLOBAL_pages_gt_node, GLOBAL_pages_void)
|
#define FREE_QG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, struct query_goal_solution_frame, _pages_qg_sol_fr)
|
||||||
|
|
||||||
#define ALLOC_GLOBAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, struct global_trie_hash, GLOBAL_pages_gt_hash, GLOBAL_pages_void)
|
#define ALLOC_QG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, struct query_goal_answer_frame, _pages_qg_ans_fr)
|
||||||
#define FREE_GLOBAL_TRIE_HASH(STR) FREE_STRUCT(STR, struct global_trie_hash, GLOBAL_pages_gt_hash, GLOBAL_pages_void)
|
#define FREE_QG_ANSWER_FRAME(STR) FREE_STRUCT(STR, struct query_goal_answer_frame, _pages_qg_ans_fr)
|
||||||
|
|
||||||
#define ALLOC_OR_FRAME(STR) ALLOC_STRUCT(STR, struct or_frame, GLOBAL_pages_or_fr, GLOBAL_pages_void)
|
#define ALLOC_SUSPENSION_FRAME(STR) ALLOC_STRUCT(STR, struct suspension_frame, _pages_susp_fr)
|
||||||
#define FREE_OR_FRAME(STR) FREE_STRUCT(STR, struct or_frame, GLOBAL_pages_or_fr, GLOBAL_pages_void)
|
#define FREE_SUSPENSION_FRAME(STR) FREE_BLOCK(SuspFr_global_start(STR)); \
|
||||||
|
FREE_STRUCT(STR, struct suspension_frame, _pages_susp_fr)
|
||||||
|
|
||||||
#define ALLOC_QG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, struct query_goal_solution_frame, GLOBAL_pages_qg_sol_fr, GLOBAL_pages_void)
|
#define ALLOC_TG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, struct table_subgoal_solution_frame, _pages_tg_sol_fr)
|
||||||
#define FREE_QG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, struct query_goal_solution_frame, GLOBAL_pages_qg_sol_fr, GLOBAL_pages_void)
|
#define FREE_TG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, struct table_subgoal_solution_frame, _pages_tg_sol_fr)
|
||||||
|
|
||||||
#define ALLOC_QG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, struct query_goal_answer_frame, GLOBAL_pages_qg_ans_fr, GLOBAL_pages_void)
|
#define ALLOC_TG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, struct table_subgoal_answer_frame, _pages_tg_ans_fr)
|
||||||
#define FREE_QG_ANSWER_FRAME(STR) FREE_STRUCT(STR, struct query_goal_answer_frame, GLOBAL_pages_qg_ans_fr, GLOBAL_pages_void)
|
#define FREE_TG_ANSWER_FRAME(STR) FREE_STRUCT(STR, struct table_subgoal_answer_frame, _pages_tg_ans_fr)
|
||||||
|
|
||||||
#define ALLOC_SUSPENSION_FRAME(STR) ALLOC_STRUCT(STR, struct suspension_frame, GLOBAL_pages_susp_fr, GLOBAL_pages_void)
|
|
||||||
#define FREE_SUSPENSION_FRAME(STR) FREE_BLOCK(SuspFr_global_start(STR)); \
|
|
||||||
FREE_STRUCT(STR, struct suspension_frame, GLOBAL_pages_susp_fr, GLOBAL_pages_void)
|
|
||||||
|
|
||||||
#define ALLOC_TG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, struct table_subgoal_solution_frame, GLOBAL_pages_tg_sol_fr, GLOBAL_pages_void)
|
|
||||||
#define FREE_TG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, struct table_subgoal_solution_frame, GLOBAL_pages_tg_sol_fr, GLOBAL_pages_void)
|
|
||||||
|
|
||||||
#define ALLOC_TG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, struct table_subgoal_answer_frame, GLOBAL_pages_tg_ans_fr, GLOBAL_pages_void)
|
|
||||||
#define FREE_TG_ANSWER_FRAME(STR) FREE_STRUCT(STR, struct table_subgoal_answer_frame, GLOBAL_pages_tg_ans_fr, GLOBAL_pages_void)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,87 +107,87 @@ static inline struct page_statistics show_statistics_table_subgoal_answer_frames
|
|||||||
|
|
||||||
struct page_statistics {
|
struct page_statistics {
|
||||||
#ifdef USE_PAGES_MALLOC
|
#ifdef USE_PAGES_MALLOC
|
||||||
long pages_allocated; /* same as struct pages (opt.structs.h) */
|
long pages_in_use; /* same as struct pages (opt.structs.h) */
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
long structs_in_use; /* same as struct pages (opt.structs.h) */
|
long structs_in_use; /* same as struct pages (opt.structs.h) */
|
||||||
long bytes_in_use;
|
long bytes_in_use;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define Pg_bytes_in_use(STATS) STATS.bytes_in_use
|
#define PgEnt_bytes_in_use(STATS) STATS.bytes_in_use
|
||||||
|
|
||||||
#ifdef USE_PAGES_MALLOC
|
#ifdef USE_PAGES_MALLOC
|
||||||
#ifdef DEBUG_TABLING
|
#ifdef DEBUG_TABLING
|
||||||
#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE, PAGE) \
|
#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE, PAGE) \
|
||||||
{ pg_hd_ptr pg_hd; \
|
{ pg_hd_ptr pg_hd; \
|
||||||
STR_TYPE *aux_ptr; \
|
STR_TYPE *aux_ptr; \
|
||||||
long cont = 0; \
|
long cont = 0; \
|
||||||
pg_hd = Pg_free_pg(PAGE); \
|
pg_hd = PgEnt_first(PAGE); \
|
||||||
while (pg_hd) { \
|
while (pg_hd) { \
|
||||||
aux_ptr = PgHd_free_str(pg_hd); \
|
aux_ptr = PgHd_first_str(pg_hd); \
|
||||||
while (aux_ptr) { \
|
while (aux_ptr) { \
|
||||||
cont++; \
|
cont++; \
|
||||||
aux_ptr = aux_ptr->next; \
|
aux_ptr = aux_ptr->next; \
|
||||||
} \
|
} \
|
||||||
pg_hd = PgHd_next(pg_hd); \
|
pg_hd = PgHd_next(pg_hd); \
|
||||||
} \
|
} \
|
||||||
TABLING_ERROR_CHECKING(CHECK_PAGE_FREE_STRUCTS, Pg_str_free(PAGE) != cont); \
|
TABLING_ERROR_CHECKING(CHECK_PAGE_FREE_STRUCTS, PgEnt_strs_free(PAGE) != cont); \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE, PAGE)
|
#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE, PAGE)
|
||||||
#endif /* DEBUG_TABLING */
|
#endif /* DEBUG_TABLING */
|
||||||
#define INIT_PAGE_STATS(STATS) \
|
#define INIT_PAGE_STATS(STATS) \
|
||||||
Pg_pg_alloc(STATS) = 0; \
|
PgEnt_pages_in_use(STATS) = 0; \
|
||||||
Pg_str_in_use(STATS) = 0
|
PgEnt_strs_in_use(STATS) = 0
|
||||||
#define INCREMENT_PAGE_STATS(STATS, PAGE) \
|
#define INCREMENT_PAGE_STATS(STATS, PAGE) \
|
||||||
Pg_pg_alloc(STATS) += Pg_pg_alloc(PAGE); \
|
PgEnt_pages_in_use(STATS) += PgEnt_pages_in_use(PAGE); \
|
||||||
Pg_str_in_use(STATS) += Pg_str_in_use(PAGE)
|
PgEnt_strs_in_use(STATS) += PgEnt_strs_in_use(PAGE)
|
||||||
#define INCREMENT_AUX_STATS(STATS, BYTES, PAGES) \
|
#define INCREMENT_AUX_STATS(STATS, BYTES, PAGES) \
|
||||||
BYTES += Pg_bytes_in_use(STATS); \
|
BYTES += PgEnt_bytes_in_use(STATS); \
|
||||||
PAGES += Pg_pg_alloc(STATS)
|
PAGES += PgEnt_pages_in_use(STATS)
|
||||||
#define SHOW_PAGE_STATS_MSG(STR_NAME) " " STR_NAME " %10ld bytes (%ld pages and %ld structs in use)\n"
|
#define SHOW_PAGE_STATS_MSG(STR_NAME) " " STR_NAME " %10ld bytes (%ld pages and %ld structs in use)\n"
|
||||||
#define SHOW_PAGE_STATS_ARGS(STATS, STR_TYPE) Pg_str_in_use(STATS) * sizeof(STR_TYPE), Pg_pg_alloc(STATS), Pg_str_in_use(STATS)
|
#define SHOW_PAGE_STATS_ARGS(STATS, STR_TYPE) PgEnt_strs_in_use(STATS) * sizeof(STR_TYPE), PgEnt_pages_in_use(STATS), PgEnt_strs_in_use(STATS)
|
||||||
#else /* !USE_PAGES_MALLOC */
|
#else /* !USE_PAGES_MALLOC */
|
||||||
#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE, PAGE)
|
#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE, PAGE)
|
||||||
#define INIT_PAGE_STATS(STATS) \
|
#define INIT_PAGE_STATS(STATS) \
|
||||||
Pg_str_in_use(STATS) = 0
|
PgEnt_strs_in_use(STATS) = 0
|
||||||
#define INCREMENT_PAGE_STATS(STATS, PAGE) \
|
#define INCREMENT_PAGE_STATS(STATS, PAGE) \
|
||||||
Pg_str_in_use(STATS) += Pg_str_in_use(PAGE)
|
PgEnt_strs_in_use(STATS) += PgEnt_strs_in_use(PAGE)
|
||||||
#define INCREMENT_AUX_STATS(STATS, BYTES, PAGES) \
|
#define INCREMENT_AUX_STATS(STATS, BYTES, PAGES) \
|
||||||
BYTES += Pg_bytes_in_use(STATS)
|
BYTES += PgEnt_bytes_in_use(STATS)
|
||||||
#define SHOW_PAGE_STATS_MSG(STR_NAME) " " STR_NAME " %10ld bytes (%ld structs in use)\n"
|
#define SHOW_PAGE_STATS_MSG(STR_NAME) " " STR_NAME " %10ld bytes (%ld structs in use)\n"
|
||||||
#define SHOW_PAGE_STATS_ARGS(STATS, STR_TYPE) Pg_str_in_use(STATS) * sizeof(STR_TYPE), Pg_str_in_use(STATS)
|
#define SHOW_PAGE_STATS_ARGS(STATS, STR_TYPE) PgEnt_strs_in_use(STATS) * sizeof(STR_TYPE), PgEnt_strs_in_use(STATS)
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
|
|
||||||
#define GET_GLOBAL_PAGE_STATS(STATS, STR_TYPE, STR_PAGES) \
|
|
||||||
INIT_PAGE_STATS(STATS); \
|
|
||||||
CHECK_PAGE_FREE_STRUCTS(STR_TYPE, STR_PAGES); \
|
|
||||||
INCREMENT_PAGE_STATS(STATS, STR_PAGES); \
|
|
||||||
Pg_bytes_in_use(STATS) = Pg_str_in_use(STATS) * sizeof(STR_TYPE)
|
|
||||||
#define GET_REMOTE_PAGE_STATS(STATS, STR_TYPE, STR_PAGES) \
|
|
||||||
INIT_PAGE_STATS(STATS); \
|
|
||||||
LOCK(GLOBAL_ThreadHandlesLock); \
|
|
||||||
{ int wid; \
|
|
||||||
for (wid = 0; wid < MAX_THREADS; wid++) { \
|
|
||||||
if (! Yap_local[wid]) \
|
|
||||||
break; \
|
|
||||||
if (REMOTE_ThreadHandle(wid).in_use) { \
|
|
||||||
CHECK_PAGE_FREE_STRUCTS(STR_TYPE, STR_PAGES(wid)); \
|
|
||||||
INCREMENT_PAGE_STATS(STATS, STR_PAGES(wid)); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
UNLOCK(GLOBAL_ThreadHandlesLock); \
|
|
||||||
Pg_bytes_in_use(STATS) = Pg_str_in_use(STATS) * sizeof(STR_TYPE)
|
|
||||||
|
|
||||||
#define SHOW_GLOBAL_PAGE_STATS(OUT_STREAM, STR_TYPE, STR_PAGES, STR_NAME) \
|
#ifdef THREADS
|
||||||
|
#define GET_ALL_PAGE_STATS(STATS, STR_TYPE, _PAGES) \
|
||||||
|
LOCK(GLOBAL_ThreadHandlesLock); \
|
||||||
|
CHECK_PAGE_FREE_STRUCTS(STR_TYPE, GLOBAL##_PAGES); \
|
||||||
|
INCREMENT_PAGE_STATS(STATS, GLOBAL##_PAGES); \
|
||||||
|
{ int wid; \
|
||||||
|
for (wid = 0; wid < MAX_THREADS; wid++) { \
|
||||||
|
if (! Yap_local[wid]) \
|
||||||
|
break; \
|
||||||
|
if (REMOTE_ThreadHandle(wid).in_use) { \
|
||||||
|
CHECK_PAGE_FREE_STRUCTS(STR_TYPE, REMOTE##_PAGES(wid)); \
|
||||||
|
INCREMENT_PAGE_STATS(STATS, REMOTE##_PAGES(wid)); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
UNLOCK(GLOBAL_ThreadHandlesLock)
|
||||||
|
#else
|
||||||
|
#define GET_ALL_PAGE_STATS(STATS, STR_TYPE, _PAGES) \
|
||||||
|
CHECK_PAGE_FREE_STRUCTS(STR_TYPE, GLOBAL##_PAGES); \
|
||||||
|
INCREMENT_PAGE_STATS(STATS, GLOBAL##_PAGES)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define GET_PAGE_STATS(STATS, STR_TYPE, _PAGES) \
|
||||||
|
INIT_PAGE_STATS(STATS); \
|
||||||
|
GET_ALL_PAGE_STATS(STATS, STR_TYPE, _PAGES); \
|
||||||
|
PgEnt_bytes_in_use(STATS) = PgEnt_strs_in_use(STATS) * sizeof(STR_TYPE)
|
||||||
|
#define SHOW_PAGE_STATS(OUT_STREAM, STR_TYPE, _PAGES, STR_NAME) \
|
||||||
{ struct page_statistics stats; \
|
{ struct page_statistics stats; \
|
||||||
GET_GLOBAL_PAGE_STATS(stats, STR_TYPE, STR_PAGES); \
|
GET_PAGE_STATS(stats, STR_TYPE, _PAGES); \
|
||||||
Sfprintf(OUT_STREAM, SHOW_PAGE_STATS_MSG(STR_NAME), SHOW_PAGE_STATS_ARGS(stats, STR_TYPE)); \
|
|
||||||
return stats; \
|
|
||||||
}
|
|
||||||
#define SHOW_REMOTE_PAGE_STATS(OUT_STREAM, STR_TYPE, STR_PAGES, STR_NAME) \
|
|
||||||
{ struct page_statistics stats; \
|
|
||||||
GET_REMOTE_PAGE_STATS(stats, STR_TYPE, STR_PAGES); \
|
|
||||||
Sfprintf(OUT_STREAM, SHOW_PAGE_STATS_MSG(STR_NAME), SHOW_PAGE_STATS_ARGS(stats, STR_TYPE)); \
|
Sfprintf(OUT_STREAM, SHOW_PAGE_STATS_MSG(STR_NAME), SHOW_PAGE_STATS_ARGS(stats, STR_TYPE)); \
|
||||||
return stats; \
|
return stats; \
|
||||||
}
|
}
|
||||||
@ -643,7 +643,7 @@ static Int p_show_statistics_tabling( USES_REGS1 ) {
|
|||||||
Sfprintf(out, "Total memory in use (I+II+III): %10ld bytes (%ld pages in use)\n",
|
Sfprintf(out, "Total memory in use (I+II+III): %10ld bytes (%ld pages in use)\n",
|
||||||
total_bytes, total_pages);
|
total_bytes, total_pages);
|
||||||
Sfprintf(out, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
Sfprintf(out, "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));
|
PgEnt_pages_in_use(GLOBAL_pages_alloc) * Yap_page_size, PgEnt_pages_in_use(GLOBAL_pages_alloc));
|
||||||
#else
|
#else
|
||||||
Sfprintf(out, "Total memory in use (I+II+III): %10ld bytes\n", total_bytes);
|
Sfprintf(out, "Total memory in use (I+II+III): %10ld bytes\n", total_bytes);
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
@ -810,7 +810,7 @@ static Int p_show_statistics_or( USES_REGS1 ) {
|
|||||||
Sfprintf(out, "Total memory in use (I+II): %10ld bytes (%ld pages in use)\n",
|
Sfprintf(out, "Total memory in use (I+II): %10ld bytes (%ld pages in use)\n",
|
||||||
total_bytes, total_pages);
|
total_bytes, total_pages);
|
||||||
Sfprintf(out, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
Sfprintf(out, "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));
|
PgEnt_pages_in_use(GLOBAL_pages_alloc) * Yap_page_size, PgEnt_pages_in_use(GLOBAL_pages_alloc));
|
||||||
#else
|
#else
|
||||||
Sfprintf(out, "Total memory in use (I+II): %10ld bytes\n", total_bytes);
|
Sfprintf(out, "Total memory in use (I+II): %10ld bytes\n", total_bytes);
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
@ -899,7 +899,7 @@ static Int p_show_statistics_opt( USES_REGS1 ) {
|
|||||||
Sfprintf(out, "Total memory in use (I+II+III+IV): %10ld bytes (%ld pages in use)\n",
|
Sfprintf(out, "Total memory in use (I+II+III+IV): %10ld bytes (%ld pages in use)\n",
|
||||||
total_bytes, total_pages);
|
total_bytes, total_pages);
|
||||||
Sfprintf(out, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
Sfprintf(out, "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));
|
PgEnt_pages_in_use(GLOBAL_pages_alloc) * Yap_page_size, PgEnt_pages_in_use(GLOBAL_pages_alloc));
|
||||||
#else
|
#else
|
||||||
Sfprintf(out, "Total memory in use (I+II+III+IV): %10ld bytes\n", total_bytes);
|
Sfprintf(out, "Total memory in use (I+II+III+IV): %10ld bytes\n", total_bytes);
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
@ -917,129 +917,105 @@ static Int p_get_optyap_statistics( USES_REGS1 ) {
|
|||||||
value = IntOfTerm(Deref(ARG1));
|
value = IntOfTerm(Deref(ARG1));
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
if (value == 0 || value == 1) { /* table_entries */
|
if (value == 0 || value == 1) { /* table_entries */
|
||||||
GET_GLOBAL_PAGE_STATS(stats, struct table_entry, GLOBAL_pages_tab_ent);
|
GET_PAGE_STATS(stats, struct table_entry, _pages_tab_ent);
|
||||||
bytes += Pg_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
if (value == 0 || value == 16) { /* subgoal_entries */
|
if (value == 0 || value == 16) { /* subgoal_entries */
|
||||||
GET_GLOBAL_PAGE_STATS(stats, struct subgoal_entry, GLOBAL_pages_sg_ent);
|
GET_PAGE_STATS(stats, struct subgoal_entry, _pages_sg_ent);
|
||||||
bytes += Pg_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
|
||||||
if (value == 0 || value == 2) { /* subgoal_frames */
|
|
||||||
#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING)
|
|
||||||
GET_GLOBAL_PAGE_STATS(stats, struct subgoal_frame, GLOBAL_pages_sg_fr);
|
|
||||||
#else
|
|
||||||
GET_REMOTE_PAGE_STATS(stats, struct subgoal_frame, REMOTE_pages_sg_fr);
|
|
||||||
#endif
|
#endif
|
||||||
bytes += Pg_bytes_in_use(stats);
|
if (value == 0 || value == 2) { /* subgoal_frames */
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
GET_PAGE_STATS(stats, struct subgoal_frame, _pages_sg_fr);
|
||||||
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 3) { /* dependency_frames */
|
if (value == 0 || value == 3) { /* dependency_frames */
|
||||||
#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING)
|
GET_PAGE_STATS(stats, struct dependency_frame, _pages_dep_fr);
|
||||||
GET_GLOBAL_PAGE_STATS(stats, struct dependency_frame, GLOBAL_pages_dep_fr);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
#else
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
GET_REMOTE_PAGE_STATS(stats, struct dependency_frame, REMOTE_pages_dep_fr);
|
|
||||||
#endif
|
|
||||||
bytes += Pg_bytes_in_use(stats);
|
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 6) { /* subgoal_trie_nodes */
|
if (value == 0 || value == 6) { /* subgoal_trie_nodes */
|
||||||
#if !defined(THREADS_NO_SHARING)
|
GET_PAGE_STATS(stats, struct subgoal_trie_node, _pages_sg_node);
|
||||||
GET_GLOBAL_PAGE_STATS(stats, struct subgoal_trie_node, GLOBAL_pages_sg_node);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
#else
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
GET_REMOTE_PAGE_STATS(stats, struct subgoal_trie_node, REMOTE_pages_sg_node);
|
|
||||||
#endif
|
|
||||||
bytes += Pg_bytes_in_use(stats);
|
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 8) { /* subgoal_trie_hashes */
|
if (value == 0 || value == 8) { /* subgoal_trie_hashes */
|
||||||
#if !defined(THREADS_NO_SHARING)
|
GET_PAGE_STATS(stats, struct subgoal_trie_hash, _pages_sg_hash);
|
||||||
GET_GLOBAL_PAGE_STATS(stats, struct subgoal_trie_hash, GLOBAL_pages_sg_hash);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
#else
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
GET_REMOTE_PAGE_STATS(stats, struct subgoal_trie_hash, REMOTE_pages_sg_hash);
|
|
||||||
#endif
|
|
||||||
bytes += Pg_bytes_in_use(stats);
|
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 7) { /* answer_trie_nodes */
|
if (value == 0 || value == 7) { /* answer_trie_nodes */
|
||||||
#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING)
|
GET_PAGE_STATS(stats, struct answer_trie_node, _pages_ans_node);
|
||||||
GET_GLOBAL_PAGE_STATS(stats, struct answer_trie_node, GLOBAL_pages_ans_node);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
#else
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
GET_REMOTE_PAGE_STATS(stats, struct answer_trie_node, REMOTE_pages_ans_node);
|
|
||||||
#endif
|
|
||||||
bytes += Pg_bytes_in_use(stats);
|
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 9) { /* answer_trie_hashes */
|
if (value == 0 || value == 9) { /* answer_trie_hashes */
|
||||||
#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING)
|
GET_PAGE_STATS(stats, struct answer_trie_hash, _pages_ans_hash);
|
||||||
GET_GLOBAL_PAGE_STATS(stats, struct answer_trie_hash, GLOBAL_pages_ans_hash);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
#else
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
GET_REMOTE_PAGE_STATS(stats, struct answer_trie_hash, REMOTE_pages_ans_hash);
|
|
||||||
#endif
|
|
||||||
bytes += Pg_bytes_in_use(stats);
|
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
|
||||||
}
|
}
|
||||||
#if defined(THREADS_FULL_SHARING)
|
#if defined(THREADS_FULL_SHARING)
|
||||||
if (value == 0 || value == 17) { /* answer_ref_nodes */
|
if (value == 0 || value == 17) { /* answer_ref_nodes */
|
||||||
GET_REMOTE_PAGE_STATS(stats, struct answer_ref_node, REMOTE_pages_ans_ref_node);
|
GET_PAGE_STATS(stats, struct answer_ref_node, _pages_ans_ref_node);
|
||||||
bytes += Pg_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
#endif /* THREADS_FULL_SHARING */
|
#endif
|
||||||
if (value == 0 || value == 10) { /* global_trie_nodes */
|
if (value == 0 || value == 10) { /* global_trie_nodes */
|
||||||
GET_GLOBAL_PAGE_STATS(stats, struct global_trie_node, GLOBAL_pages_gt_node);
|
GET_PAGE_STATS(stats, struct global_trie_node, _pages_gt_node);
|
||||||
bytes += Pg_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 11) { /* global_trie_hashes */
|
if (value == 0 || value == 11) { /* global_trie_hashes */
|
||||||
GET_GLOBAL_PAGE_STATS(stats, struct global_trie_hash, GLOBAL_pages_gt_hash);
|
GET_PAGE_STATS(stats, struct global_trie_hash, _pages_gt_hash);
|
||||||
bytes += Pg_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
if (value == 0 || value == 4) { /* or_frames */
|
if (value == 0 || value == 4) { /* or_frames */
|
||||||
GET_GLOBAL_PAGE_STATS(stats, struct or_frame, GLOBAL_pages_or_fr);
|
GET_PAGE_STATS(stats, struct or_frame, _pages_or_fr);
|
||||||
bytes += Pg_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 12) { /* query_goal_solution_frames */
|
if (value == 0 || value == 12) { /* query_goal_solution_frames */
|
||||||
GET_GLOBAL_PAGE_STATS(stats, struct query_goal_solution_frame, GLOBAL_pages_qg_sol_fr);
|
GET_PAGE_STATS(stats, struct query_goal_solution_frame, _pages_qg_sol_fr);
|
||||||
bytes += Pg_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 13) { /* query_goal_answer_frames */
|
if (value == 0 || value == 13) { /* query_goal_answer_frames */
|
||||||
GET_GLOBAL_PAGE_STATS(stats, struct query_goal_answer_frame, GLOBAL_pages_qg_ans_fr);
|
GET_PAGE_STATS(stats, struct query_goal_answer_frame, _pages_qg_ans_fr);
|
||||||
bytes += Pg_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
#if defined(YAPOR) && defined(TABLING)
|
#if defined(YAPOR) && defined(TABLING)
|
||||||
if (value == 0 || value == 5) { /* suspension_frames */
|
if (value == 0 || value == 5) { /* suspension_frames */
|
||||||
GET_GLOBAL_PAGE_STATS(stats, struct suspension_frame, GLOBAL_pages_susp_fr);
|
GET_PAGE_STATS(stats, struct suspension_frame, _pages_susp_fr);
|
||||||
bytes += Pg_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
#ifdef TABLING_INNER_CUTS
|
#ifdef TABLING_INNER_CUTS
|
||||||
if (value == 0 || value == 14) { /* table_subgoal_solution_frames */
|
if (value == 0 || value == 14) { /* table_subgoal_solution_frames */
|
||||||
GET_GLOBAL_PAGE_STATS(stats, struct table_subgoal_solution_frame, GLOBAL_pages_tg_sol_fr);
|
GET_PAGE_STATS(stats, struct table_subgoal_solution_frame, _pages_tg_sol_fr);
|
||||||
bytes += Pg_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
if (value == 0 || value == 15) { /* table_subgoal_answer_frames */
|
if (value == 0 || value == 15) { /* table_subgoal_answer_frames */
|
||||||
GET_GLOBAL_PAGE_STATS(stats, struct table_subgoal_answer_frame, GLOBAL_pages_tg_ans_fr);
|
GET_PAGE_STATS(stats, struct table_subgoal_answer_frame, _pages_tg_ans_fr);
|
||||||
bytes += Pg_bytes_in_use(stats);
|
bytes += PgEnt_bytes_in_use(stats);
|
||||||
if (value != 0) structs = Pg_str_in_use(stats);
|
if (value != 0) structs = PgEnt_strs_in_use(stats);
|
||||||
}
|
}
|
||||||
#endif /* TABLING_INNER_CUTS */
|
#endif /* TABLING_INNER_CUTS */
|
||||||
#endif /* YAPOR && TABLING */
|
#endif /* YAPOR && TABLING */
|
||||||
|
|
||||||
if (value == 0) { /* total_memory */
|
if (value == 0) { /* total_memory */
|
||||||
#ifdef USE_PAGES_MALLOC
|
#ifdef USE_PAGES_MALLOC
|
||||||
structs = Pg_pg_alloc(GLOBAL_pages_void) * Yap_page_size;
|
structs = PgEnt_pages_in_use(GLOBAL_pages_alloc) * Yap_page_size;
|
||||||
#else
|
#else
|
||||||
structs = bytes;
|
structs = bytes;
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
@ -1083,120 +1059,96 @@ static inline realtime current_time(void) {
|
|||||||
|
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
static inline struct page_statistics show_statistics_table_entries(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_table_entries(IOSTREAM *out) {
|
||||||
SHOW_GLOBAL_PAGE_STATS(out, struct table_entry, GLOBAL_pages_tab_ent, "Table entries: ");
|
SHOW_PAGE_STATS(out, struct table_entry, _pages_tab_ent, "Table entries: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
static inline struct page_statistics show_statistics_subgoal_entries(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_subgoal_entries(IOSTREAM *out) {
|
||||||
SHOW_GLOBAL_PAGE_STATS(out, struct subgoal_entry, GLOBAL_pages_sg_ent, "Subgoal entries: ");
|
SHOW_PAGE_STATS(out, struct subgoal_entry, _pages_sg_ent, "Subgoal entries: ");
|
||||||
}
|
}
|
||||||
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
||||||
|
|
||||||
|
|
||||||
static inline struct page_statistics show_statistics_subgoal_frames(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_subgoal_frames(IOSTREAM *out) {
|
||||||
#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING)
|
SHOW_PAGE_STATS(out, struct subgoal_frame, _pages_sg_fr, "Subgoal frames: ");
|
||||||
SHOW_GLOBAL_PAGE_STATS(out, struct subgoal_frame, GLOBAL_pages_sg_fr, "Subgoal frames: ");
|
|
||||||
#else
|
|
||||||
SHOW_REMOTE_PAGE_STATS(out, struct subgoal_frame, REMOTE_pages_sg_fr, "Subgoal frames: ");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline struct page_statistics show_statistics_dependency_frames(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_dependency_frames(IOSTREAM *out) {
|
||||||
#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING)
|
SHOW_PAGE_STATS(out, struct dependency_frame, _pages_dep_fr, "Dependency frames: ");
|
||||||
SHOW_GLOBAL_PAGE_STATS(out, struct dependency_frame, GLOBAL_pages_dep_fr, "Dependency frames: ");
|
|
||||||
#else
|
|
||||||
SHOW_REMOTE_PAGE_STATS(out, struct dependency_frame, REMOTE_pages_dep_fr, "Dependency frames: ");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline struct page_statistics show_statistics_subgoal_trie_nodes(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_subgoal_trie_nodes(IOSTREAM *out) {
|
||||||
#if !defined(THREADS_NO_SHARING)
|
SHOW_PAGE_STATS(out, struct subgoal_trie_node, _pages_sg_node, "Subgoal trie nodes: ");
|
||||||
SHOW_GLOBAL_PAGE_STATS(out, struct subgoal_trie_node, GLOBAL_pages_sg_node, "Subgoal trie nodes: ");
|
|
||||||
#else
|
|
||||||
SHOW_REMOTE_PAGE_STATS(out, struct subgoal_trie_node, REMOTE_pages_sg_node, "Subgoal trie nodes: ");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline struct page_statistics show_statistics_subgoal_trie_hashes(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_subgoal_trie_hashes(IOSTREAM *out) {
|
||||||
#if !defined(THREADS_NO_SHARING)
|
SHOW_PAGE_STATS(out, struct subgoal_trie_hash, _pages_sg_hash, "Subgoal trie hashes: ");
|
||||||
SHOW_GLOBAL_PAGE_STATS(out, struct subgoal_trie_hash, GLOBAL_pages_sg_hash, "Subgoal trie hashes: ");
|
|
||||||
#else
|
|
||||||
SHOW_REMOTE_PAGE_STATS(out, struct subgoal_trie_hash, REMOTE_pages_sg_hash, "Subgoal trie hashes: ");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline struct page_statistics show_statistics_answer_trie_nodes(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_answer_trie_nodes(IOSTREAM *out) {
|
||||||
#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING)
|
SHOW_PAGE_STATS(out, struct answer_trie_node, _pages_ans_node, "Answer trie nodes: ");
|
||||||
SHOW_GLOBAL_PAGE_STATS(out, struct answer_trie_node, GLOBAL_pages_ans_node, "Answer trie nodes: ");
|
|
||||||
#else
|
|
||||||
SHOW_REMOTE_PAGE_STATS(out, struct answer_trie_node, REMOTE_pages_ans_node, "Answer trie nodes: ");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline struct page_statistics show_statistics_answer_trie_hashes(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_answer_trie_hashes(IOSTREAM *out) {
|
||||||
#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING)
|
SHOW_PAGE_STATS(out, struct answer_trie_hash, _pages_ans_hash, "Answer trie hashes: ");
|
||||||
SHOW_GLOBAL_PAGE_STATS(out, struct answer_trie_hash, GLOBAL_pages_ans_hash, "Answer trie hashes: ");
|
|
||||||
#else
|
|
||||||
SHOW_REMOTE_PAGE_STATS(out, struct answer_trie_hash, REMOTE_pages_ans_hash, "Answer trie hashes: ");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(THREADS_FULL_SHARING)
|
#if defined(THREADS_FULL_SHARING)
|
||||||
static inline struct page_statistics show_statistics_answer_ref_nodes(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_answer_ref_nodes(IOSTREAM *out) {
|
||||||
SHOW_REMOTE_PAGE_STATS(out, struct answer_ref_node, REMOTE_pages_ans_ref_node, "Answer ref nodes: ");
|
SHOW_PAGE_STATS(out, struct answer_ref_node, _pages_ans_ref_node, "Answer ref nodes: ");
|
||||||
}
|
}
|
||||||
#endif /* THREADS_FULL_SHARING */
|
#endif /* THREADS_FULL_SHARING */
|
||||||
|
|
||||||
|
|
||||||
static inline struct page_statistics show_statistics_global_trie_nodes(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_global_trie_nodes(IOSTREAM *out) {
|
||||||
SHOW_GLOBAL_PAGE_STATS(out, struct global_trie_node, GLOBAL_pages_gt_node, "Global trie nodes: ");
|
SHOW_PAGE_STATS(out, struct global_trie_node, _pages_gt_node, "Global trie nodes: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline struct page_statistics show_statistics_global_trie_hashes(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_global_trie_hashes(IOSTREAM *out) {
|
||||||
SHOW_GLOBAL_PAGE_STATS(out, struct global_trie_hash, GLOBAL_pages_gt_hash, "Global trie hashes: ");
|
SHOW_PAGE_STATS(out, struct global_trie_hash, _pages_gt_hash, "Global trie hashes: ");
|
||||||
}
|
}
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
|
|
||||||
|
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
static inline struct page_statistics show_statistics_or_frames(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_or_frames(IOSTREAM *out) {
|
||||||
SHOW_GLOBAL_PAGE_STATS(out, struct or_frame, GLOBAL_pages_or_fr, "Or-frames: ");
|
SHOW_PAGE_STATS(out, struct or_frame, _pages_or_fr, "Or-frames: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline struct page_statistics show_statistics_query_goal_solution_frames(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_query_goal_solution_frames(IOSTREAM *out) {
|
||||||
SHOW_GLOBAL_PAGE_STATS(out, struct query_goal_solution_frame, GLOBAL_pages_qg_sol_fr, "Query goal solution frames: ");
|
SHOW_PAGE_STATS(out, struct query_goal_solution_frame, _pages_qg_sol_fr, "Query goal solution frames: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline struct page_statistics show_statistics_query_goal_answer_frames(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_query_goal_answer_frames(IOSTREAM *out) {
|
||||||
SHOW_GLOBAL_PAGE_STATS(out, struct query_goal_answer_frame, GLOBAL_pages_qg_ans_fr, "Query goal answer frames: ");
|
SHOW_PAGE_STATS(out, struct query_goal_answer_frame, _pages_qg_ans_fr, "Query goal answer frames: ");
|
||||||
}
|
}
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
|
||||||
|
|
||||||
#if defined(YAPOR) && defined(TABLING)
|
#if defined(YAPOR) && defined(TABLING)
|
||||||
static inline struct page_statistics show_statistics_suspension_frames(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_suspension_frames(IOSTREAM *out) {
|
||||||
SHOW_GLOBAL_PAGE_STATS(out, struct suspension_frame, GLOBAL_pages_susp_fr, "Suspension frames: ");
|
SHOW_PAGE_STATS(out, struct suspension_frame, _pages_susp_fr, "Suspension frames: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef TABLING_INNER_CUTS
|
#ifdef TABLING_INNER_CUTS
|
||||||
static inline struct page_statistics show_statistics_table_subgoal_solution_frames(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_table_subgoal_solution_frames(IOSTREAM *out) {
|
||||||
SHOW_GLOBAL_PAGE_STATS(out, struct table_subgoal_solution_frame, GLOBAL_pages_tg_sol_fr, "Table subgoal solution frames:");
|
SHOW_PAGE_STATS(out, struct table_subgoal_solution_frame, _pages_tg_sol_fr, "Table subgoal solution frames:");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline struct page_statistics show_statistics_table_subgoal_answer_frames(IOSTREAM *out) {
|
static inline struct page_statistics show_statistics_table_subgoal_answer_frames(IOSTREAM *out) {
|
||||||
SHOW_GLOBAL_PAGE_STATS(out, struct table_subgoal_answer_frame, GLOBAL_pages_tg_ans_fr, "Table subgoal answer frames: ");
|
SHOW_PAGE_STATS(out, struct table_subgoal_answer_frame, _pages_tg_ans_fr, "Table subgoal answer frames: ");
|
||||||
}
|
}
|
||||||
#endif /* TABLING_INNER_CUTS */
|
#endif /* TABLING_INNER_CUTS */
|
||||||
#endif /* YAPOR && TABLING */
|
#endif /* YAPOR && TABLING */
|
||||||
|
@ -20,31 +20,23 @@ typedef unsigned long bitmap;
|
|||||||
|
|
||||||
#ifdef YAPOR_THREADS
|
#ifdef YAPOR_THREADS
|
||||||
/* Threads may not assume addresses are the same at different workers */
|
/* Threads may not assume addresses are the same at different workers */
|
||||||
static inline choiceptr
|
static inline choiceptr offset_to_cptr(Int node) {
|
||||||
offset_to_cptr(Int node)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
return (choiceptr)(LCL0+node);
|
return (choiceptr)(LCL0+node);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Int
|
static inline Int cptr_to_offset(choiceptr node) {
|
||||||
cptr_to_offset(choiceptr node)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
return (Int)((CELL *)node-LCL0);
|
return (Int)((CELL *)node-LCL0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline choiceptr
|
static inline choiceptr offset_to_cptr_with_null(Int node) {
|
||||||
offset_to_cptr_with_null(Int node)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
if (node == 0L) return NULL;
|
if (node == 0L) return NULL;
|
||||||
return (choiceptr)(LCL0+node);
|
return (choiceptr)(LCL0+node);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Int
|
static inline Int cptr_to_offset_with_null(choiceptr node) {
|
||||||
cptr_to_offset_with_null(choiceptr node)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
if (node == NULL) return 0L;
|
if (node == NULL) return 0L;
|
||||||
return (Int)((CELL *)node-LCL0);
|
return (Int)((CELL *)node-LCL0);
|
||||||
@ -104,16 +96,18 @@ struct threads_dependency_frame {
|
|||||||
#ifdef USE_PAGES_MALLOC
|
#ifdef USE_PAGES_MALLOC
|
||||||
typedef struct page_header {
|
typedef struct page_header {
|
||||||
volatile int structs_in_use;
|
volatile int structs_in_use;
|
||||||
|
void *allocated_area;
|
||||||
void *first_free_struct;
|
void *first_free_struct;
|
||||||
struct page_header *previous;
|
struct page_header *previous;
|
||||||
struct page_header *next;
|
struct page_header *next;
|
||||||
} *pg_hd_ptr;
|
} *pg_hd_ptr;
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
|
|
||||||
#define PgHd_str_in_use(X) ((X)->structs_in_use)
|
#define PgHd_strs_in_use(X) ((X)->structs_in_use)
|
||||||
#define PgHd_free_str(X) ((X)->first_free_struct)
|
#define PgHd_alloc_area(X) ((X)->allocated_area)
|
||||||
#define PgHd_previous(X) ((X)->previous)
|
#define PgHd_first_str(X) ((X)->first_free_struct)
|
||||||
#define PgHd_next(X) ((X)->next)
|
#define PgHd_previous(X) ((X)->previous)
|
||||||
|
#define PgHd_next(X) ((X)->next)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -126,31 +120,31 @@ struct global_page_entry {
|
|||||||
lockvar lock;
|
lockvar lock;
|
||||||
#endif /* YAPOR || THREADS */
|
#endif /* YAPOR || THREADS */
|
||||||
#ifdef USE_PAGES_MALLOC
|
#ifdef USE_PAGES_MALLOC
|
||||||
struct page_header *first_free_page;
|
struct page_header *first_page;
|
||||||
|
struct page_header *last_page;
|
||||||
int structs_per_page;
|
int structs_per_page;
|
||||||
volatile long pages_allocated;
|
volatile long pages_in_use;
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
volatile long structs_in_use;
|
volatile long structs_in_use;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct local_page_entry {
|
struct local_page_entry {
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
lockvar lock;
|
|
||||||
#endif /* YAPOR || THREADS */
|
|
||||||
#ifdef USE_PAGES_MALLOC
|
#ifdef USE_PAGES_MALLOC
|
||||||
struct page_header *first_free_page;
|
struct page_header *first_page;
|
||||||
|
struct page_header *last_page;
|
||||||
int structs_per_page;
|
int structs_per_page;
|
||||||
volatile long pages_allocated;
|
long pages_in_use;
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
volatile long structs_in_use;
|
long structs_in_use;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define Pg_lock(X) ((X).lock)
|
#define PgEnt_lock(X) ((X).lock)
|
||||||
#define Pg_free_pg(X) ((X).first_free_page)
|
#define PgEnt_first(X) ((X).first_page)
|
||||||
#define Pg_str_per_pg(X) ((X).structs_per_page)
|
#define PgEnt_last(X) ((X).last_page)
|
||||||
#define Pg_pg_alloc(X) ((X).pages_allocated)
|
#define PgEnt_strs_per_page(X) ((X).structs_per_page)
|
||||||
#define Pg_str_in_use(X) ((X).structs_in_use)
|
#define PgEnt_pages_in_use(X) ((X).pages_in_use)
|
||||||
#define Pg_str_free(X) (Pg_pg_alloc(X) * Pg_str_per_pg(X) - Pg_str_in_use(X))
|
#define PgEnt_strs_in_use(X) ((X).structs_in_use)
|
||||||
|
#define PgEnt_strs_free(X) (PgEnt_pg_in_use(X) * PgEnt_str_per_pg(X) - PgEnt_str_in_use(X))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -159,39 +153,39 @@ struct local_page_entry {
|
|||||||
***************************/
|
***************************/
|
||||||
|
|
||||||
struct global_pages {
|
struct global_pages {
|
||||||
|
struct global_page_entry alloc_pages;
|
||||||
struct global_page_entry void_pages;
|
struct global_page_entry void_pages;
|
||||||
|
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
struct global_page_entry table_entry_pages;
|
struct global_page_entry table_entry_pages;
|
||||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
struct global_page_entry subgoal_entry_pages;
|
struct global_page_entry subgoal_entry_pages;
|
||||||
#endif
|
#endif
|
||||||
#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING)
|
|
||||||
struct global_page_entry subgoal_frame_pages;
|
struct global_page_entry subgoal_frame_pages;
|
||||||
struct global_page_entry dependency_frame_pages;
|
struct global_page_entry dependency_frame_pages;
|
||||||
#endif
|
|
||||||
#if !defined(THREADS_NO_SHARING)
|
|
||||||
struct global_page_entry subgoal_trie_node_pages;
|
struct global_page_entry subgoal_trie_node_pages;
|
||||||
struct global_page_entry subgoal_trie_hash_pages;
|
struct global_page_entry subgoal_trie_hash_pages;
|
||||||
#endif
|
|
||||||
#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING)
|
|
||||||
struct global_page_entry answer_trie_node_pages;
|
struct global_page_entry answer_trie_node_pages;
|
||||||
struct global_page_entry answer_trie_hash_pages;
|
struct global_page_entry answer_trie_hash_pages;
|
||||||
|
#if defined(THREADS_FULL_SHARING)
|
||||||
|
struct global_page_entry answer_ref_node_pages;
|
||||||
#endif
|
#endif
|
||||||
struct global_page_entry global_trie_node_pages;
|
struct global_page_entry global_trie_node_pages;
|
||||||
struct global_page_entry global_trie_hash_pages;
|
struct global_page_entry global_trie_hash_pages;
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
|
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
struct global_page_entry or_frame_pages;
|
struct global_page_entry or_frame_pages;
|
||||||
struct global_page_entry query_goal_solution_frame_pages;
|
struct global_page_entry query_goal_solution_frame_pages;
|
||||||
struct global_page_entry query_goal_answer_frame_pages;
|
struct global_page_entry query_goal_answer_frame_pages;
|
||||||
#endif /* YAPOR */
|
#ifdef TABLING
|
||||||
#if defined(YAPOR) && defined(TABLING)
|
|
||||||
struct global_page_entry suspension_frame_pages;
|
struct global_page_entry suspension_frame_pages;
|
||||||
#endif /* YAPOR && TABLING */
|
#endif
|
||||||
#ifdef TABLING_INNER_CUTS
|
#ifdef TABLING_INNER_CUTS
|
||||||
struct global_page_entry table_subgoal_solution_frame_pages;
|
struct global_page_entry table_subgoal_solution_frame_pages;
|
||||||
struct global_page_entry table_subgoal_answer_frame_pages;
|
struct global_page_entry table_subgoal_answer_frame_pages;
|
||||||
#endif /* TABLING_INNER_CUTS */
|
#endif
|
||||||
|
#endif /* YAPOR */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -202,30 +196,26 @@ struct global_pages {
|
|||||||
|
|
||||||
#if defined(TABLING) && (defined(YAPOR) || defined(THREADS))
|
#if defined(TABLING) && (defined(YAPOR) || defined(THREADS))
|
||||||
struct local_pages {
|
struct local_pages {
|
||||||
#if defined(YAPOR)
|
#ifdef YAPOR
|
||||||
struct answer_trie_node *next_free_answer_trie_node;
|
struct answer_trie_node *next_free_answer_trie_node;
|
||||||
#elif defined(THREADS)
|
#elif THREADS
|
||||||
struct local_page_entry void_pages;
|
struct local_page_entry void_pages;
|
||||||
|
struct local_page_entry table_entry_pages;
|
||||||
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
|
struct local_page_entry subgoal_entry_pages;
|
||||||
|
#endif
|
||||||
struct local_page_entry subgoal_frame_pages;
|
struct local_page_entry subgoal_frame_pages;
|
||||||
struct local_page_entry dependency_frame_pages;
|
struct local_page_entry dependency_frame_pages;
|
||||||
#if defined(THREADS_NO_SHARING)
|
|
||||||
struct local_page_entry subgoal_trie_node_pages;
|
struct local_page_entry subgoal_trie_node_pages;
|
||||||
struct local_page_entry subgoal_trie_hash_pages;
|
struct local_page_entry subgoal_trie_hash_pages;
|
||||||
#elif defined(THREADS_SUBGOAL_SHARING) || defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
|
||||||
struct subgoal_trie_node *next_free_subgoal_trie_node;
|
|
||||||
struct subgoal_trie_hash *next_free_subgoal_trie_hash;
|
|
||||||
#endif
|
|
||||||
#if defined(THREADS_NO_SHARING) || defined(THREADS_SUBGOAL_SHARING)
|
|
||||||
struct local_page_entry answer_trie_node_pages;
|
struct local_page_entry answer_trie_node_pages;
|
||||||
struct local_page_entry answer_trie_hash_pages;
|
struct local_page_entry answer_trie_hash_pages;
|
||||||
#elif defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
|
||||||
struct answer_trie_node *next_free_answer_trie_node;
|
|
||||||
struct answer_trie_hash *next_free_answer_trie_hash;
|
|
||||||
#endif
|
|
||||||
#if defined(THREADS_FULL_SHARING)
|
#if defined(THREADS_FULL_SHARING)
|
||||||
struct local_page_entry answer_ref_node_pages;
|
struct local_page_entry answer_ref_node_pages;
|
||||||
#endif
|
#endif
|
||||||
#endif /* YAPOR - THREADS */
|
struct local_page_entry global_trie_node_pages;
|
||||||
|
struct local_page_entry global_trie_hash_pages;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
#endif /* TABLING && (YAPOR || THREADS) */
|
#endif /* TABLING && (YAPOR || THREADS) */
|
||||||
|
|
||||||
@ -351,6 +341,7 @@ struct global_optyap_data {
|
|||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define GLOBAL_pages_alloc (GLOBAL_optyap_data.pages.alloc_pages)
|
||||||
#define GLOBAL_pages_void (GLOBAL_optyap_data.pages.void_pages)
|
#define GLOBAL_pages_void (GLOBAL_optyap_data.pages.void_pages)
|
||||||
#define GLOBAL_pages_tab_ent (GLOBAL_optyap_data.pages.table_entry_pages)
|
#define GLOBAL_pages_tab_ent (GLOBAL_optyap_data.pages.table_entry_pages)
|
||||||
#define GLOBAL_pages_sg_ent (GLOBAL_optyap_data.pages.subgoal_entry_pages)
|
#define GLOBAL_pages_sg_ent (GLOBAL_optyap_data.pages.subgoal_entry_pages)
|
||||||
@ -360,6 +351,7 @@ struct global_optyap_data {
|
|||||||
#define GLOBAL_pages_sg_hash (GLOBAL_optyap_data.pages.subgoal_trie_hash_pages)
|
#define GLOBAL_pages_sg_hash (GLOBAL_optyap_data.pages.subgoal_trie_hash_pages)
|
||||||
#define GLOBAL_pages_ans_node (GLOBAL_optyap_data.pages.answer_trie_node_pages)
|
#define GLOBAL_pages_ans_node (GLOBAL_optyap_data.pages.answer_trie_node_pages)
|
||||||
#define GLOBAL_pages_ans_hash (GLOBAL_optyap_data.pages.answer_trie_hash_pages)
|
#define GLOBAL_pages_ans_hash (GLOBAL_optyap_data.pages.answer_trie_hash_pages)
|
||||||
|
#define GLOBAL_pages_ans_ref_node (GLOBAL_optyap_data.pages.answer_ref_node_pages)
|
||||||
#define GLOBAL_pages_gt_node (GLOBAL_optyap_data.pages.global_trie_node_pages)
|
#define GLOBAL_pages_gt_node (GLOBAL_optyap_data.pages.global_trie_node_pages)
|
||||||
#define GLOBAL_pages_gt_hash (GLOBAL_optyap_data.pages.global_trie_hash_pages)
|
#define GLOBAL_pages_gt_hash (GLOBAL_optyap_data.pages.global_trie_hash_pages)
|
||||||
#define GLOBAL_pages_or_fr (GLOBAL_optyap_data.pages.or_frame_pages)
|
#define GLOBAL_pages_or_fr (GLOBAL_optyap_data.pages.or_frame_pages)
|
||||||
@ -479,6 +471,8 @@ struct local_optyap_data {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define LOCAL_pages_void (LOCAL_optyap_data.pages.void_pages)
|
#define LOCAL_pages_void (LOCAL_optyap_data.pages.void_pages)
|
||||||
|
#define LOCAL_pages_tab_ent (LOCAL_optyap_data.pages.table_entry_pages)
|
||||||
|
#define LOCAL_pages_sg_ent (LOCAL_optyap_data.pages.subgoal_entry_pages)
|
||||||
#define LOCAL_pages_sg_fr (LOCAL_optyap_data.pages.subgoal_frame_pages)
|
#define LOCAL_pages_sg_fr (LOCAL_optyap_data.pages.subgoal_frame_pages)
|
||||||
#define LOCAL_pages_dep_fr (LOCAL_optyap_data.pages.dependency_frame_pages)
|
#define LOCAL_pages_dep_fr (LOCAL_optyap_data.pages.dependency_frame_pages)
|
||||||
#define LOCAL_pages_sg_node (LOCAL_optyap_data.pages.subgoal_trie_node_pages)
|
#define LOCAL_pages_sg_node (LOCAL_optyap_data.pages.subgoal_trie_node_pages)
|
||||||
@ -486,10 +480,9 @@ struct local_optyap_data {
|
|||||||
#define LOCAL_pages_ans_node (LOCAL_optyap_data.pages.answer_trie_node_pages)
|
#define LOCAL_pages_ans_node (LOCAL_optyap_data.pages.answer_trie_node_pages)
|
||||||
#define LOCAL_pages_ans_hash (LOCAL_optyap_data.pages.answer_trie_hash_pages)
|
#define LOCAL_pages_ans_hash (LOCAL_optyap_data.pages.answer_trie_hash_pages)
|
||||||
#define LOCAL_pages_ans_ref_node (LOCAL_optyap_data.pages.answer_ref_node_pages)
|
#define LOCAL_pages_ans_ref_node (LOCAL_optyap_data.pages.answer_ref_node_pages)
|
||||||
#define LOCAL_next_free_sg_node (LOCAL_optyap_data.pages.next_free_subgoal_trie_node)
|
#define LOCAL_pages_gt_node (LOCAL_optyap_data.pages.global_trie_node_pages)
|
||||||
#define LOCAL_next_free_sg_hash (LOCAL_optyap_data.pages.next_free_subgoal_trie_hash)
|
#define LOCAL_pages_gt_hash (LOCAL_optyap_data.pages.global_trie_hash_pages)
|
||||||
#define LOCAL_next_free_ans_node (LOCAL_optyap_data.pages.next_free_answer_trie_node)
|
#define LOCAL_next_free_ans_node (LOCAL_optyap_data.pages.next_free_answer_trie_node)
|
||||||
#define LOCAL_next_free_ans_hash (LOCAL_optyap_data.pages.next_free_answer_trie_hash)
|
|
||||||
#define LOCAL_lock (LOCAL_optyap_data.lock)
|
#define LOCAL_lock (LOCAL_optyap_data.lock)
|
||||||
#define LOCAL_load (LOCAL_optyap_data.load)
|
#define LOCAL_load (LOCAL_optyap_data.load)
|
||||||
#ifdef YAPOR_THREADS
|
#ifdef YAPOR_THREADS
|
||||||
@ -538,6 +531,8 @@ struct local_optyap_data {
|
|||||||
#define LOCAL_ma_hash_table (LOCAL_optyap_data.ma_hash_table)
|
#define LOCAL_ma_hash_table (LOCAL_optyap_data.ma_hash_table)
|
||||||
|
|
||||||
#define REMOTE_pages_void(wid) (REMOTE(wid)->optyap_data_.pages.void_pages)
|
#define REMOTE_pages_void(wid) (REMOTE(wid)->optyap_data_.pages.void_pages)
|
||||||
|
#define REMOTE_pages_tab_ent(wid) (REMOTE(wid)->optyap_data_.pages.table_entry_pages)
|
||||||
|
#define REMOTE_pages_sg_ent(wid) (REMOTE(wid)->optyap_data_.pages.subgoal_entry_pages)
|
||||||
#define REMOTE_pages_sg_fr(wid) (REMOTE(wid)->optyap_data_.pages.subgoal_frame_pages)
|
#define REMOTE_pages_sg_fr(wid) (REMOTE(wid)->optyap_data_.pages.subgoal_frame_pages)
|
||||||
#define REMOTE_pages_dep_fr(wid) (REMOTE(wid)->optyap_data_.pages.dependency_frame_pages)
|
#define REMOTE_pages_dep_fr(wid) (REMOTE(wid)->optyap_data_.pages.dependency_frame_pages)
|
||||||
#define REMOTE_pages_sg_node(wid) (REMOTE(wid)->optyap_data_.pages.subgoal_trie_node_pages)
|
#define REMOTE_pages_sg_node(wid) (REMOTE(wid)->optyap_data_.pages.subgoal_trie_node_pages)
|
||||||
@ -545,10 +540,9 @@ struct local_optyap_data {
|
|||||||
#define REMOTE_pages_ans_node(wid) (REMOTE(wid)->optyap_data_.pages.answer_trie_node_pages)
|
#define REMOTE_pages_ans_node(wid) (REMOTE(wid)->optyap_data_.pages.answer_trie_node_pages)
|
||||||
#define REMOTE_pages_ans_hash(wid) (REMOTE(wid)->optyap_data_.pages.answer_trie_hash_pages)
|
#define REMOTE_pages_ans_hash(wid) (REMOTE(wid)->optyap_data_.pages.answer_trie_hash_pages)
|
||||||
#define REMOTE_pages_ans_ref_node(wid) (REMOTE(wid)->optyap_data_.pages.answer_ref_node_pages)
|
#define REMOTE_pages_ans_ref_node(wid) (REMOTE(wid)->optyap_data_.pages.answer_ref_node_pages)
|
||||||
#define REMOTE_next_free_sg_node(wid) (REMOTE(wid)->optyap_data_.pages.next_free_subgoal_trie_node)
|
#define REMOTE_pages_gt_node(wid) (REMOTE(wid)->optyap_data_.pages.global_trie_node_pages)
|
||||||
#define REMOTE_next_free_sg_hash(wid) (REMOTE(wid)->optyap_data_.pages.next_free_subgoal_trie_hash)
|
#define REMOTE_pages_gt_hash(wid) (REMOTE(wid)->optyap_data_.pages.global_trie_hash_pages)
|
||||||
#define REMOTE_next_free_ans_node(wid) (REMOTE(wid)->optyap_data_.pages.next_free_answer_trie_node)
|
#define REMOTE_next_free_ans_node(wid) (REMOTE(wid)->optyap_data_.pages.next_free_answer_trie_node)
|
||||||
#define REMOTE_next_free_ans_hash(wid) (REMOTE(wid)->optyap_data_.pages.next_free_answer_trie_hash)
|
|
||||||
#define REMOTE_lock(wid) (REMOTE(wid)->optyap_data_.lock)
|
#define REMOTE_lock(wid) (REMOTE(wid)->optyap_data_.lock)
|
||||||
#define REMOTE_load(wid) (REMOTE(wid)->optyap_data_.load)
|
#define REMOTE_load(wid) (REMOTE(wid)->optyap_data_.load)
|
||||||
#ifdef YAPOR_THREADS
|
#ifdef YAPOR_THREADS
|
||||||
|
6
OPTYap/tab.macros.h
Executable file → Normal file
6
OPTYap/tab.macros.h
Executable file → Normal file
@ -744,7 +744,7 @@ static inline sg_node_ptr get_subgoal_trie_for_abolish(tab_ent_ptr tab_ent USES_
|
|||||||
sg_node_ptr *sg_node_addr = (sg_node_ptr *) get_thread_bucket((void **) &TabEnt_subgoal_trie(tab_ent));
|
sg_node_ptr *sg_node_addr = (sg_node_ptr *) get_thread_bucket((void **) &TabEnt_subgoal_trie(tab_ent));
|
||||||
sg_node_ptr sg_node = *sg_node_addr;
|
sg_node_ptr sg_node = *sg_node_addr;
|
||||||
*sg_node_addr = NULL;
|
*sg_node_addr = NULL;
|
||||||
if (worker_id == 0)
|
if (GLOBAL_NOfThreads == 1)
|
||||||
abolish_thread_buckets((void **) &TabEnt_subgoal_trie(tab_ent));
|
abolish_thread_buckets((void **) &TabEnt_subgoal_trie(tab_ent));
|
||||||
return sg_node;
|
return sg_node;
|
||||||
#else
|
#else
|
||||||
@ -804,7 +804,7 @@ static inline sg_fr_ptr get_subgoal_frame_for_abolish(sg_node_ptr sg_node USES_R
|
|||||||
#if defined(THREADS_SUBGOAL_SHARING)
|
#if defined(THREADS_SUBGOAL_SHARING)
|
||||||
sg_fr_ptr *sg_fr_addr = (sg_fr_ptr *) get_thread_bucket((void **) UNTAG_SUBGOAL_NODE(TrNode_sg_fr(sg_node)));
|
sg_fr_ptr *sg_fr_addr = (sg_fr_ptr *) get_thread_bucket((void **) UNTAG_SUBGOAL_NODE(TrNode_sg_fr(sg_node)));
|
||||||
sg_fr_ptr sg_fr = *sg_fr_addr;
|
sg_fr_ptr sg_fr = *sg_fr_addr;
|
||||||
if (worker_id == 0)
|
if (GLOBAL_NOfThreads == 1)
|
||||||
abolish_thread_buckets((void **) UNTAG_SUBGOAL_NODE(TrNode_sg_fr(sg_node)));
|
abolish_thread_buckets((void **) UNTAG_SUBGOAL_NODE(TrNode_sg_fr(sg_node)));
|
||||||
else
|
else
|
||||||
*sg_fr_addr = NULL;
|
*sg_fr_addr = NULL;
|
||||||
@ -812,7 +812,7 @@ static inline sg_fr_ptr get_subgoal_frame_for_abolish(sg_node_ptr sg_node USES_R
|
|||||||
#elif defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#elif defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
sg_fr_ptr *sg_fr_addr = (sg_fr_ptr *) get_thread_bucket((void **) &SgEnt_sg_fr((sg_ent_ptr) UNTAG_SUBGOAL_NODE(TrNode_sg_fr(sg_node))));
|
sg_fr_ptr *sg_fr_addr = (sg_fr_ptr *) get_thread_bucket((void **) &SgEnt_sg_fr((sg_ent_ptr) UNTAG_SUBGOAL_NODE(TrNode_sg_fr(sg_node))));
|
||||||
sg_fr_ptr sg_fr = *sg_fr_addr;
|
sg_fr_ptr sg_fr = *sg_fr_addr;
|
||||||
if (worker_id == 0)
|
if (GLOBAL_NOfThreads == 1)
|
||||||
abolish_thread_buckets((void **) &SgEnt_sg_fr((sg_ent_ptr) UNTAG_SUBGOAL_NODE(TrNode_sg_fr(sg_node))));
|
abolish_thread_buckets((void **) &SgEnt_sg_fr((sg_ent_ptr) UNTAG_SUBGOAL_NODE(TrNode_sg_fr(sg_node))));
|
||||||
else
|
else
|
||||||
*sg_fr_addr = NULL;
|
*sg_fr_addr = NULL;
|
||||||
|
@ -21,28 +21,32 @@
|
|||||||
#include "YapHeap.h"
|
#include "YapHeap.h"
|
||||||
#include "tab.macros.h"
|
#include "tab.macros.h"
|
||||||
|
|
||||||
static inline sg_node_ptr subgoal_trie_check_insert_entry(tab_ent_ptr, sg_node_ptr, Term);
|
static inline sg_node_ptr subgoal_trie_check_insert_entry(tab_ent_ptr, sg_node_ptr, Term USES_REGS);
|
||||||
static inline sg_node_ptr subgoal_trie_check_insert_gt_entry(tab_ent_ptr, sg_node_ptr, Term);
|
static inline sg_node_ptr subgoal_trie_check_insert_gt_entry(tab_ent_ptr, sg_node_ptr, Term USES_REGS);
|
||||||
static inline ans_node_ptr answer_trie_check_insert_entry(sg_fr_ptr, ans_node_ptr, Term, int);
|
static inline ans_node_ptr answer_trie_check_insert_entry(sg_fr_ptr, ans_node_ptr, Term, int USES_REGS);
|
||||||
static inline ans_node_ptr answer_trie_check_insert_gt_entry(sg_fr_ptr, ans_node_ptr, Term, int);
|
static inline ans_node_ptr answer_trie_check_insert_gt_entry(sg_fr_ptr, ans_node_ptr, Term, int USES_REGS);
|
||||||
static inline gt_node_ptr global_trie_check_insert_entry(gt_node_ptr, Term);
|
static inline gt_node_ptr global_trie_check_insert_entry(gt_node_ptr, Term USES_REGS);
|
||||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
||||||
static inline gt_node_ptr global_trie_check_insert_gt_entry(gt_node_ptr, Term);
|
static inline gt_node_ptr global_trie_check_insert_gt_entry(gt_node_ptr, Term USES_REGS);
|
||||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr, sg_node_ptr, Term, int *, CELL **);
|
static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr, sg_node_ptr, Term, int *, CELL ** USES_REGS);
|
||||||
static inline sg_node_ptr subgoal_search_terms_loop(tab_ent_ptr, sg_node_ptr, Term, int *, CELL **);
|
static inline sg_node_ptr subgoal_search_terms_loop(tab_ent_ptr, sg_node_ptr, Term, int *, CELL ** USES_REGS);
|
||||||
static inline ans_node_ptr answer_search_loop(sg_fr_ptr, ans_node_ptr, Term, int *);
|
static inline ans_node_ptr answer_search_loop(sg_fr_ptr, ans_node_ptr, Term, int * USES_REGS);
|
||||||
static inline ans_node_ptr answer_search_terms_loop(sg_fr_ptr, ans_node_ptr, Term, int *);
|
static inline ans_node_ptr answer_search_terms_loop(sg_fr_ptr, ans_node_ptr, Term, int * USES_REGS);
|
||||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
||||||
static inline gt_node_ptr subgoal_search_global_trie_terms_loop(Term, int *, CELL **, CELL *);
|
static inline gt_node_ptr subgoal_search_global_trie_terms_loop(Term, int *, CELL **, CELL * USES_REGS);
|
||||||
static inline gt_node_ptr answer_search_global_trie_terms_loop(Term, int *, CELL *);
|
static inline gt_node_ptr answer_search_global_trie_terms_loop(Term, int *, CELL * USES_REGS);
|
||||||
#else
|
#else
|
||||||
static inline gt_node_ptr subgoal_search_global_trie_loop(Term, int *, CELL **);
|
static inline gt_node_ptr subgoal_search_global_trie_loop(Term, int *, CELL ** USES_REGS);
|
||||||
static inline gt_node_ptr answer_search_global_trie_loop(Term, int *);
|
static inline gt_node_ptr answer_search_global_trie_loop(Term, int * USES_REGS);
|
||||||
#endif /* GLOBAL_TRIE_MODE */
|
#endif /* GLOBAL_TRIE_MODE */
|
||||||
static inline CELL *load_answer_loop(ans_node_ptr);
|
static inline CELL *load_answer_loop(ans_node_ptr USES_REGS);
|
||||||
static inline CELL *load_substitution_loop(gt_node_ptr, int *, CELL *);
|
static inline CELL *load_substitution_loop(gt_node_ptr, int *, CELL * USES_REGS);
|
||||||
static inline CELL *exec_substitution_loop(gt_node_ptr, CELL **, CELL *);
|
static inline CELL *exec_substitution_loop(gt_node_ptr, CELL **, CELL * USES_REGS);
|
||||||
|
#ifdef MODE_DIRECTED_TABLING
|
||||||
|
static inline ans_node_ptr answer_search_min_max(sg_fr_ptr, ans_node_ptr, Term, int USES_REGS);
|
||||||
|
static void invalidate_answer_trie(ans_node_ptr, sg_fr_ptr, int USES_REGS);
|
||||||
|
#endif /* MODE_DIRECTED_TABLING */
|
||||||
|
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
#ifdef TABLING_INNER_CUTS
|
#ifdef TABLING_INNER_CUTS
|
||||||
@ -54,15 +58,15 @@ static int update_answer_trie_branch(ans_node_ptr);
|
|||||||
static void update_answer_trie_branch(ans_node_ptr, int);
|
static void update_answer_trie_branch(ans_node_ptr, int);
|
||||||
#endif
|
#endif
|
||||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
||||||
static void free_global_trie_branch(gt_node_ptr, int);
|
static void free_global_trie_branch(gt_node_ptr, int USES_REGS);
|
||||||
#else
|
#else
|
||||||
static void free_global_trie_branch(gt_node_ptr);
|
static void free_global_trie_branch(gt_node_ptr USES_REGS);
|
||||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
static void traverse_subgoal_trie(sg_node_ptr, char *, int, int *, int, int);
|
static void traverse_subgoal_trie(sg_node_ptr, char *, int, int *, int, int USES_REGS);
|
||||||
static void traverse_answer_trie(ans_node_ptr, char *, int, int *, int, int, int);
|
static void traverse_answer_trie(ans_node_ptr, char *, int, int *, int, int, int USES_REGS);
|
||||||
static void traverse_global_trie(gt_node_ptr, char *, int, int *, int, int);
|
static void traverse_global_trie(gt_node_ptr, char *, int, int *, int, int USES_REGS);
|
||||||
static void traverse_global_trie_for_term(gt_node_ptr, char *, int *, int *, int *, int);
|
static void traverse_global_trie_for_term(gt_node_ptr, char *, int *, int *, int *, int USES_REGS);
|
||||||
static inline void traverse_trie_node(Term, char *, int *, int *, int *, int);
|
static inline void traverse_trie_node(Term, char *, int *, int *, int *, int USES_REGS);
|
||||||
static inline void traverse_update_arity(char *, int *, int *);
|
static inline void traverse_update_arity(char *, int *, int *);
|
||||||
|
|
||||||
|
|
||||||
@ -123,13 +127,13 @@ static struct trie_statistics{
|
|||||||
#endif /*THREADS */
|
#endif /*THREADS */
|
||||||
|
|
||||||
#if defined(THREADS_SUBGOAL_SHARING) || defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#if defined(THREADS_SUBGOAL_SHARING) || defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
#define IF_ABOLISH_SUBGOAL_TRIE_SHARED_DATA_STRUCTURES if (worker_id == 0)
|
#define IF_ABOLISH_SUBGOAL_TRIE_SHARED_DATA_STRUCTURES if (GLOBAL_NOfThreads == 1)
|
||||||
#else
|
#else
|
||||||
#define IF_ABOLISH_SUBGOAL_TRIE_SHARED_DATA_STRUCTURES
|
#define IF_ABOLISH_SUBGOAL_TRIE_SHARED_DATA_STRUCTURES
|
||||||
#endif /* THREADS_SUBGOAL_SHARING || THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
#endif /* THREADS_SUBGOAL_SHARING || THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
||||||
|
|
||||||
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
#define IF_ABOLISH_ANSWER_TRIE_SHARED_DATA_STRUCTURES if (worker_id == 0)
|
#define IF_ABOLISH_ANSWER_TRIE_SHARED_DATA_STRUCTURES if (GLOBAL_NOfThreads == 1)
|
||||||
#else
|
#else
|
||||||
#define IF_ABOLISH_ANSWER_TRIE_SHARED_DATA_STRUCTURES
|
#define IF_ABOLISH_ANSWER_TRIE_SHARED_DATA_STRUCTURES
|
||||||
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
||||||
@ -151,11 +155,11 @@ static struct trie_statistics{
|
|||||||
#define CHECK_DECREMENT_GLOBAL_TRIE_FOR_SUBTERMS_REFERENCE(REF,MODE) \
|
#define CHECK_DECREMENT_GLOBAL_TRIE_FOR_SUBTERMS_REFERENCE(REF,MODE) \
|
||||||
CHECK_DECREMENT_GLOBAL_TRIE_REFERENCE(REF,MODE)
|
CHECK_DECREMENT_GLOBAL_TRIE_REFERENCE(REF,MODE)
|
||||||
#define FREE_GLOBAL_TRIE_BRANCH(NODE,MODE) \
|
#define FREE_GLOBAL_TRIE_BRANCH(NODE,MODE) \
|
||||||
free_global_trie_branch(NODE,MODE)
|
free_global_trie_branch(NODE,MODE PASS_REGS)
|
||||||
#else
|
#else
|
||||||
#define CHECK_DECREMENT_GLOBAL_TRIE_FOR_SUBTERMS_REFERENCE(REF,MODE)
|
#define CHECK_DECREMENT_GLOBAL_TRIE_FOR_SUBTERMS_REFERENCE(REF,MODE)
|
||||||
#define FREE_GLOBAL_TRIE_BRANCH(NODE,MODE) \
|
#define FREE_GLOBAL_TRIE_BRANCH(NODE,MODE) \
|
||||||
free_global_trie_branch(NODE)
|
free_global_trie_branch(NODE PASS_REGS)
|
||||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
|
|
||||||
|
|
||||||
@ -218,7 +222,7 @@ static struct trie_statistics{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static inline CELL *exec_substitution_loop(gt_node_ptr current_node, CELL **stack_vars_ptr, CELL *stack_terms) {
|
static inline CELL *exec_substitution_loop(gt_node_ptr current_node, CELL **stack_vars_ptr, CELL *stack_terms USES_REGS) {
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
===========
|
===========
|
||||||
| |
|
| |
|
||||||
@ -256,7 +260,6 @@ static inline CELL *exec_substitution_loop(gt_node_ptr current_node, CELL **stac
|
|||||||
LOCAL_TrailTop --> | | <-- stack_terms_base (TRIE_COMPACT_PAIRS)
|
LOCAL_TrailTop --> | | <-- stack_terms_base (TRIE_COMPACT_PAIRS)
|
||||||
-----------
|
-----------
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
CACHE_REGS
|
|
||||||
CELL *stack_vars = *stack_vars_ptr;
|
CELL *stack_vars = *stack_vars_ptr;
|
||||||
CELL *stack_terms_limit = (CELL *) TR;
|
CELL *stack_terms_limit = (CELL *) TR;
|
||||||
#ifdef TRIE_COMPACT_PAIRS
|
#ifdef TRIE_COMPACT_PAIRS
|
||||||
@ -270,7 +273,7 @@ static inline CELL *exec_substitution_loop(gt_node_ptr current_node, CELL **stac
|
|||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
||||||
if (t > VarIndexOfTableTerm(MAX_TABLE_VARS)) {
|
if (t > VarIndexOfTableTerm(MAX_TABLE_VARS)) {
|
||||||
stack_terms = exec_substitution_loop((gt_node_ptr) t, &stack_vars, stack_terms);
|
stack_terms = exec_substitution_loop((gt_node_ptr) t, &stack_vars, stack_terms PASS_REGS);
|
||||||
} else
|
} else
|
||||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
{
|
{
|
||||||
@ -477,10 +480,10 @@ static void update_answer_trie_branch(ans_node_ptr current_node, int position) {
|
|||||||
|
|
||||||
|
|
||||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
||||||
static void free_global_trie_branch(gt_node_ptr current_node, int mode) {
|
static void free_global_trie_branch(gt_node_ptr current_node, int mode USES_REGS) {
|
||||||
Term t = TrNode_entry(current_node);
|
Term t = TrNode_entry(current_node);
|
||||||
#else
|
#else
|
||||||
static void free_global_trie_branch(gt_node_ptr current_node) {
|
static void free_global_trie_branch(gt_node_ptr current_node USES_REGS) {
|
||||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
gt_node_ptr parent_node, child_node;
|
gt_node_ptr parent_node, child_node;
|
||||||
|
|
||||||
@ -578,8 +581,7 @@ static void free_global_trie_branch(gt_node_ptr current_node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_index, int *arity, int mode, int position) {
|
static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_index, int *arity, int mode, int position USES_REGS) {
|
||||||
CACHE_REGS
|
|
||||||
int *current_arity = NULL, current_str_index = 0, current_mode = 0;
|
int *current_arity = NULL, current_str_index = 0, current_mode = 0;
|
||||||
|
|
||||||
/* test if hashing */
|
/* test if hashing */
|
||||||
@ -593,7 +595,7 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
|
|||||||
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
|
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
|
||||||
do {
|
do {
|
||||||
if (*bucket) {
|
if (*bucket) {
|
||||||
traverse_subgoal_trie(*bucket, str, str_index, arity, mode, TRAVERSE_POSITION_FIRST);
|
traverse_subgoal_trie(*bucket, str, str_index, arity, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
|
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
|
||||||
#ifdef TRIE_COMPACT_PAIRS
|
#ifdef TRIE_COMPACT_PAIRS
|
||||||
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
|
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
|
||||||
@ -618,7 +620,7 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
|
|||||||
|
|
||||||
/* process current trie node */
|
/* process current trie node */
|
||||||
TrStat_sg_nodes++;
|
TrStat_sg_nodes++;
|
||||||
traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode, TRAVERSE_TYPE_SUBGOAL);
|
traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode, TRAVERSE_TYPE_SUBGOAL PASS_REGS);
|
||||||
|
|
||||||
/* show answers ... */
|
/* show answers ... */
|
||||||
if (IS_SUBGOAL_LEAF_NODE(current_node)) {
|
if (IS_SUBGOAL_LEAF_NODE(current_node)) {
|
||||||
@ -641,7 +643,7 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
|
|||||||
SHOW_TABLE_STRUCTURE(" TRUE\n");
|
SHOW_TABLE_STRUCTURE(" TRUE\n");
|
||||||
} else {
|
} else {
|
||||||
arity[0] = 0;
|
arity[0] = 0;
|
||||||
traverse_answer_trie(TrNode_child(SgFr_answer_trie(sg_fr)), &str[str_index], 0, arity, 0, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST);
|
traverse_answer_trie(TrNode_child(SgFr_answer_trie(sg_fr)), &str[str_index], 0, arity, 0, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
if (SgFr_state(sg_fr) < complete) {
|
if (SgFr_state(sg_fr) < complete) {
|
||||||
TrStat_sg_incomplete++;
|
TrStat_sg_incomplete++;
|
||||||
SHOW_TABLE_STRUCTURE(" ---> INCOMPLETE\n");
|
SHOW_TABLE_STRUCTURE(" ---> INCOMPLETE\n");
|
||||||
@ -650,7 +652,7 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
/* ... or continue with child node */
|
/* ... or continue with child node */
|
||||||
traverse_subgoal_trie(TrNode_child(current_node), str, str_index, arity, mode, TRAVERSE_POSITION_FIRST);
|
traverse_subgoal_trie(TrNode_child(current_node), str, str_index, arity, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
/* restore the initial state and continue with sibling nodes */
|
/* restore the initial state and continue with sibling nodes */
|
||||||
if (position == TRAVERSE_POSITION_FIRST) {
|
if (position == TRAVERSE_POSITION_FIRST) {
|
||||||
str_index = current_str_index;
|
str_index = current_str_index;
|
||||||
@ -665,7 +667,7 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
|
|||||||
if (arity[arity[0]] == -1)
|
if (arity[arity[0]] == -1)
|
||||||
str[str_index - 1] = '|';
|
str[str_index - 1] = '|';
|
||||||
#endif /* TRIE_COMPACT_PAIRS */
|
#endif /* TRIE_COMPACT_PAIRS */
|
||||||
traverse_subgoal_trie(current_node, str, str_index, arity, mode, TRAVERSE_POSITION_NEXT);
|
traverse_subgoal_trie(current_node, str, str_index, arity, mode, TRAVERSE_POSITION_NEXT PASS_REGS);
|
||||||
current_node = TrNode_next(current_node);
|
current_node = TrNode_next(current_node);
|
||||||
}
|
}
|
||||||
free(current_arity);
|
free(current_arity);
|
||||||
@ -674,8 +676,7 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str, int str_i
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_index, int *arity, int var_index, int mode, int position) {
|
static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_index, int *arity, int var_index, int mode, int position USES_REGS) {
|
||||||
CACHE_REGS
|
|
||||||
int *current_arity = NULL, current_str_index = 0, current_var_index = 0, current_mode = 0;
|
int *current_arity = NULL, current_str_index = 0, current_var_index = 0, current_mode = 0;
|
||||||
|
|
||||||
/* test if hashing */
|
/* test if hashing */
|
||||||
@ -689,7 +690,7 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_i
|
|||||||
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
|
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
|
||||||
do {
|
do {
|
||||||
if (*bucket) {
|
if (*bucket) {
|
||||||
traverse_answer_trie(*bucket, str, str_index, arity, var_index, mode, TRAVERSE_POSITION_FIRST);
|
traverse_answer_trie(*bucket, str, str_index, arity, var_index, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
|
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
|
||||||
#ifdef TRIE_COMPACT_PAIRS
|
#ifdef TRIE_COMPACT_PAIRS
|
||||||
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
|
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
|
||||||
@ -721,7 +722,7 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_i
|
|||||||
|
|
||||||
/* process current trie node */
|
/* process current trie node */
|
||||||
TrStat_ans_nodes++;
|
TrStat_ans_nodes++;
|
||||||
traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode, TRAVERSE_TYPE_ANSWER);
|
traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode, TRAVERSE_TYPE_ANSWER PASS_REGS);
|
||||||
|
|
||||||
/* show answer .... */
|
/* show answer .... */
|
||||||
if (IS_ANSWER_LEAF_NODE(current_node)) {
|
if (IS_ANSWER_LEAF_NODE(current_node)) {
|
||||||
@ -738,7 +739,7 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_i
|
|||||||
#endif /* TABLING_INNER_CUTS */
|
#endif /* TABLING_INNER_CUTS */
|
||||||
/* ... or continue with child node */
|
/* ... or continue with child node */
|
||||||
else
|
else
|
||||||
traverse_answer_trie(TrNode_child(current_node), str, str_index, arity, var_index, mode, TRAVERSE_POSITION_FIRST);
|
traverse_answer_trie(TrNode_child(current_node), str, str_index, arity, var_index, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
|
|
||||||
/* restore the initial state and continue with sibling nodes */
|
/* restore the initial state and continue with sibling nodes */
|
||||||
if (position == TRAVERSE_POSITION_FIRST) {
|
if (position == TRAVERSE_POSITION_FIRST) {
|
||||||
@ -755,7 +756,7 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_i
|
|||||||
if (arity[arity[0]] == -1)
|
if (arity[arity[0]] == -1)
|
||||||
str[str_index - 1] = '|';
|
str[str_index - 1] = '|';
|
||||||
#endif /* TRIE_COMPACT_PAIRS */
|
#endif /* TRIE_COMPACT_PAIRS */
|
||||||
traverse_answer_trie(current_node, str, str_index, arity, var_index, mode, TRAVERSE_POSITION_NEXT);
|
traverse_answer_trie(current_node, str, str_index, arity, var_index, mode, TRAVERSE_POSITION_NEXT PASS_REGS);
|
||||||
current_node = TrNode_next(current_node);
|
current_node = TrNode_next(current_node);
|
||||||
}
|
}
|
||||||
free(current_arity);
|
free(current_arity);
|
||||||
@ -765,8 +766,7 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str, int str_i
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_index, int *arity, int mode, int position) {
|
static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_index, int *arity, int mode, int position USES_REGS) {
|
||||||
CACHE_REGS
|
|
||||||
int *current_arity = NULL, current_str_index = 0, current_mode = 0;
|
int *current_arity = NULL, current_str_index = 0, current_mode = 0;
|
||||||
|
|
||||||
/* test if hashing */
|
/* test if hashing */
|
||||||
@ -780,7 +780,7 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_in
|
|||||||
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
|
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
|
||||||
do {
|
do {
|
||||||
if (*bucket) {
|
if (*bucket) {
|
||||||
traverse_global_trie(*bucket, str, str_index, arity, mode, TRAVERSE_POSITION_FIRST);
|
traverse_global_trie(*bucket, str, str_index, arity, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
|
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
|
||||||
#ifdef TRIE_COMPACT_PAIRS
|
#ifdef TRIE_COMPACT_PAIRS
|
||||||
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
|
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
|
||||||
@ -805,11 +805,11 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_in
|
|||||||
|
|
||||||
/* process current trie node */
|
/* process current trie node */
|
||||||
TrStat_gt_nodes++;
|
TrStat_gt_nodes++;
|
||||||
traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode, TRAVERSE_TYPE_GT_SUBGOAL);
|
traverse_trie_node(TrNode_entry(current_node), str, &str_index, arity, &mode, TRAVERSE_TYPE_GT_SUBGOAL PASS_REGS);
|
||||||
|
|
||||||
/* continue with child node ... */
|
/* continue with child node ... */
|
||||||
if (arity[0] != 0 || mode != TRAVERSE_MODE_NORMAL)
|
if (arity[0] != 0 || mode != TRAVERSE_MODE_NORMAL)
|
||||||
traverse_global_trie(TrNode_child(current_node), str, str_index, arity, mode, TRAVERSE_POSITION_FIRST);
|
traverse_global_trie(TrNode_child(current_node), str, str_index, arity, mode, TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
/* ... or show term */
|
/* ... or show term */
|
||||||
else {
|
else {
|
||||||
TrStat_gt_terms++;
|
TrStat_gt_terms++;
|
||||||
@ -831,7 +831,7 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_in
|
|||||||
if (arity[arity[0]] == -1)
|
if (arity[arity[0]] == -1)
|
||||||
str[str_index - 1] = '|';
|
str[str_index - 1] = '|';
|
||||||
#endif /* TRIE_COMPACT_PAIRS */
|
#endif /* TRIE_COMPACT_PAIRS */
|
||||||
traverse_global_trie(current_node, str, str_index, arity, mode, TRAVERSE_POSITION_NEXT);
|
traverse_global_trie(current_node, str, str_index, arity, mode, TRAVERSE_POSITION_NEXT PASS_REGS);
|
||||||
current_node = TrNode_next(current_node);
|
current_node = TrNode_next(current_node);
|
||||||
}
|
}
|
||||||
free(current_arity);
|
free(current_arity);
|
||||||
@ -841,16 +841,15 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_in
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void traverse_global_trie_for_term(gt_node_ptr current_node, char *str, int *str_index, int *arity, int *mode, int type) {
|
static void traverse_global_trie_for_term(gt_node_ptr current_node, char *str, int *str_index, int *arity, int *mode, int type USES_REGS) {
|
||||||
if (TrNode_parent(current_node) != GLOBAL_root_gt)
|
if (TrNode_parent(current_node) != GLOBAL_root_gt)
|
||||||
traverse_global_trie_for_term(TrNode_parent(current_node), str, str_index, arity, mode, type);
|
traverse_global_trie_for_term(TrNode_parent(current_node), str, str_index, arity, mode, type PASS_REGS);
|
||||||
traverse_trie_node(TrNode_entry(current_node), str, str_index, arity, mode, type);
|
traverse_trie_node(TrNode_entry(current_node), str, str_index, arity, mode, type PASS_REGS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int *arity, int *mode_ptr, int type) {
|
static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int *arity, int *mode_ptr, int type USES_REGS) {
|
||||||
CACHE_REGS
|
|
||||||
int mode = *mode_ptr;
|
int mode = *mode_ptr;
|
||||||
int str_index = *str_index_ptr;
|
int str_index = *str_index_ptr;
|
||||||
|
|
||||||
@ -903,7 +902,7 @@ static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int
|
|||||||
TrStat_gt_refs++;
|
TrStat_gt_refs++;
|
||||||
/* (type % 2 + 2): TRAVERSE_TYPE_ANSWER --> TRAVERSE_TYPE_GT_ANSWER */
|
/* (type % 2 + 2): TRAVERSE_TYPE_ANSWER --> TRAVERSE_TYPE_GT_ANSWER */
|
||||||
/* (type % 2 + 2): TRAVERSE_TYPE_SUBGOAL --> TRAVERSE_TYPE_GT_SUBGOAL */
|
/* (type % 2 + 2): TRAVERSE_TYPE_SUBGOAL --> TRAVERSE_TYPE_GT_SUBGOAL */
|
||||||
traverse_global_trie_for_term((gt_node_ptr) t, str, &str_index, arity, &mode, type % 2 + 2);
|
traverse_global_trie_for_term((gt_node_ptr) t, str, &str_index, arity, &mode, type % 2 + 2 PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
if (type == TRAVERSE_TYPE_SUBGOAL || type == TRAVERSE_TYPE_GT_SUBGOAL)
|
if (type == TRAVERSE_TYPE_SUBGOAL || type == TRAVERSE_TYPE_GT_SUBGOAL)
|
||||||
str_index += sprintf(& str[str_index], "VAR%d", VarIndexOfTableTerm(t));
|
str_index += sprintf(& str[str_index], "VAR%d", VarIndexOfTableTerm(t));
|
||||||
@ -1037,7 +1036,7 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
|
|||||||
int old_subs_arity = subs_arity;
|
int old_subs_arity = subs_arity;
|
||||||
for (i = 1; i <= pred_arity; i++) {
|
for (i = 1; i <= pred_arity; i++) {
|
||||||
int j = MODE_DIRECTED_GET_ARG(mode_directed[i-1]) + 1;
|
int j = MODE_DIRECTED_GET_ARG(mode_directed[i-1]) + 1;
|
||||||
current_sg_node = subgoal_search_loop(tab_ent, current_sg_node, Deref(XREGS[j]), &subs_arity, &stack_vars);
|
current_sg_node = subgoal_search_loop(tab_ent, current_sg_node, Deref(XREGS[j]), &subs_arity, &stack_vars PASS_REGS);
|
||||||
if (subs_arity != old_subs_arity) {
|
if (subs_arity != old_subs_arity) {
|
||||||
if (subs_pos && MODE_DIRECTED_GET_MODE(aux_mode_directed[subs_pos-1]) == MODE_DIRECTED_GET_MODE(mode_directed[i-1])) {
|
if (subs_pos && MODE_DIRECTED_GET_MODE(aux_mode_directed[subs_pos-1]) == MODE_DIRECTED_GET_MODE(mode_directed[i-1])) {
|
||||||
/* same mode as before -> use the current entry in the aux_mode_directed[] array */
|
/* same mode as before -> use the current entry in the aux_mode_directed[] array */
|
||||||
@ -1054,10 +1053,10 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
|
|||||||
#endif /* MODE_DIRECTED_TABLING */
|
#endif /* MODE_DIRECTED_TABLING */
|
||||||
if (IsMode_GlobalTrie(TabEnt_mode(tab_ent))) {
|
if (IsMode_GlobalTrie(TabEnt_mode(tab_ent))) {
|
||||||
for (i = 1; i <= pred_arity; i++)
|
for (i = 1; i <= pred_arity; i++)
|
||||||
current_sg_node = subgoal_search_terms_loop(tab_ent, current_sg_node, Deref(XREGS[i]), &subs_arity, &stack_vars);
|
current_sg_node = subgoal_search_terms_loop(tab_ent, current_sg_node, Deref(XREGS[i]), &subs_arity, &stack_vars PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
for (i = 1; i <= pred_arity; i++)
|
for (i = 1; i <= pred_arity; i++)
|
||||||
current_sg_node = subgoal_search_loop(tab_ent, current_sg_node, Deref(XREGS[i]), &subs_arity, &stack_vars);
|
current_sg_node = subgoal_search_loop(tab_ent, current_sg_node, Deref(XREGS[i]), &subs_arity, &stack_vars PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
STACK_PUSH_UP(subs_arity, stack_vars);
|
STACK_PUSH_UP(subs_arity, stack_vars);
|
||||||
@ -1068,7 +1067,7 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
|
|||||||
RESET_VARIABLE(t);
|
RESET_VARIABLE(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
volatile sg_fr_ptr *sg_fr_end = get_insert_subgoal_frame_addr(current_sg_node PASS_REGS);
|
sg_fr_ptr *sg_fr_end = get_insert_subgoal_frame_addr(current_sg_node PASS_REGS);
|
||||||
#ifndef THREADS
|
#ifndef THREADS
|
||||||
LOCK_SUBGOAL_NODE(current_sg_node);
|
LOCK_SUBGOAL_NODE(current_sg_node);
|
||||||
#endif /* !THREADS */
|
#endif /* !THREADS */
|
||||||
@ -1084,6 +1083,7 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
|
|||||||
#if !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING)
|
#if !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING)
|
||||||
new_subgoal_frame(sg_fr, preg, mode_directed);
|
new_subgoal_frame(sg_fr, preg, mode_directed);
|
||||||
*sg_fr_end = sg_fr;
|
*sg_fr_end = sg_fr;
|
||||||
|
__sync_synchronize();
|
||||||
TAG_AS_SUBGOAL_LEAF_NODE(current_sg_node);
|
TAG_AS_SUBGOAL_LEAF_NODE(current_sg_node);
|
||||||
UNLOCK_SUBGOAL_NODE(current_sg_node);
|
UNLOCK_SUBGOAL_NODE(current_sg_node);
|
||||||
#else /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
#else /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
||||||
@ -1139,12 +1139,12 @@ ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
|||||||
if (IsMode_GlobalTrie(TabEnt_mode(SgFr_tab_ent(sg_fr)))) {
|
if (IsMode_GlobalTrie(TabEnt_mode(SgFr_tab_ent(sg_fr)))) {
|
||||||
for (i = subs_arity; i >= 1; i--) {
|
for (i = subs_arity; i >= 1; i--) {
|
||||||
TABLING_ERROR_CHECKING(answer_search, IsNonVarTerm(subs_ptr[i]));
|
TABLING_ERROR_CHECKING(answer_search, IsNonVarTerm(subs_ptr[i]));
|
||||||
current_ans_node = answer_search_terms_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity);
|
current_ans_node = answer_search_terms_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = subs_arity; i >= 1; i--) {
|
for (i = subs_arity; i >= 1; i--) {
|
||||||
TABLING_ERROR_CHECKING(answer_search, IsNonVarTerm(subs_ptr[i]));
|
TABLING_ERROR_CHECKING(answer_search, IsNonVarTerm(subs_ptr[i]));
|
||||||
current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity);
|
current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1181,7 +1181,7 @@ ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
|||||||
do {
|
do {
|
||||||
TABLING_ERROR_CHECKING(answer_search, IsNonVarTerm(subs_ptr[i]));
|
TABLING_ERROR_CHECKING(answer_search, IsNonVarTerm(subs_ptr[i]));
|
||||||
if (mode == MODE_DIRECTED_INDEX || mode == MODE_DIRECTED_ALL) {
|
if (mode == MODE_DIRECTED_INDEX || mode == MODE_DIRECTED_ALL) {
|
||||||
current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity);
|
current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
LOCK_ANSWER_NODE(current_ans_node);
|
LOCK_ANSWER_NODE(current_ans_node);
|
||||||
if (TrNode_child(current_ans_node) == NULL) {
|
if (TrNode_child(current_ans_node) == NULL) {
|
||||||
@ -1191,15 +1191,15 @@ ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
|||||||
TrNode_init_lock_field(&virtual_ans_node);
|
TrNode_init_lock_field(&virtual_ans_node);
|
||||||
TrNode_parent(&virtual_ans_node) = NULL;
|
TrNode_parent(&virtual_ans_node) = NULL;
|
||||||
TrNode_child(&virtual_ans_node) = NULL;
|
TrNode_child(&virtual_ans_node) = NULL;
|
||||||
current_ans_node = answer_search_loop(sg_fr, &virtual_ans_node, Deref(subs_ptr[i]), &vars_arity);
|
current_ans_node = answer_search_loop(sg_fr, &virtual_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
||||||
TrNode_child(parent_ans_node) = TrNode_child(&virtual_ans_node);
|
TrNode_child(parent_ans_node) = TrNode_child(&virtual_ans_node);
|
||||||
#else
|
#else
|
||||||
current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity);
|
current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
} else if (mode == MODE_DIRECTED_MIN || mode == MODE_DIRECTED_MAX) {
|
} else if (mode == MODE_DIRECTED_MIN || mode == MODE_DIRECTED_MAX) {
|
||||||
ans_node_ptr parent_ans_node = current_ans_node;
|
ans_node_ptr parent_ans_node = current_ans_node;
|
||||||
invalid_ans_node = TrNode_child(parent_ans_node); /* by default, assume a better answer */
|
invalid_ans_node = TrNode_child(parent_ans_node); /* by default, assume a better answer */
|
||||||
current_ans_node = answer_search_min_max(sg_fr, current_ans_node, Deref(subs_ptr[i]), mode);
|
current_ans_node = answer_search_min_max(sg_fr, current_ans_node, Deref(subs_ptr[i]), mode PASS_REGS);
|
||||||
if (invalid_ans_node == TrNode_child(parent_ans_node)) /* worse or equal answer */
|
if (invalid_ans_node == TrNode_child(parent_ans_node)) /* worse or equal answer */
|
||||||
invalid_ans_node = NULL;
|
invalid_ans_node = NULL;
|
||||||
} else if (mode == MODE_DIRECTED_FIRST)
|
} else if (mode == MODE_DIRECTED_FIRST)
|
||||||
@ -1212,12 +1212,12 @@ ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
|||||||
TrNode_init_lock_field(&virtual_ans_node);
|
TrNode_init_lock_field(&virtual_ans_node);
|
||||||
TrNode_parent(&virtual_ans_node) = NULL;
|
TrNode_parent(&virtual_ans_node) = NULL;
|
||||||
TrNode_child(&virtual_ans_node) = NULL;
|
TrNode_child(&virtual_ans_node) = NULL;
|
||||||
current_ans_node = answer_search_loop(sg_fr, &virtual_ans_node, Deref(subs_ptr[i]), &vars_arity);
|
current_ans_node = answer_search_loop(sg_fr, &virtual_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
||||||
TrNode_child(parent_ans_node) = TrNode_child(&virtual_ans_node);
|
TrNode_child(parent_ans_node) = TrNode_child(&virtual_ans_node);
|
||||||
#else
|
#else
|
||||||
invalid_ans_node = TrNode_child(current_ans_node);
|
invalid_ans_node = TrNode_child(current_ans_node);
|
||||||
TrNode_child(current_ans_node) = NULL;
|
TrNode_child(current_ans_node) = NULL;
|
||||||
current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity);
|
current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS);
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
}
|
}
|
||||||
UNLOCK_ANSWER_NODE(current_ans_node);
|
UNLOCK_ANSWER_NODE(current_ans_node);
|
||||||
@ -1230,7 +1230,7 @@ ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
|||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
if (invalid_ans_node)
|
if (invalid_ans_node)
|
||||||
invalidate_answer_trie(invalid_ans_node, sg_fr, TRAVERSE_POSITION_FIRST);
|
invalidate_answer_trie(invalid_ans_node, sg_fr, TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
|
|
||||||
/* reset variables */
|
/* reset variables */
|
||||||
stack_vars = (CELL *) TR;
|
stack_vars = (CELL *) TR;
|
||||||
@ -1255,7 +1255,7 @@ void load_answer(ans_node_ptr current_ans_node, CELL *subs_ptr) {
|
|||||||
if (subs_arity == 0)
|
if (subs_arity == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
stack_terms = load_answer_loop(current_ans_node);
|
stack_terms = load_answer_loop(current_ans_node PASS_REGS);
|
||||||
|
|
||||||
for (i = subs_arity; i >= 1; i--) {
|
for (i = subs_arity; i >= 1; i--) {
|
||||||
Term t = STACK_POP_DOWN(stack_terms);
|
Term t = STACK_POP_DOWN(stack_terms);
|
||||||
@ -1275,7 +1275,7 @@ CELL *exec_substitution(gt_node_ptr current_node, CELL *aux_stack) {
|
|||||||
Term t;
|
Term t;
|
||||||
|
|
||||||
++aux_stack; /* skip the heap_arity entry */
|
++aux_stack; /* skip the heap_arity entry */
|
||||||
stack_terms = exec_substitution_loop(current_node, &aux_stack, (CELL *) LOCAL_TrailTop);
|
stack_terms = exec_substitution_loop(current_node, &aux_stack, (CELL *) LOCAL_TrailTop PASS_REGS);
|
||||||
*--aux_stack = 0; /* restore the heap_arity entry */
|
*--aux_stack = 0; /* restore the heap_arity entry */
|
||||||
|
|
||||||
subs_ptr = aux_stack + aux_stack[1] + 2;
|
subs_ptr = aux_stack + aux_stack[1] + 2;
|
||||||
@ -1516,16 +1516,33 @@ void free_answer_hash_chain(ans_hash_ptr hash) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************************************************************
|
/*****************************************************************************************
|
||||||
** - main thread (worker_id 0) abolishes its local and all shared data structures. **
|
** all threads abolish their local data structures, and the main thread also abolishes **
|
||||||
** - all other threads only abolish their local data structures. **
|
** all shared data structures, if no other thread is running (GLOBAL_NOfThreads == 1). **
|
||||||
** - for the main thread, we assume that all other threads have the table clean (i.e., without local data structures) **
|
*****************************************************************************************/
|
||||||
** and that they will be not using the table during the abolish operation. **
|
|
||||||
***********************************************************************************************************************/
|
|
||||||
void abolish_table(tab_ent_ptr tab_ent) {
|
void abolish_table(tab_ent_ptr tab_ent) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
sg_node_ptr sg_node;
|
sg_node_ptr sg_node;
|
||||||
|
|
||||||
|
#if defined(THREADS) && defined(USE_PAGES_MALLOC)
|
||||||
|
if (GLOBAL_NOfThreads == 1) {
|
||||||
|
ATTACH_PAGES(_pages_tab_ent);
|
||||||
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
||||||
|
ATTACH_PAGES(_pages_sg_ent);
|
||||||
|
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
|
||||||
|
ATTACH_PAGES(_pages_sg_fr);
|
||||||
|
ATTACH_PAGES(_pages_dep_fr);
|
||||||
|
ATTACH_PAGES(_pages_sg_node);
|
||||||
|
ATTACH_PAGES(_pages_sg_hash);
|
||||||
|
ATTACH_PAGES(_pages_ans_node);
|
||||||
|
ATTACH_PAGES(_pages_ans_hash);
|
||||||
|
#if defined(THREADS_FULL_SHARING)
|
||||||
|
ATTACH_PAGES(_pages_ans_ref_node);
|
||||||
|
#endif /* THREADS_FULL_SHARING */
|
||||||
|
ATTACH_PAGES(_pages_gt_node);
|
||||||
|
ATTACH_PAGES(_pages_gt_hash);
|
||||||
|
}
|
||||||
|
#endif /* THREADS && USE_PAGES_MALLOC */
|
||||||
sg_node = get_subgoal_trie_for_abolish(tab_ent PASS_REGS);
|
sg_node = get_subgoal_trie_for_abolish(tab_ent PASS_REGS);
|
||||||
if (sg_node) {
|
if (sg_node) {
|
||||||
if (TrNode_child(sg_node)) {
|
if (TrNode_child(sg_node)) {
|
||||||
@ -1614,7 +1631,7 @@ void show_table(tab_ent_ptr tab_ent, int show_mode, IOSTREAM *out) {
|
|||||||
arity[0] = 1;
|
arity[0] = 1;
|
||||||
arity[1] = TabEnt_arity(tab_ent);
|
arity[1] = TabEnt_arity(tab_ent);
|
||||||
int str_index = sprintf(str, " ?- %s(", AtomName(TabEnt_atom(tab_ent)));
|
int str_index = sprintf(str, " ?- %s(", AtomName(TabEnt_atom(tab_ent)));
|
||||||
traverse_subgoal_trie(TrNode_child(sg_node), str, str_index, arity, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST);
|
traverse_subgoal_trie(TrNode_child(sg_node), str, str_index, arity, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
free(str);
|
free(str);
|
||||||
free(arity);
|
free(arity);
|
||||||
} else {
|
} else {
|
||||||
@ -1676,7 +1693,7 @@ void show_global_trie(int show_mode, IOSTREAM *out) {
|
|||||||
char *str = (char *) malloc(sizeof(char) * SHOW_TABLE_STR_ARRAY_SIZE);
|
char *str = (char *) malloc(sizeof(char) * SHOW_TABLE_STR_ARRAY_SIZE);
|
||||||
int *arity = (int *) malloc(sizeof(int) * SHOW_TABLE_ARITY_ARRAY_SIZE);
|
int *arity = (int *) malloc(sizeof(int) * SHOW_TABLE_ARITY_ARRAY_SIZE);
|
||||||
arity[0] = 0;
|
arity[0] = 0;
|
||||||
traverse_global_trie(TrNode_child(GLOBAL_root_gt), str, 0, arity, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST);
|
traverse_global_trie(TrNode_child(GLOBAL_root_gt), str, 0, arity, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
free(str);
|
free(str);
|
||||||
free(arity);
|
free(arity);
|
||||||
} else
|
} else
|
||||||
|
@ -40,15 +40,15 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||||
#define SUBGOAL_CHECK_INSERT_ENTRY(TAB_ENT, NODE, ENTRY) \
|
#define SUBGOAL_CHECK_INSERT_ENTRY(TAB_ENT, NODE, ENTRY) \
|
||||||
NODE = global_trie_check_insert_entry(NODE, ENTRY)
|
NODE = global_trie_check_insert_entry(NODE, ENTRY PASS_REGS)
|
||||||
#define ANSWER_CHECK_INSERT_ENTRY(SG_FR, NODE, ENTRY, INSTR) \
|
#define ANSWER_CHECK_INSERT_ENTRY(SG_FR, NODE, ENTRY, INSTR) \
|
||||||
NODE = global_trie_check_insert_entry(NODE, ENTRY)
|
NODE = global_trie_check_insert_entry(NODE, ENTRY PASS_REGS)
|
||||||
#else
|
#else
|
||||||
#define SUBGOAL_CHECK_INSERT_ENTRY(TAB_ENT, NODE, ENTRY) \
|
#define SUBGOAL_CHECK_INSERT_ENTRY(TAB_ENT, NODE, ENTRY) \
|
||||||
NODE = subgoal_trie_check_insert_entry(TAB_ENT, NODE, ENTRY)
|
NODE = subgoal_trie_check_insert_entry(TAB_ENT, NODE, ENTRY PASS_REGS)
|
||||||
#define ANSWER_CHECK_INSERT_ENTRY(SG_FR, NODE, ENTRY, INSTR) \
|
#define ANSWER_CHECK_INSERT_ENTRY(SG_FR, NODE, ENTRY, INSTR) \
|
||||||
NODE = answer_trie_check_insert_entry(SG_FR, NODE, ENTRY, INSTR)
|
NODE = answer_trie_check_insert_entry(SG_FR, NODE, ENTRY, INSTR PASS_REGS)
|
||||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||||
|
|
||||||
|
|
||||||
@ -60,13 +60,10 @@
|
|||||||
#ifdef INCLUDE_SUBGOAL_TRIE_CHECK_INSERT
|
#ifdef INCLUDE_SUBGOAL_TRIE_CHECK_INSERT
|
||||||
#ifndef SUBGOAL_TRIE_LOCK_AT_WRITE_LEVEL /* SUBGOAL_TRIE_LOCK_AT_ENTRY_LEVEL || SUBGOAL_TRIE_LOCK_AT_NODE_LEVEL || ! YAPOR */
|
#ifndef SUBGOAL_TRIE_LOCK_AT_WRITE_LEVEL /* SUBGOAL_TRIE_LOCK_AT_ENTRY_LEVEL || SUBGOAL_TRIE_LOCK_AT_NODE_LEVEL || ! YAPOR */
|
||||||
#ifdef MODE_GLOBAL_TRIE_ENTRY
|
#ifdef MODE_GLOBAL_TRIE_ENTRY
|
||||||
static inline sg_node_ptr subgoal_trie_check_insert_gt_entry(tab_ent_ptr tab_ent, sg_node_ptr parent_node, Term t) {
|
static inline sg_node_ptr subgoal_trie_check_insert_gt_entry(tab_ent_ptr tab_ent, sg_node_ptr parent_node, Term t USES_REGS) {
|
||||||
#else
|
#else
|
||||||
static inline sg_node_ptr subgoal_trie_check_insert_entry(tab_ent_ptr tab_ent, sg_node_ptr parent_node, Term t) {
|
static inline sg_node_ptr subgoal_trie_check_insert_entry(tab_ent_ptr tab_ent, sg_node_ptr parent_node, Term t USES_REGS) {
|
||||||
#endif /* MODE_GLOBAL_TRIE_ENTRY */
|
#endif /* MODE_GLOBAL_TRIE_ENTRY */
|
||||||
#ifdef THREADS_NO_SHARING
|
|
||||||
CACHE_REGS
|
|
||||||
#endif /* THREADS_NO_SHARING */
|
|
||||||
sg_node_ptr child_node;
|
sg_node_ptr child_node;
|
||||||
|
|
||||||
LOCK_SUBGOAL_NODE(parent_node);
|
LOCK_SUBGOAL_NODE(parent_node);
|
||||||
@ -160,13 +157,10 @@ static inline sg_node_ptr subgoal_trie_check_insert_entry(tab_ent_ptr tab_ent, s
|
|||||||
}
|
}
|
||||||
#else /* SUBGOAL_TRIE_LOCK_AT_WRITE_LEVEL */
|
#else /* SUBGOAL_TRIE_LOCK_AT_WRITE_LEVEL */
|
||||||
#ifdef MODE_GLOBAL_TRIE_ENTRY
|
#ifdef MODE_GLOBAL_TRIE_ENTRY
|
||||||
static inline sg_node_ptr subgoal_trie_check_insert_gt_entry(tab_ent_ptr tab_ent, sg_node_ptr parent_node, Term t) {
|
static inline sg_node_ptr subgoal_trie_check_insert_gt_entry(tab_ent_ptr tab_ent, sg_node_ptr parent_node, Term t USES_REGS) {
|
||||||
#else
|
#else
|
||||||
static inline sg_node_ptr subgoal_trie_check_insert_entry(tab_ent_ptr tab_ent, sg_node_ptr parent_node, Term t) {
|
static inline sg_node_ptr subgoal_trie_check_insert_entry(tab_ent_ptr tab_ent, sg_node_ptr parent_node, Term t USES_REGS) {
|
||||||
#endif /* MODE_GLOBAL_TRIE_ENTRY */
|
#endif /* MODE_GLOBAL_TRIE_ENTRY */
|
||||||
#ifdef THREADS_NO_SHARING
|
|
||||||
CACHE_REGS
|
|
||||||
#endif /* THREADS_NO_SHARING */
|
|
||||||
sg_node_ptr child_node;
|
sg_node_ptr child_node;
|
||||||
sg_hash_ptr hash;
|
sg_hash_ptr hash;
|
||||||
|
|
||||||
@ -365,13 +359,10 @@ subgoal_trie_hash:
|
|||||||
#ifdef INCLUDE_ANSWER_TRIE_CHECK_INSERT
|
#ifdef INCLUDE_ANSWER_TRIE_CHECK_INSERT
|
||||||
#ifndef ANSWER_TRIE_LOCK_AT_WRITE_LEVEL /* ANSWER_TRIE_LOCK_AT_ENTRY_LEVEL || ANSWER_TRIE_LOCK_AT_NODE_LEVEL || ! YAPOR */
|
#ifndef ANSWER_TRIE_LOCK_AT_WRITE_LEVEL /* ANSWER_TRIE_LOCK_AT_ENTRY_LEVEL || ANSWER_TRIE_LOCK_AT_NODE_LEVEL || ! YAPOR */
|
||||||
#ifdef MODE_GLOBAL_TRIE_ENTRY
|
#ifdef MODE_GLOBAL_TRIE_ENTRY
|
||||||
static inline ans_node_ptr answer_trie_check_insert_gt_entry(sg_fr_ptr sg_fr, ans_node_ptr parent_node, Term t, int instr) {
|
static inline ans_node_ptr answer_trie_check_insert_gt_entry(sg_fr_ptr sg_fr, ans_node_ptr parent_node, Term t, int instr USES_REGS) {
|
||||||
#else
|
#else
|
||||||
static inline ans_node_ptr answer_trie_check_insert_entry(sg_fr_ptr sg_fr, ans_node_ptr parent_node, Term t, int instr) {
|
static inline ans_node_ptr answer_trie_check_insert_entry(sg_fr_ptr sg_fr, ans_node_ptr parent_node, Term t, int instr USES_REGS) {
|
||||||
#endif /* MODE_GLOBAL_TRIE_ENTRY */
|
#endif /* MODE_GLOBAL_TRIE_ENTRY */
|
||||||
#if defined(THREADS_NO_SHARING) || defined(THREADS_SUBGOAL_SHARING)
|
|
||||||
CACHE_REGS
|
|
||||||
#endif /* THREADS_NO_SHARING || THREADS_SUBGOAL_SHARING */
|
|
||||||
ans_node_ptr child_node;
|
ans_node_ptr child_node;
|
||||||
|
|
||||||
TABLING_ERROR_CHECKING(answer_trie_check_insert_(gt)_entry, IS_ANSWER_LEAF_NODE(parent_node));
|
TABLING_ERROR_CHECKING(answer_trie_check_insert_(gt)_entry, IS_ANSWER_LEAF_NODE(parent_node));
|
||||||
@ -466,11 +457,10 @@ static inline ans_node_ptr answer_trie_check_insert_entry(sg_fr_ptr sg_fr, ans_n
|
|||||||
}
|
}
|
||||||
#else /* ANSWER_TRIE_LOCK_AT_WRITE_LEVEL */
|
#else /* ANSWER_TRIE_LOCK_AT_WRITE_LEVEL */
|
||||||
#ifdef MODE_GLOBAL_TRIE_ENTRY
|
#ifdef MODE_GLOBAL_TRIE_ENTRY
|
||||||
static inline ans_node_ptr answer_trie_check_insert_gt_entry(sg_fr_ptr sg_fr, ans_node_ptr parent_node, Term t, int instr) {
|
static inline ans_node_ptr answer_trie_check_insert_gt_entry(sg_fr_ptr sg_fr, ans_node_ptr parent_node, Term t, int instr USES_REGS) {
|
||||||
#else
|
#else
|
||||||
static inline ans_node_ptr answer_trie_check_insert_entry(sg_fr_ptr sg_fr, ans_node_ptr parent_node, Term t, int instr) {
|
static inline ans_node_ptr answer_trie_check_insert_entry(sg_fr_ptr sg_fr, ans_node_ptr parent_node, Term t, int instr USES_REGS) {
|
||||||
#endif /* MODE_GLOBAL_TRIE_ENTRY */
|
#endif /* MODE_GLOBAL_TRIE_ENTRY */
|
||||||
CACHE_REGS
|
|
||||||
ans_node_ptr child_node;
|
ans_node_ptr child_node;
|
||||||
ans_hash_ptr hash;
|
ans_hash_ptr hash;
|
||||||
|
|
||||||
@ -670,9 +660,9 @@ answer_trie_hash:
|
|||||||
#ifdef INCLUDE_GLOBAL_TRIE_CHECK_INSERT
|
#ifdef INCLUDE_GLOBAL_TRIE_CHECK_INSERT
|
||||||
#ifndef GLOBAL_TRIE_LOCK_AT_WRITE_LEVEL /* GLOBAL_TRIE_LOCK_AT_NODE_LEVEL || ! YAPOR */
|
#ifndef GLOBAL_TRIE_LOCK_AT_WRITE_LEVEL /* GLOBAL_TRIE_LOCK_AT_NODE_LEVEL || ! YAPOR */
|
||||||
#ifdef MODE_GLOBAL_TRIE_ENTRY
|
#ifdef MODE_GLOBAL_TRIE_ENTRY
|
||||||
static inline gt_node_ptr global_trie_check_insert_gt_entry(gt_node_ptr parent_node, Term t) {
|
static inline gt_node_ptr global_trie_check_insert_gt_entry(gt_node_ptr parent_node, Term t USES_REGS) {
|
||||||
#else
|
#else
|
||||||
static inline gt_node_ptr global_trie_check_insert_entry(gt_node_ptr parent_node, Term t) {
|
static inline gt_node_ptr global_trie_check_insert_entry(gt_node_ptr parent_node, Term t USES_REGS) {
|
||||||
#endif /* MODE_GLOBAL_TRIE_ENTRY */
|
#endif /* MODE_GLOBAL_TRIE_ENTRY */
|
||||||
gt_node_ptr child_node;
|
gt_node_ptr child_node;
|
||||||
|
|
||||||
@ -767,11 +757,10 @@ static inline gt_node_ptr global_trie_check_insert_entry(gt_node_ptr parent_node
|
|||||||
}
|
}
|
||||||
#else /* GLOBAL_TRIE_LOCK_AT_WRITE_LEVEL */
|
#else /* GLOBAL_TRIE_LOCK_AT_WRITE_LEVEL */
|
||||||
#ifdef MODE_GLOBAL_TRIE_ENTRY
|
#ifdef MODE_GLOBAL_TRIE_ENTRY
|
||||||
static inline gt_node_ptr global_trie_check_insert_gt_entry(gt_node_ptr parent_node, Term t) {
|
static inline gt_node_ptr global_trie_check_insert_gt_entry(gt_node_ptr parent_node, Term t USES_REGS) {
|
||||||
#else
|
#else
|
||||||
static inline gt_node_ptr global_trie_check_insert_entry(gt_node_ptr parent_node, Term t) {
|
static inline gt_node_ptr global_trie_check_insert_entry(gt_node_ptr parent_node, Term t USES_REGS) {
|
||||||
#endif /* MODE_GLOBAL_TRIE_ENTRY */
|
#endif /* MODE_GLOBAL_TRIE_ENTRY */
|
||||||
CACHE_REGS
|
|
||||||
gt_node_ptr child_node;
|
gt_node_ptr child_node;
|
||||||
gt_hash_ptr hash;
|
gt_hash_ptr hash;
|
||||||
|
|
||||||
@ -970,15 +959,15 @@ global_trie_hash:
|
|||||||
#ifdef INCLUDE_SUBGOAL_SEARCH_LOOP
|
#ifdef INCLUDE_SUBGOAL_SEARCH_LOOP
|
||||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
#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) {
|
static inline gt_node_ptr subgoal_search_global_trie_terms_loop(Term t, int *subs_arity_ptr, CELL **stack_vars_ptr, CELL *stack_terms USES_REGS) {
|
||||||
#else
|
#else
|
||||||
static inline gt_node_ptr subgoal_search_global_trie_loop(Term t, int *subs_arity_ptr, CELL **stack_vars_ptr) {
|
static inline gt_node_ptr subgoal_search_global_trie_loop(Term t, int *subs_arity_ptr, CELL **stack_vars_ptr USES_REGS) {
|
||||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
#else
|
#else
|
||||||
#ifdef MODE_TERMS_LOOP
|
#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) {
|
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 USES_REGS) {
|
||||||
#else
|
#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) {
|
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 USES_REGS) {
|
||||||
#endif /* MODE_TERMS_LOOP */
|
#endif /* MODE_TERMS_LOOP */
|
||||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
@ -1020,7 +1009,6 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
|
|||||||
LOCAL_TrailTop --> | |
|
LOCAL_TrailTop --> | |
|
||||||
-----------
|
-----------
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
CACHE_REGS
|
|
||||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||||
gt_node_ptr current_node = GLOBAL_root_gt;
|
gt_node_ptr current_node = GLOBAL_root_gt;
|
||||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||||
@ -1058,11 +1046,11 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
|
|||||||
} else {
|
} else {
|
||||||
gt_node_ptr entry_node;
|
gt_node_ptr entry_node;
|
||||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
||||||
entry_node = subgoal_search_global_trie_terms_loop(t, &subs_arity, &stack_vars, stack_terms);
|
entry_node = subgoal_search_global_trie_terms_loop(t, &subs_arity, &stack_vars, stack_terms PASS_REGS);
|
||||||
#else
|
#else
|
||||||
entry_node = subgoal_search_global_trie_loop(t, &subs_arity, &stack_vars);
|
entry_node = subgoal_search_global_trie_loop(t, &subs_arity, &stack_vars PASS_REGS);
|
||||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
current_node = subgoal_trie_check_insert_gt_entry(tab_ent, current_node, (Term) entry_node);
|
current_node = subgoal_trie_check_insert_gt_entry(tab_ent, current_node, (Term) entry_node PASS_REGS);
|
||||||
#else /* ! MODE_TERMS_LOOP */
|
#else /* ! MODE_TERMS_LOOP */
|
||||||
} else
|
} else
|
||||||
#if defined(MODE_GLOBAL_TRIE_LOOP)
|
#if defined(MODE_GLOBAL_TRIE_LOOP)
|
||||||
@ -1093,8 +1081,8 @@ 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)
|
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||||
} else if (current_node != GLOBAL_root_gt) {
|
} else if (current_node != GLOBAL_root_gt) {
|
||||||
gt_node_ptr entry_node = subgoal_search_global_trie_terms_loop(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 PASS_REGS);
|
||||||
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
|
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node PASS_REGS);
|
||||||
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
} else {
|
} else {
|
||||||
SUBGOAL_CHECK_INSERT_ENTRY(tab_ent, current_node, CompactPairInit);
|
SUBGOAL_CHECK_INSERT_ENTRY(tab_ent, current_node, CompactPairInit);
|
||||||
@ -1110,14 +1098,14 @@ 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)
|
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||||
} else if (current_node != GLOBAL_root_gt) {
|
} else if (current_node != GLOBAL_root_gt) {
|
||||||
gt_node_ptr entry_node = subgoal_search_global_trie_terms_loop(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 PASS_REGS);
|
||||||
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
|
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node PASS_REGS);
|
||||||
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
#else /* ! TRIE_COMPACT_PAIRS */
|
#else /* ! TRIE_COMPACT_PAIRS */
|
||||||
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||||
if (current_node != GLOBAL_root_gt) {
|
if (current_node != GLOBAL_root_gt) {
|
||||||
gt_node_ptr entry_node = subgoal_search_global_trie_terms_loop(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 PASS_REGS);
|
||||||
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
|
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node PASS_REGS);
|
||||||
} else
|
} else
|
||||||
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
if (IsPairTerm(t)) {
|
if (IsPairTerm(t)) {
|
||||||
@ -1184,15 +1172,15 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
|
|||||||
#ifdef INCLUDE_ANSWER_SEARCH_LOOP
|
#ifdef INCLUDE_ANSWER_SEARCH_LOOP
|
||||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
#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) {
|
static inline gt_node_ptr answer_search_global_trie_terms_loop(Term t, int *vars_arity_ptr, CELL *stack_terms USES_REGS) {
|
||||||
#else
|
#else
|
||||||
static inline gt_node_ptr answer_search_global_trie_loop(Term t, int *vars_arity_ptr) {
|
static inline gt_node_ptr answer_search_global_trie_loop(Term t, int *vars_arity_ptr USES_REGS) {
|
||||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
#else
|
#else
|
||||||
#ifdef MODE_TERMS_LOOP
|
#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) {
|
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 USES_REGS) {
|
||||||
#else
|
#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) {
|
static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr current_node, Term t, int *vars_arity_ptr USES_REGS) {
|
||||||
#endif /* MODE_TERMS_LOOP */
|
#endif /* MODE_TERMS_LOOP */
|
||||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
@ -1224,7 +1212,6 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
|
|||||||
LOCAL_TrailTop --> | |
|
LOCAL_TrailTop --> | |
|
||||||
-----------
|
-----------
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
CACHE_REGS
|
|
||||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||||
gt_node_ptr current_node = GLOBAL_root_gt;
|
gt_node_ptr current_node = GLOBAL_root_gt;
|
||||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||||
@ -1274,11 +1261,11 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
|
|||||||
} else {
|
} else {
|
||||||
gt_node_ptr entry_node;
|
gt_node_ptr entry_node;
|
||||||
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
|
||||||
entry_node = answer_search_global_trie_terms_loop(t, &vars_arity, stack_terms);
|
entry_node = answer_search_global_trie_terms_loop(t, &vars_arity, stack_terms PASS_REGS);
|
||||||
#else
|
#else
|
||||||
entry_node = answer_search_global_trie_loop(t, &vars_arity);
|
entry_node = answer_search_global_trie_loop(t, &vars_arity PASS_REGS);
|
||||||
#endif /* GLOBAL_TRIE_FOR_SUBTERMS */
|
#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);
|
current_node = answer_trie_check_insert_gt_entry(sg_fr, current_node, (Term) entry_node, _trie_retry_gterm + in_pair PASS_REGS);
|
||||||
#else /* ! MODE_TERMS_LOOP */
|
#else /* ! MODE_TERMS_LOOP */
|
||||||
} else
|
} else
|
||||||
#if defined(MODE_GLOBAL_TRIE_LOOP)
|
#if defined(MODE_GLOBAL_TRIE_LOOP)
|
||||||
@ -1310,8 +1297,8 @@ 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)
|
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||||
} else if (current_node != GLOBAL_root_gt) {
|
} else if (current_node != GLOBAL_root_gt) {
|
||||||
gt_node_ptr entry_node = answer_search_global_trie_terms_loop(t, &vars_arity, stack_terms);
|
gt_node_ptr entry_node = answer_search_global_trie_terms_loop(t, &vars_arity, stack_terms PASS_REGS);
|
||||||
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
|
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node PASS_REGS);
|
||||||
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
} else {
|
} else {
|
||||||
ANSWER_CHECK_INSERT_ENTRY(sg_fr, current_node, CompactPairInit, _trie_retry_null + in_pair);
|
ANSWER_CHECK_INSERT_ENTRY(sg_fr, current_node, CompactPairInit, _trie_retry_null + in_pair);
|
||||||
@ -1329,14 +1316,14 @@ 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)
|
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||||
} else if (current_node != GLOBAL_root_gt) {
|
} else if (current_node != GLOBAL_root_gt) {
|
||||||
gt_node_ptr entry_node = answer_search_global_trie_terms_loop(t, &vars_arity, stack_terms);
|
gt_node_ptr entry_node = answer_search_global_trie_terms_loop(t, &vars_arity, stack_terms PASS_REGS);
|
||||||
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
|
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node PASS_REGS);
|
||||||
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
#else /* ! TRIE_COMPACT_PAIRS */
|
#else /* ! TRIE_COMPACT_PAIRS */
|
||||||
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||||
if (current_node != GLOBAL_root_gt) {
|
if (current_node != GLOBAL_root_gt) {
|
||||||
gt_node_ptr entry_node = answer_search_global_trie_terms_loop(t, &vars_arity, stack_terms);
|
gt_node_ptr entry_node = answer_search_global_trie_terms_loop(t, &vars_arity, stack_terms PASS_REGS);
|
||||||
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
|
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node PASS_REGS);
|
||||||
} else
|
} else
|
||||||
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
if (IsPairTerm(t)) {
|
if (IsPairTerm(t)) {
|
||||||
@ -1411,11 +1398,10 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
|
|||||||
NODE = new_node; \
|
NODE = new_node; \
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ans_node_ptr answer_search_min_max(sg_fr_ptr sg_fr, ans_node_ptr current_node, Term t, int mode) {
|
static inline ans_node_ptr answer_search_min_max(sg_fr_ptr sg_fr, ans_node_ptr current_node, Term t, int mode USES_REGS) {
|
||||||
CACHE_REGS
|
|
||||||
ans_node_ptr child_node;
|
ans_node_ptr child_node;
|
||||||
Term child_term;
|
Term child_term;
|
||||||
Float trie_value, term_value;
|
Float trie_value = 0, term_value = 0;
|
||||||
|
|
||||||
/* start by computing the current value on the trie (trie_value) */
|
/* start by computing the current value on the trie (trie_value) */
|
||||||
child_node = TrNode_child(current_node);
|
child_node = TrNode_child(current_node);
|
||||||
@ -1510,9 +1496,7 @@ static inline ans_node_ptr answer_search_min_max(sg_fr_ptr sg_fr, ans_node_ptr c
|
|||||||
TrNode_next(NODE) = SgFr_invalid_chain(SG_FR); \
|
TrNode_next(NODE) = SgFr_invalid_chain(SG_FR); \
|
||||||
SgFr_invalid_chain(SG_FR) = NODE
|
SgFr_invalid_chain(SG_FR) = NODE
|
||||||
|
|
||||||
static void invalidate_answer_trie(ans_node_ptr current_node, sg_fr_ptr sg_fr, int position) {
|
static void invalidate_answer_trie(ans_node_ptr current_node, sg_fr_ptr sg_fr, int position USES_REGS) {
|
||||||
CACHE_REGS
|
|
||||||
|
|
||||||
if (IS_ANSWER_TRIE_HASH(current_node)) {
|
if (IS_ANSWER_TRIE_HASH(current_node)) {
|
||||||
ans_hash_ptr hash;
|
ans_hash_ptr hash;
|
||||||
ans_node_ptr *bucket, *last_bucket;
|
ans_node_ptr *bucket, *last_bucket;
|
||||||
@ -1526,13 +1510,13 @@ static void invalidate_answer_trie(ans_node_ptr current_node, sg_fr_ptr sg_fr, i
|
|||||||
if (IS_ANSWER_LEAF_NODE(current_node)) {
|
if (IS_ANSWER_LEAF_NODE(current_node)) {
|
||||||
INVALIDATE_ANSWER_TRIE_LEAF_NODE(current_node, sg_fr);
|
INVALIDATE_ANSWER_TRIE_LEAF_NODE(current_node, sg_fr);
|
||||||
} else {
|
} else {
|
||||||
invalidate_answer_trie(TrNode_child(current_node), sg_fr, TRAVERSE_POSITION_FIRST);
|
invalidate_answer_trie(TrNode_child(current_node), sg_fr, TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
INVALIDATE_ANSWER_TRIE_NODE(current_node, sg_fr);
|
INVALIDATE_ANSWER_TRIE_NODE(current_node, sg_fr);
|
||||||
}
|
}
|
||||||
while (next_node) {
|
while (next_node) {
|
||||||
current_node = next_node;
|
current_node = next_node;
|
||||||
next_node = TrNode_next(current_node);
|
next_node = TrNode_next(current_node);
|
||||||
invalidate_answer_trie(current_node, sg_fr, TRAVERSE_POSITION_NEXT);
|
invalidate_answer_trie(current_node, sg_fr, TRAVERSE_POSITION_NEXT PASS_REGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (++bucket != last_bucket);
|
} while (++bucket != last_bucket);
|
||||||
@ -1550,19 +1534,19 @@ static void invalidate_answer_trie(ans_node_ptr current_node, sg_fr_ptr sg_fr, i
|
|||||||
if (IS_ANSWER_LEAF_NODE(current_node)) {
|
if (IS_ANSWER_LEAF_NODE(current_node)) {
|
||||||
INVALIDATE_ANSWER_TRIE_LEAF_NODE(current_node, sg_fr);
|
INVALIDATE_ANSWER_TRIE_LEAF_NODE(current_node, sg_fr);
|
||||||
} else {
|
} else {
|
||||||
invalidate_answer_trie(TrNode_child(current_node), sg_fr, TRAVERSE_POSITION_FIRST);
|
invalidate_answer_trie(TrNode_child(current_node), sg_fr, TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
INVALIDATE_ANSWER_TRIE_NODE(current_node, sg_fr);
|
INVALIDATE_ANSWER_TRIE_NODE(current_node, sg_fr);
|
||||||
}
|
}
|
||||||
while (next_node) {
|
while (next_node) {
|
||||||
current_node = next_node;
|
current_node = next_node;
|
||||||
next_node = TrNode_next(current_node);
|
next_node = TrNode_next(current_node);
|
||||||
invalidate_answer_trie(current_node, sg_fr, TRAVERSE_POSITION_NEXT);
|
invalidate_answer_trie(current_node, sg_fr, TRAVERSE_POSITION_NEXT PASS_REGS);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (IS_ANSWER_LEAF_NODE(current_node)) {
|
if (IS_ANSWER_LEAF_NODE(current_node)) {
|
||||||
INVALIDATE_ANSWER_TRIE_LEAF_NODE(current_node, sg_fr);
|
INVALIDATE_ANSWER_TRIE_LEAF_NODE(current_node, sg_fr);
|
||||||
} else {
|
} else {
|
||||||
invalidate_answer_trie(TrNode_child(current_node), sg_fr, TRAVERSE_POSITION_FIRST);
|
invalidate_answer_trie(TrNode_child(current_node), sg_fr, TRAVERSE_POSITION_FIRST PASS_REGS);
|
||||||
INVALIDATE_ANSWER_TRIE_NODE(current_node, sg_fr);
|
INVALIDATE_ANSWER_TRIE_NODE(current_node, sg_fr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1579,9 +1563,9 @@ static void invalidate_answer_trie(ans_node_ptr current_node, sg_fr_ptr sg_fr, i
|
|||||||
|
|
||||||
#ifdef INCLUDE_LOAD_ANSWER_LOOP
|
#ifdef INCLUDE_LOAD_ANSWER_LOOP
|
||||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||||
static inline CELL *load_substitution_loop(gt_node_ptr current_node, int *vars_arity_ptr, CELL *stack_terms) {
|
static inline CELL *load_substitution_loop(gt_node_ptr current_node, int *vars_arity_ptr, CELL *stack_terms USES_REGS) {
|
||||||
#else
|
#else
|
||||||
static inline CELL *load_answer_loop(ans_node_ptr current_node) {
|
static inline CELL *load_answer_loop(ans_node_ptr current_node USES_REGS) {
|
||||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
===========
|
===========
|
||||||
@ -1610,7 +1594,6 @@ static inline CELL *load_answer_loop(ans_node_ptr current_node) {
|
|||||||
LOCAL_TrailTop --> | | <-- stack_terms_base (TRIE_COMPACT_PAIRS)
|
LOCAL_TrailTop --> | | <-- stack_terms_base (TRIE_COMPACT_PAIRS)
|
||||||
-----------
|
-----------
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
CACHE_REGS
|
|
||||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||||
int vars_arity = *vars_arity_ptr;
|
int vars_arity = *vars_arity_ptr;
|
||||||
#else
|
#else
|
||||||
@ -1634,7 +1617,7 @@ static inline CELL *load_answer_loop(ans_node_ptr current_node) {
|
|||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
#if ! defined(MODE_GLOBAL_TRIE_LOOP) || defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
#if ! defined(MODE_GLOBAL_TRIE_LOOP) || defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||||
if (t > VarIndexOfTableTerm(MAX_TABLE_VARS)) {
|
if (t > VarIndexOfTableTerm(MAX_TABLE_VARS)) {
|
||||||
stack_terms = load_substitution_loop((gt_node_ptr) t, &vars_arity, stack_terms);
|
stack_terms = load_substitution_loop((gt_node_ptr) t, &vars_arity, stack_terms PASS_REGS);
|
||||||
} else
|
} else
|
||||||
#endif /* ! MODE_GLOBAL_TRIE_LOOP || GLOBAL_TRIE_FOR_SUBTERMS */
|
#endif /* ! MODE_GLOBAL_TRIE_LOOP || GLOBAL_TRIE_FOR_SUBTERMS */
|
||||||
{ int var_index = VarIndexOfTableTerm(t);
|
{ int var_index = VarIndexOfTableTerm(t);
|
||||||
|
Reference in New Issue
Block a user