diff --git a/C/attvar.c b/C/attvar.c index 5f309ecc8..90daa65b1 100644 --- a/C/attvar.c +++ b/C/attvar.c @@ -201,13 +201,6 @@ mark_attvar(CELL *orig) Yap_mark_external_reference(&(attv->Atts)); } -#if FROZEN_STACKS -static Term -CurrentTime(void) { - return(MkIntegerTerm(TR-(tr_fr_ptr)Yap_TrailBase)); -} -#endif - static Term BuildAttTerm(Functor mfun, UInt ar) { diff --git a/C/heapgc.c b/C/heapgc.c index d8c0cc5c6..8bd92a1ca 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -51,7 +51,9 @@ STATIC_PROTO(void compact_heap, (void)); STATIC_PROTO(void update_relocation_chain, (CELL *, CELL *)); STATIC_PROTO(int is_gc_verbose, (void)); STATIC_PROTO(int is_gc_very_verbose, (void)); +#ifdef EASY_SHUNTING STATIC_PROTO(void set_conditionals, (tr_fr_ptr)); +#endif /* EASY_SHUNTING */ #include "heapgc.h" diff --git a/OPTYap/opt.init.c b/OPTYap/opt.init.c index c55eebe3c..43e7c5bc9 100644 --- a/OPTYap/opt.init.c +++ b/OPTYap/opt.init.c @@ -5,7 +5,7 @@ Copyright: R. Rocha and NCC - University of Porto, Portugal File: opt.init.c - version: $Id: opt.init.c,v 1.14 2005-11-16 01:55:03 vsc Exp $ + version: $Id: opt.init.c,v 1.15 2007-04-26 14:11:08 ricroc Exp $ **********************************************************************/ @@ -57,36 +57,6 @@ ma_h_inner_struct *Yap_ma_h_top; -#if YAP_MEMORY_ALLOC_SCHEME -char * -Yap_get_yap_space(int sz) -{ - char *ptr = Yap_AllocCodeSpace(sz+sizeof(CELL)); - if (ptr) { - *ptr = 'y'; - return ptr+sizeof(CELL); - } - ptr = (char *)malloc(sz+sizeof(CELL)); - if (ptr) { - *ptr = 'm'; - return ptr+sizeof(CELL); - } - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "Yap_AllocCodeSpace error (ALLOC_STRUCT), when allocating %d B", sz); - return NULL; -} - -void -Yap_free_yap_space(char *ptr) -{ - ptr -= sizeof(CELL); - if (ptr[0] == 'y') { - Yap_FreeCodeSpace(ptr); - } else { - free((void *)ptr); - } -} -#endif - /* -------------------------- ** ** Global functions ** ** -------------------------- */ @@ -177,8 +147,7 @@ void Yap_init_global(int max_table_size, int n_workers, int sch_loop, int delay_ GLOBAL_check_sg_fr = NULL; #endif /* LIMIT_TABLING */ for (i = 0; i < MAX_TABLE_VARS; i++) { - CELL *pt = ADDR_GLOBAL_table_var_enumerator(i); - + CELL *pt = GLOBAL_table_var_enumerator_addr(i); RESET_VARIABLE(pt); } #ifdef TABLE_LOCK_AT_WRITE_LEVEL @@ -295,4 +264,3 @@ void init_workers(void) { } #endif /* YAPOR */ #endif /* YAPOR || TABLING */ - diff --git a/OPTYap/opt.macros.h b/OPTYap/opt.macros.h index 8dc4d0a59..254178178 100644 --- a/OPTYap/opt.macros.h +++ b/OPTYap/opt.macros.h @@ -5,7 +5,7 @@ Copyright: R. Rocha and NCC - University of Porto, Portugal File: opt.macros.h - version: $Id: opt.macros.h,v 1.11 2005-11-16 01:55:03 vsc Exp $ + version: $Id: opt.macros.h,v 1.12 2007-04-26 14:11:08 ricroc Exp $ **********************************************************************/ @@ -16,6 +16,8 @@ #include #define SHMMAX 0x2000000 /* 32 Mbytes: works fine with linux */ +/* #define SHMMAX 0x400000 - 4 Mbytes: shmget limit for Mac (?) */ +/* #define SHMMAX 0x800000 - 8 Mbytes: shmget limit for Solaris (?) */ @@ -43,7 +45,7 @@ extern int Yap_page_size; #define ADJUST_SIZE(SIZE) ((SIZE + ALIGN) & ALIGNMASK) #define ADJUST_SIZE_TO_PAGE(SIZE) ((SIZE) - (SIZE) % Yap_page_size + Yap_page_size) #define STRUCT_SIZE(STR_TYPE) ADJUST_SIZE(sizeof(STR_TYPE)) -#define PAGE_HEADER(STR) (pg_hd_ptr)((unsigned int)STR - (unsigned 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) @@ -61,19 +63,35 @@ extern int Yap_page_size; UPDATE_STATS(Pg_str_in_use(STR_PAGES), -1); \ free(STR) #elif YAP_MEMORY_ALLOC_SCHEME /* ---------------------------------------------------- */ - - -char *STD_PROTO(Yap_get_yap_space, (int)); -void STD_PROTO(Yap_free_yap_space, (char *)); - #define ALLOC_STRUCT(STR, STR_PAGES, STR_TYPE) \ - UPDATE_STATS(Pg_str_in_use(STR_PAGES), 1); \ - STR = (STR_TYPE *)Yap_get_yap_space(sizeof(STR_TYPE)) + { char *ptr = Yap_AllocCodeSpace(sizeof(STR_TYPE) + sizeof(CELL)); \ + if (ptr) { \ + *ptr = 'y'; \ + ptr += sizeof(CELL); \ + STR = (STR_TYPE *)ptr; \ + } else { \ + ptr = (char *)malloc(sizeof(STR_TYPE) + sizeof(CELL)); \ + if (ptr) { \ + *ptr = 'm'; \ + ptr += sizeof(CELL); \ + STR = (STR_TYPE *)ptr; \ + } else { \ + Yap_Error(FATAL_ERROR, TermNil, "malloc error (ALLOC_STRUCT)"); \ + STR = NULL; \ + } \ + } \ + UPDATE_STATS(Pg_str_in_use(STR_PAGES), 1); \ + } #define ALLOC_NEXT_FREE_STRUCT(STR, STR_PAGES, STR_TYPE) \ ALLOC_STRUCT(STR, STR_PAGES, STR_TYPE) #define FREE_STRUCT(STR, STR_PAGES, STR_TYPE) \ - UPDATE_STATS(Pg_str_in_use(STR_PAGES), -1); \ - Yap_free_yap_space((char *)(STR)) + { char *ptr = (char *)(STR) - sizeof(CELL); \ + if (ptr[0] == 'y') { \ + Yap_FreeCodeSpace(ptr); \ + } else \ + free(ptr); \ + UPDATE_STATS(Pg_str_in_use(STR_PAGES), -1); \ + } #elif SHM_MEMORY_ALLOC_SCHEME /* ---------------------------------------------------- */ #ifdef LIMIT_TABLING #define INIT_PAGE(PG_HD, STR_PAGES, STR_TYPE) \ diff --git a/OPTYap/opt.preds.c b/OPTYap/opt.preds.c index ced5ce5d1..d1a0a5e8b 100644 --- a/OPTYap/opt.preds.c +++ b/OPTYap/opt.preds.c @@ -5,7 +5,7 @@ Copyright: R. Rocha and NCC - University of Porto, Portugal File: opt.preds.c - version: $Id: opt.preds.c,v 1.26 2006-04-29 15:52:22 ricroc Exp $ + version: $Id: opt.preds.c,v 1.27 2007-04-26 14:11:08 ricroc Exp $ **********************************************************************/ @@ -63,14 +63,14 @@ static int p_or_statistics(void); #endif /* YAPOR */ #ifdef TABLING -static int p_table(void); -static int p_tabling_mode(void); -static int p_abolish_table(void); -static int p_abolish_all_tables(void); -static int p_show_tabled_predicates(void); -static int p_show_table(void); -static int p_table_statistics(void); -static int p_tabling_statistics(void); +static Int p_table(void); +static Int p_tabling_mode(void); +static Int p_abolish_table(void); +static Int p_abolish_all_tables(void); +static Int p_show_tabled_predicates(void); +static Int p_show_table(void); +static Int p_table_statistics(void); +static Int p_tabling_statistics(void); #endif /* TABLING */ #if defined(YAPOR) && defined(TABLING) @@ -523,7 +523,7 @@ int p_or_statistics(void) { #ifdef TABLING static -int p_table(void) { +Int p_table(void) { Term mod, t; PredEntry *pe; tab_ent_ptr tab_ent; @@ -559,7 +559,7 @@ int p_table(void) { static -int p_tabling_mode(void) { +Int p_tabling_mode(void) { Term mod, t, val; tab_ent_ptr tab_ent; @@ -635,7 +635,7 @@ int p_tabling_mode(void) { static -int p_abolish_table(void) { +Int p_abolish_table(void) { Term mod, t; tab_ent_ptr tab_ent; sg_hash_ptr hash; @@ -662,7 +662,7 @@ int p_abolish_table(void) { static -int p_abolish_all_tables(void) { +Int p_abolish_all_tables(void) { tab_ent_ptr tab_ent; sg_hash_ptr hash; sg_node_ptr sg_node; @@ -684,32 +684,37 @@ int p_abolish_all_tables(void) { static -int p_show_tabled_predicates(void) { +Int p_show_tabled_predicates(void) { tab_ent_ptr tab_ent; PredEntry *pred; char *name; Int arity; - fprintf(Yap_stderr,"Tabled predicates\n"); + fprintf(Yap_stderr, "Tabled predicates\n"); tab_ent = GLOBAL_root_tab_ent; if (tab_ent == NULL) - fprintf(Yap_stderr," none\n"); - else while(tab_ent) { - pred = TabEnt_pe(tab_ent); - arity = pred->ArityOfPE; - if (arity == 0) - name = RepAtom((Atom)pred->FunctorOfPred)->StrOfAE; - else - name = RepAtom(NameOfFunctor((pred->FunctorOfPred)))->StrOfAE; - fprintf(Yap_stderr," %s/%d\n", name, arity); - tab_ent = TabEnt_next(tab_ent); - } + fprintf(Yap_stderr, " none\n"); + else + while(tab_ent) { + pred = TabEnt_pe(tab_ent); + arity = pred->ArityOfPE; + if (arity == 0) + name = RepAtom((Atom)pred->FunctorOfPred)->StrOfAE; + else + name = RepAtom(NameOfFunctor((pred->FunctorOfPred)))->StrOfAE; +#if SHORT_INTS + fprintf(Yap_stderr, " %s/%ld\n", name, arity); +#else + fprintf(Yap_stderr, " %s/%d\n", name, arity); +#endif /* SHORT_INTS */ + tab_ent = TabEnt_next(tab_ent); + } return (TRUE); } static -int p_show_table(void) { +Int p_show_table(void) { Term mod, t; tab_ent_ptr tab_ent; Atom at; @@ -731,7 +736,7 @@ int p_show_table(void) { static -int p_table_statistics(void) { +Int p_table_statistics(void) { Term mod, t; tab_ent_ptr tab_ent; Atom at; @@ -754,7 +759,7 @@ int p_table_statistics(void) { static -int p_tabling_statistics(void) { +Int p_tabling_statistics(void) { #ifdef SHM_MEMORY_ALLOC_SCHEME long pages_in_use = 0, bytes_in_use = 0; diff --git a/OPTYap/opt.structs.h b/OPTYap/opt.structs.h index f8f604854..432272b46 100644 --- a/OPTYap/opt.structs.h +++ b/OPTYap/opt.structs.h @@ -5,7 +5,7 @@ Copyright: R. Rocha and NCC - University of Porto, Portugal File: opt.structs.h - version: $Id: opt.structs.h,v 1.10 2005-11-04 01:17:17 vsc Exp $ + version: $Id: opt.structs.h,v 1.11 2007-04-26 14:11:08 ricroc Exp $ **********************************************************************/ @@ -182,64 +182,63 @@ struct global_data{ #endif /* TABLING */ }; -#define GLOBAL_MAX_PAGES (GLOBAL.pages.max_pages) -#define GLOBAL_PAGES_void (GLOBAL.pages.void_pages) -#define GLOBAL_PAGES_or_fr (GLOBAL.pages.or_frame_pages) -#define GLOBAL_PAGES_qg_sol_fr (GLOBAL.pages.query_goal_solution_frame_pages) -#define GLOBAL_PAGES_qg_ans_fr (GLOBAL.pages.query_goal_answer_frame_pages) -#define GLOBAL_PAGES_tg_sol_fr (GLOBAL.pages.table_subgoal_solution_frame_pages) -#define GLOBAL_PAGES_tg_ans_fr (GLOBAL.pages.table_subgoal_answer_frame_pages) -#define GLOBAL_PAGES_tab_ent (GLOBAL.pages.table_entry_pages) -#define GLOBAL_PAGES_sg_fr (GLOBAL.pages.subgoal_frame_pages) -#define GLOBAL_PAGES_sg_node (GLOBAL.pages.subgoal_trie_node_pages) -#define GLOBAL_PAGES_ans_node (GLOBAL.pages.answer_trie_node_pages) -#define GLOBAL_PAGES_sg_hash (GLOBAL.pages.subgoal_hash_pages) -#define GLOBAL_PAGES_ans_hash (GLOBAL.pages.answer_hash_pages) -#define GLOBAL_PAGES_dep_fr (GLOBAL.pages.dependency_frame_pages) -#define GLOBAL_PAGES_susp_fr (GLOBAL.pages.suspension_frame_pages) -#define SCHEDULER_LOOP (GLOBAL.scheduler_loop) -#define DELAYED_RELEASE_LOAD (GLOBAL.delayed_release_load) -#define number_workers (GLOBAL.number_workers) -#define worker_pid(worker) (GLOBAL.worker_pid[worker]) -#define GLOBAL_master_worker (GLOBAL.master_worker) -#define GLOBAL_execution_time (GLOBAL.execution_time) -#define GLOBAL_best_times(time) (GLOBAL.best_execution_times[time]) -#define GLOBAL_number_goals (GLOBAL.number_of_executed_goals) -#define GLOBAL_performance_mode (GLOBAL.performance_mode) -#define GLOBAL_root_cp (GLOBAL.root_choice_point) -#define GLOBAL_root_or_fr (GLOBAL.root_or_frame) -#define GLOBAL_bm_present_workers (GLOBAL.present_workers) -#define GLOBAL_bm_idle_workers (GLOBAL.idle_workers) -#define GLOBAL_bm_root_cp_workers (GLOBAL.root_cp_workers) -#define GLOBAL_bm_invisible_workers (GLOBAL.invisible_workers) -#define GLOBAL_bm_requestable_workers (GLOBAL.requestable_workers) -#define GLOBAL_bm_executing_workers (GLOBAL.executing_workers) -#define GLOBAL_bm_finished_workers (GLOBAL.finished_workers) -#define GLOBAL_bm_pruning_workers (GLOBAL.pruning_workers) -#define GLOBAL_LOCKS_bm_idle_workers (GLOBAL.locks.bitmap_idle_workers) -#define GLOBAL_LOCKS_bm_root_cp_workers (GLOBAL.locks.bitmap_root_cp_workers) -#define GLOBAL_LOCKS_bm_invisible_workers (GLOBAL.locks.bitmap_invisible_workers) -#define GLOBAL_LOCKS_bm_requestable_workers (GLOBAL.locks.bitmap_requestable_workers) -#define GLOBAL_LOCKS_bm_executing_workers (GLOBAL.locks.bitmap_executing_workers) -#define GLOBAL_LOCKS_bm_finished_workers (GLOBAL.locks.bitmap_finished_workers) -#define GLOBAL_LOCKS_bm_pruning_workers (GLOBAL.locks.bitmap_pruning_workers) -#define GLOBAL_LOCKS_who_locked_heap (GLOBAL.locks.who_locked_heap) -#define GLOBAL_LOCKS_heap_access (GLOBAL.locks.heap_access) -#define GLOBAL_LOCKS_alloc_block (GLOBAL.locks.alloc_block) -#define GLOBAL_LOCKS_stderr_messages (GLOBAL.locks.stderr_messages) -#define GLOBAL_branch(worker, depth) (GLOBAL.branch[worker][depth]) -#define PARALLEL_EXECUTION_MODE (GLOBAL.parallel_execution_mode) -#define GLOBAL_answers (GLOBAL.answers) -#define GLOBAL_root_tab_ent (GLOBAL.root_table_entry) -#define GLOBAL_first_sg_fr (GLOBAL.first_subgoal_frame) -#define GLOBAL_last_sg_fr (GLOBAL.last_subgoal_frame) -#define GLOBAL_check_sg_fr (GLOBAL.check_subgoal_frame) -#define GLOBAL_root_dep_fr (GLOBAL.root_dependency_frame) -#define GLOBAL_table_var_enumerator(index) (GLOBAL.table_var_enumerator[index]) -#define ADDR_GLOBAL_table_var_enumerator(index) (GLOBAL.table_var_enumerator+(index)) -#define GLOBAL_table_lock(index) (GLOBAL.table_lock[index]) -#define GLOBAL_timestamp (GLOBAL.timestamp) - +#define GLOBAL_MAX_PAGES (GLOBAL.pages.max_pages) +#define GLOBAL_PAGES_void (GLOBAL.pages.void_pages) +#define GLOBAL_PAGES_or_fr (GLOBAL.pages.or_frame_pages) +#define GLOBAL_PAGES_qg_sol_fr (GLOBAL.pages.query_goal_solution_frame_pages) +#define GLOBAL_PAGES_qg_ans_fr (GLOBAL.pages.query_goal_answer_frame_pages) +#define GLOBAL_PAGES_tg_sol_fr (GLOBAL.pages.table_subgoal_solution_frame_pages) +#define GLOBAL_PAGES_tg_ans_fr (GLOBAL.pages.table_subgoal_answer_frame_pages) +#define GLOBAL_PAGES_tab_ent (GLOBAL.pages.table_entry_pages) +#define GLOBAL_PAGES_sg_fr (GLOBAL.pages.subgoal_frame_pages) +#define GLOBAL_PAGES_sg_node (GLOBAL.pages.subgoal_trie_node_pages) +#define GLOBAL_PAGES_ans_node (GLOBAL.pages.answer_trie_node_pages) +#define GLOBAL_PAGES_sg_hash (GLOBAL.pages.subgoal_hash_pages) +#define GLOBAL_PAGES_ans_hash (GLOBAL.pages.answer_hash_pages) +#define GLOBAL_PAGES_dep_fr (GLOBAL.pages.dependency_frame_pages) +#define GLOBAL_PAGES_susp_fr (GLOBAL.pages.suspension_frame_pages) +#define SCHEDULER_LOOP (GLOBAL.scheduler_loop) +#define DELAYED_RELEASE_LOAD (GLOBAL.delayed_release_load) +#define number_workers (GLOBAL.number_workers) +#define worker_pid(worker) (GLOBAL.worker_pid[worker]) +#define GLOBAL_master_worker (GLOBAL.master_worker) +#define GLOBAL_execution_time (GLOBAL.execution_time) +#define GLOBAL_best_times(time) (GLOBAL.best_execution_times[time]) +#define GLOBAL_number_goals (GLOBAL.number_of_executed_goals) +#define GLOBAL_performance_mode (GLOBAL.performance_mode) +#define GLOBAL_root_cp (GLOBAL.root_choice_point) +#define GLOBAL_root_or_fr (GLOBAL.root_or_frame) +#define GLOBAL_bm_present_workers (GLOBAL.present_workers) +#define GLOBAL_bm_idle_workers (GLOBAL.idle_workers) +#define GLOBAL_bm_root_cp_workers (GLOBAL.root_cp_workers) +#define GLOBAL_bm_invisible_workers (GLOBAL.invisible_workers) +#define GLOBAL_bm_requestable_workers (GLOBAL.requestable_workers) +#define GLOBAL_bm_executing_workers (GLOBAL.executing_workers) +#define GLOBAL_bm_finished_workers (GLOBAL.finished_workers) +#define GLOBAL_bm_pruning_workers (GLOBAL.pruning_workers) +#define GLOBAL_LOCKS_bm_idle_workers (GLOBAL.locks.bitmap_idle_workers) +#define GLOBAL_LOCKS_bm_root_cp_workers (GLOBAL.locks.bitmap_root_cp_workers) +#define GLOBAL_LOCKS_bm_invisible_workers (GLOBAL.locks.bitmap_invisible_workers) +#define GLOBAL_LOCKS_bm_requestable_workers (GLOBAL.locks.bitmap_requestable_workers) +#define GLOBAL_LOCKS_bm_executing_workers (GLOBAL.locks.bitmap_executing_workers) +#define GLOBAL_LOCKS_bm_finished_workers (GLOBAL.locks.bitmap_finished_workers) +#define GLOBAL_LOCKS_bm_pruning_workers (GLOBAL.locks.bitmap_pruning_workers) +#define GLOBAL_LOCKS_who_locked_heap (GLOBAL.locks.who_locked_heap) +#define GLOBAL_LOCKS_heap_access (GLOBAL.locks.heap_access) +#define GLOBAL_LOCKS_alloc_block (GLOBAL.locks.alloc_block) +#define GLOBAL_LOCKS_stderr_messages (GLOBAL.locks.stderr_messages) +#define GLOBAL_branch(worker, depth) (GLOBAL.branch[worker][depth]) +#define PARALLEL_EXECUTION_MODE (GLOBAL.parallel_execution_mode) +#define GLOBAL_answers (GLOBAL.answers) +#define GLOBAL_root_tab_ent (GLOBAL.root_table_entry) +#define GLOBAL_first_sg_fr (GLOBAL.first_subgoal_frame) +#define GLOBAL_last_sg_fr (GLOBAL.last_subgoal_frame) +#define GLOBAL_check_sg_fr (GLOBAL.check_subgoal_frame) +#define GLOBAL_root_dep_fr (GLOBAL.root_dependency_frame) +#define GLOBAL_table_var_enumerator(index) (GLOBAL.table_var_enumerator[index]) +#define GLOBAL_table_var_enumerator_addr(index) (GLOBAL.table_var_enumerator + (index)) +#define GLOBAL_table_lock(index) (GLOBAL.table_lock[index]) +#define GLOBAL_timestamp (GLOBAL.timestamp) diff --git a/OPTYap/tab.insts.i b/OPTYap/tab.insts.i index e8586d7ab..1923337e3 100644 --- a/OPTYap/tab.insts.i +++ b/OPTYap/tab.insts.i @@ -5,7 +5,7 @@ Copyright: R. Rocha and NCC - University of Porto, Portugal File: tab.insts.i - version: $Id: tab.insts.i,v 1.23 2006-05-02 08:01:27 ricroc Exp $ + version: $Id: tab.insts.i,v 1.24 2007-04-26 14:11:08 ricroc Exp $ **********************************************************************/ @@ -351,9 +351,9 @@ GONext(); } #else - PREG = PREG->u.ld.d; - PREFETCH_OP(PREG); - GONext(); + PREG = PREG->u.ld.d; + PREFETCH_OP(PREG); + GONext(); #endif /* INCOMPLETE_TABLING */ ENDPBOp(); diff --git a/OPTYap/tab.macros.h b/OPTYap/tab.macros.h index cb8424a6f..d6b4756dc 100644 --- a/OPTYap/tab.macros.h +++ b/OPTYap/tab.macros.h @@ -5,7 +5,7 @@ Copyright: R. Rocha and NCC - University of Porto, Portugal File: tab.macros.h - version: $Id: tab.macros.h,v 1.19 2005-08-05 14:55:03 vsc Exp $ + version: $Id: tab.macros.h,v 1.20 2007-04-26 14:11:08 ricroc Exp $ **********************************************************************/ @@ -65,11 +65,9 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p #define LOAD_CP(CP) ((struct loader_choicept *)(CP)) #define IS_BATCHED_GEN_CP(CP) (GEN_CP(CP)->cp_dep_fr == NULL) - -#define TAG_AS_ANSWER_LEAF_NODE(NODE) TrNode_parent(NODE) = (ans_node_ptr)((unsigned int)TrNode_parent(NODE) | 0x1) -#define UNTAG_ANSWER_LEAF_NODE(NODE) ((ans_node_ptr)((unsigned int)NODE & 0xfffffffe)) -#define IS_ANSWER_LEAF_NODE(NODE) ((unsigned int)TrNode_parent(NODE) & 0x1) - +#define TAG_AS_ANSWER_LEAF_NODE(NODE) TrNode_parent(NODE) = (ans_node_ptr)((unsigned long int)TrNode_parent(NODE) | 0x1) +#define UNTAG_ANSWER_LEAF_NODE(NODE) ((ans_node_ptr)((unsigned long int)NODE & ~(0x1))) +#define IS_ANSWER_LEAF_NODE(NODE) ((unsigned long int)TrNode_parent(NODE) & 0x1) #define STACK_NOT_EMPTY(STACK, STACK_BASE) STACK != STACK_BASE #define STACK_PUSH_UP(ITEM, STACK) *--STACK = (CELL)(ITEM) @@ -106,8 +104,7 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p ((CELL) TERM) >= GLOBAL_table_var_enumerator(0) && \ ((CELL) TERM) <= GLOBAL_table_var_enumerator(MAX_TABLE_VARS - 1) - -#define HASH_TABLE_LOCK(NODE) ((((unsigned int)NODE) >> 5) & (TABLE_LOCK_BUCKETS - 1)) +#define HASH_TABLE_LOCK(NODE) ((((unsigned long int)NODE) >> 5) & (TABLE_LOCK_BUCKETS - 1)) #define LOCK_TABLE(NODE) LOCK(GLOBAL_table_lock(HASH_TABLE_LOCK(NODE))) #define UNLOCK_TABLE(NODE) UNLOCK(GLOBAL_table_lock(HASH_TABLE_LOCK(NODE))) @@ -257,8 +254,9 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p DepFr_leader_cp(DEP_FR) = NORM_CP(LEADER_CP); \ DepFr_cons_cp(DEP_FR) = NORM_CP(CONS_CP); \ /* start with TrNode_child(DepFr_last_answer(DEP_FR)) pointing to SgFr_first_answer(SG_FR) */ \ - DepFr_last_answer(DEP_FR) = (ans_node_ptr)((int)(SG_FR) + \ - (int)(&SgFr_first_answer((sg_fr_ptr)DEP_FR)) - (int)(&TrNode_child((ans_node_ptr)DEP_FR))); \ + DepFr_last_answer(DEP_FR) = (ans_node_ptr)((unsigned long int)(SG_FR) + \ + (unsigned long int)(&SgFr_first_answer((sg_fr_ptr)DEP_FR)) - \ + (unsigned long int)(&TrNode_child((ans_node_ptr)DEP_FR))); \ DepFr_next(DEP_FR) = NEXT diff --git a/OPTYap/tab.tries.c b/OPTYap/tab.tries.c index c4e4b4988..638cfd856 100644 --- a/OPTYap/tab.tries.c +++ b/OPTYap/tab.tries.c @@ -5,7 +5,7 @@ Copyright: R. Rocha and NCC - University of Porto, Portugal File: tab.tries.C - version: $Id: tab.tries.c,v 1.20 2006-05-02 08:01:27 ricroc Exp $ + version: $Id: tab.tries.c,v 1.21 2007-04-26 14:11:08 ricroc Exp $ **********************************************************************/ @@ -725,9 +725,9 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) { if (f == FunctorDouble) { volatile Float dbl = FloatOfTerm(t); volatile Term *t_dbl = (Term *)((void *) &dbl); -#if SIZEOF_DOUBLE == 2 * SIZEOF_LONG_INT +#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P current_sg_node = subgoal_trie_node_check_insert(tab_ent, current_sg_node, *(t_dbl + 1)); -#endif /* SIZEOF_DOUBLE x SIZEOF_LONG_INT */ +#endif /* SIZEOF_DOUBLE x SIZEOF_INT_P */ current_sg_node = subgoal_trie_node_check_insert(tab_ent, current_sg_node, *t_dbl); } else if (f == FunctorLongInt) { Int li = LongIntOfTerm(t); @@ -828,9 +828,9 @@ ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) { volatile Float dbl = FloatOfTerm(t); volatile Term *t_dbl = (Term *)((void *) &dbl); current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, AbsAppl((Term *)f), _trie_retry_null); -#if SIZEOF_DOUBLE == 2 * SIZEOF_LONG_INT +#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, *(t_dbl + 1), _trie_retry_extension); -#endif /* SIZEOF_DOUBLE x SIZEOF_LONG_INT */ +#endif /* SIZEOF_DOUBLE x SIZEOF_INT_P */ current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, *t_dbl, _trie_retry_extension); current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, AbsAppl((Term *)f), _trie_retry_float); } else if (f == FunctorLongInt) { @@ -907,11 +907,11 @@ void load_answer_trie(ans_node_ptr ans_node, CELL *subs_ptr) { t = TrNode_entry(ans_node); ans_node = TrNode_parent(ans_node); *t_dbl = t; -#if SIZEOF_DOUBLE == 2 * SIZEOF_LONG_INT +#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P t = TrNode_entry(ans_node); ans_node = TrNode_parent(ans_node); *(t_dbl + 1) = t; -#endif /* SIZEOF_DOUBLE x SIZEOF_LONG_INT */ +#endif /* SIZEOF_DOUBLE x SIZEOF_INT_P */ ans_node = TrNode_parent(ans_node); t = MkFloatTerm(dbl); STACK_PUSH_UP(t, stack_terms); @@ -1276,7 +1276,7 @@ int traverse_subgoal_trie(sg_node_ptr sg_node, char *str, int str_index, int *ar } /* test the node type */ -#if SIZEOF_DOUBLE == 2 * SIZEOF_LONG_INT +#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P if (mode == TRAVERSE_FLOAT) { arity[0]++; arity[arity[0]] = (int) t; @@ -1287,10 +1287,12 @@ int traverse_subgoal_trie(sg_node_ptr sg_node, char *str, int str_index, int *ar *t_dbl = t; *(t_dbl + 1) = (Term) arity[arity[0]]; arity[0]--; -#else /* SIZEOF_DOUBLE == SIZEOF_LONG_INT */ +#else /* SIZEOF_DOUBLE == SIZEOF_INT_P */ if (mode == TRAVERSE_FLOAT) { - Float dbl = (Float) t; -#endif /* SIZEOF_DOUBLE x SIZEOF_LONG_INT */ + volatile Float dbl; + volatile Term *t_dbl = (Term *)((void *) &dbl); + *t_dbl = t; +#endif /* SIZEOF_DOUBLE x SIZEOF_INT_P */ str_index += sprintf(& str[str_index], "%.15g", dbl); while (arity[0]) { if (arity[arity[0]] > 0) { @@ -1316,7 +1318,11 @@ int traverse_subgoal_trie(sg_node_ptr sg_node, char *str, int str_index, int *ar mode = TRAVERSE_NORMAL; } else if (mode == TRAVERSE_LONG) { Int li = (Int) t; +#if SHORT_INTS + str_index += sprintf(& str[str_index], "%ld", li); +#else str_index += sprintf(& str[str_index], "%d", li); +#endif /* SHORT_INTS */ while (arity[0]) { if (arity[arity[0]] > 0) { arity[arity[0]]--; @@ -1340,8 +1346,12 @@ int traverse_subgoal_trie(sg_node_ptr sg_node, char *str, int str_index, int *ar } mode = TRAVERSE_NORMAL; } else if (IsVarTerm(t)) { +#if SHORT_INTS + str_index += sprintf(& str[str_index], "VAR%ld", VarIndexOfTableTerm(t)); +#else str_index += sprintf(& str[str_index], "VAR%d", VarIndexOfTableTerm(t)); - while (arity[0]) { +#endif /* SHORT_INTS */ + while (arity[0]) { if (arity[arity[0]] > 0) { arity[arity[0]]--; if (arity[arity[0]] == 0) { @@ -1363,7 +1373,11 @@ int traverse_subgoal_trie(sg_node_ptr sg_node, char *str, int str_index, int *ar } } } else if (IsIntTerm(t)) { +#if SHORT_INTS + str_index += sprintf(& str[str_index], "%ld", IntOfTerm(t)); +#else str_index += sprintf(& str[str_index], "%d", IntOfTerm(t)); +#endif /* SHORT_INTS */ while (arity[0]) { if (arity[arity[0]] > 0) { arity[arity[0]]--; @@ -1536,7 +1550,7 @@ int traverse_answer_trie(ans_node_ptr ans_node, char *str, int str_index, int *a /* test the node type */ if (mode == TRAVERSE_FLOAT) { -#if SIZEOF_DOUBLE == 2 * SIZEOF_LONG_INT +#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P arity[0]++; arity[arity[0]] = (int) t; mode = TRAVERSE_FLOAT2; @@ -1546,9 +1560,11 @@ int traverse_answer_trie(ans_node_ptr ans_node, char *str, int str_index, int *a *t_dbl = t; *(t_dbl + 1) = (Term) arity[arity[0]]; arity[0]--; -#else /* SIZEOF_DOUBLE == SIZEOF_LONG_INT */ - Float dbl = (Float) t; -#endif /* SIZEOF_DOUBLE x SIZEOF_LONG_INT */ +#else /* SIZEOF_DOUBLE == SIZEOF_INT_P */ + volatile Float dbl; + volatile Term *t_dbl = (Term *)((void *) &dbl); + *t_dbl = t; +#endif /* SIZEOF_DOUBLE x SIZEOF_INT_P */ str_index += sprintf(& str[str_index], "%.15g", dbl); while (arity[0]) { if (arity[arity[0]] > 0) { @@ -1576,7 +1592,11 @@ int traverse_answer_trie(ans_node_ptr ans_node, char *str, int str_index, int *a mode = TRAVERSE_NORMAL; } else if (mode == TRAVERSE_LONG) { Int li = (Int) t; +#if SHORT_INTS + str_index += sprintf(& str[str_index], "%ld", li); +#else str_index += sprintf(& str[str_index], "%d", li); +#endif /* SHORT_INTS */ while (arity[0]) { if (arity[arity[0]] > 0) { arity[arity[0]]--; @@ -1602,7 +1622,11 @@ int traverse_answer_trie(ans_node_ptr ans_node, char *str, int str_index, int *a } else if (mode == TRAVERSE_LONG_END) { mode = TRAVERSE_NORMAL; } else if (IsVarTerm(t)) { +#if SHORT_INTS + str_index += sprintf(& str[str_index], "ANSVAR%ld", VarIndexOfTableTerm(t)); +#else str_index += sprintf(& str[str_index], "ANSVAR%d", VarIndexOfTableTerm(t)); +#endif /* SHORT_INTS */ while (arity[0]) { if (arity[arity[0]] > 0) { arity[arity[0]]--; @@ -1625,7 +1649,11 @@ int traverse_answer_trie(ans_node_ptr ans_node, char *str, int str_index, int *a } } } else if (IsIntTerm(t)) { +#if SHORT_INTS + str_index += sprintf(& str[str_index], "%ld", IntOfTerm(t)); +#else str_index += sprintf(& str[str_index], "%d", IntOfTerm(t)); +#endif /* SHORT_INTS */ while (arity[0]) { if (arity[arity[0]] > 0) { arity[arity[0]]--; diff --git a/OPTYap/tab.tries.insts.i b/OPTYap/tab.tries.insts.i index 8ba038e1e..3f6f4555f 100644 --- a/OPTYap/tab.tries.insts.i +++ b/OPTYap/tab.tries.insts.i @@ -5,7 +5,7 @@ Copyright: R. Rocha and NCC - University of Porto, Portugal File: tab.tries.insts.i - version: $Id: tab.tries.insts.i,v 1.11 2006-01-17 14:10:41 vsc Exp $ + version: $Id: tab.tries.insts.i,v 1.12 2007-04-26 14:11:08 ricroc Exp $ **********************************************************************/ @@ -982,15 +982,15 @@ int i; Term t; volatile Float dbl; -#if SIZEOF_DOUBLE == 2 * SIZEOF_LONG_INT volatile Term *t_dbl = (Term *)((void *) &dbl); +#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P *t_dbl = *++aux_ptr; *(t_dbl + 1) = *++aux_ptr; heap_arity -= 3; -#else /* SIZEOF_DOUBLE == SIZEOF_LONG_INT */ - dbl = (Float) *++aux_ptr; +#else /* SIZEOF_DOUBLE == SIZEOF_INT_P */ + *t_dbl = *++aux_ptr; heap_arity -= 2; -#endif /* SIZEOF_DOUBLE x SIZEOF_LONG_INT */ +#endif /* SIZEOF_DOUBLE x SIZEOF_INT_P */ t = MkFloatTerm(dbl); no_cp_trie_float_longint_instr(); ENDPBOp();