Merge branch 'master' of gitosis@yap.dcc.fc.up.pt:yap-6
This commit is contained in:
commit
d9cdee931c
30
C/absmi.c
30
C/absmi.c
@ -1209,13 +1209,16 @@ Yap_absmi(int inp)
|
||||
UNLOCK(PREG->u.p.p->StatisticsForPred.lock);
|
||||
RetriesCounter--;
|
||||
if (RetriesCounter == 0 && RetriesCounterOn) {
|
||||
/* act as if we had backtracked */
|
||||
ENV = B->cp_env;
|
||||
saveregs();
|
||||
Yap_Error(RETRY_COUNTER_UNDERFLOW,TermNil,"");
|
||||
JMPNext();
|
||||
setregs();
|
||||
JMPNext();
|
||||
}
|
||||
PredEntriesCounter--;
|
||||
if (PredEntriesCounter == 0 && PredEntriesCounterOn) {
|
||||
ENV = B->cp_env;
|
||||
saveregs();
|
||||
Yap_Error(PRED_ENTRY_COUNTER_UNDERFLOW,TermNil,"");
|
||||
setregs();
|
||||
@ -1228,8 +1231,18 @@ Yap_absmi(int inp)
|
||||
/* count_retry_me Label,NArgs */
|
||||
Op(count_retry_me, Otapl);
|
||||
CACHE_Y(B);
|
||||
restore_yaam_regs(PREG->u.Otapl.d);
|
||||
restore_args(PREG->u.Otapl.s);
|
||||
/* After retry, cut should be pointing at the parent
|
||||
* choicepoint for the current B */
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
#else
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
#endif /* FROZEN_STACKS */
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
LOCK(((PredEntry *)(PREG->u.Otapl.p))->StatisticsForPred.lock);
|
||||
((PredEntry *)(PREG->u.Otapl.p))->StatisticsForPred.NOfRetries++;
|
||||
UNLOCK(((PredEntry *)(PREG->u.Otapl.p))->StatisticsForPred.lock);
|
||||
@ -1247,16 +1260,6 @@ Yap_absmi(int inp)
|
||||
setregs();
|
||||
JMPNext();
|
||||
}
|
||||
restore_yaam_regs(PREG->u.Otapl.d);
|
||||
restore_args(PREG->u.Otapl.s);
|
||||
#ifdef FROZEN_STACKS
|
||||
S_YREG = (CELL *) PROTECT_FROZEN_B(B_YREG);
|
||||
set_cut(S_YREG, B->cp_b);
|
||||
#else
|
||||
set_cut(S_YREG, B_YREG->cp_b);
|
||||
#endif /* FROZEN_STACKS */
|
||||
SET_BB(B_YREG);
|
||||
ENDCACHE_Y();
|
||||
PREG = NEXTOP(PREG, Otapl);
|
||||
GONext();
|
||||
ENDOp();
|
||||
@ -7336,7 +7339,7 @@ Yap_absmi(int inp)
|
||||
\************************************************************************/
|
||||
|
||||
BOp(call_cpred, Osbpp);
|
||||
|
||||
check_trail(TR);
|
||||
if (!(PREG->u.Osbpp.p->PredFlags & (SafePredFlag|HiddenPredFlag))) {
|
||||
CACHE_Y_AS_ENV(YREG);
|
||||
check_stack(NoStackCall, H);
|
||||
@ -7384,6 +7387,7 @@ Yap_absmi(int inp)
|
||||
|
||||
/* execute Label */
|
||||
BOp(execute_cpred, pp);
|
||||
check_trail(TR);
|
||||
{
|
||||
PredEntry *pt0;
|
||||
|
||||
@ -8038,9 +8042,9 @@ Yap_absmi(int inp)
|
||||
setregs();
|
||||
JMPNext();
|
||||
}
|
||||
PREG = pe->cs.p_code.TrueCodeOfPred;
|
||||
if ((pe->PredFlags & (CountPredFlag|ProfiledPredFlag|SpiedPredFlag)) ==
|
||||
CountPredFlag) {
|
||||
PREG = pe->cs.p_code.TrueCodeOfPred;
|
||||
JMPNext();
|
||||
}
|
||||
}
|
||||
|
@ -1006,7 +1006,7 @@ RemoveMainIndex(PredEntry *ap)
|
||||
}
|
||||
if (First != NULL && spied) {
|
||||
ap->OpcodeOfPred = Yap_opcode(_spy_pred);
|
||||
ap->cs.p_code.TrueCodeOfPred = ap->CodeOfPred = (yamop *)(&(ap->OpcodeOfPred));
|
||||
ap->CodeOfPred = (yamop *)(&(ap->OpcodeOfPred));
|
||||
} else if (ap->cs.p_code.NOfClauses > 1
|
||||
#ifdef TABLING
|
||||
||ap->PredFlags & TabledPredFlag
|
||||
@ -1775,10 +1775,10 @@ asserta_stat_clause(PredEntry *p, yamop *q, int spy_flag)
|
||||
p->cs.p_code.FirstClause = q;
|
||||
if (p->PredFlags & (SpiedPredFlag|CountPredFlag|ProfiledPredFlag)) {
|
||||
p->OpcodeOfPred = Yap_opcode(_spy_pred);
|
||||
p->cs.p_code.TrueCodeOfPred = p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred));
|
||||
p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred));
|
||||
} else if (!(p->PredFlags & IndexedPredFlag)) {
|
||||
p->OpcodeOfPred = INDEX_OPCODE;
|
||||
p->cs.p_code.TrueCodeOfPred = p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred));
|
||||
p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred));
|
||||
}
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (p->ModuleOfPred != IDB_MODULE) {
|
||||
|
@ -1811,9 +1811,9 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
}
|
||||
else if (op >= _plus && op <= _functor) {
|
||||
if (profiling)
|
||||
Yap_emit(enter_profiling_op, (CELL)RepPredProp(p), Zero, &cglobs->cint);
|
||||
Yap_emit(enter_profiling_op, (CELL)p, Zero, &cglobs->cint);
|
||||
else if (call_counting)
|
||||
Yap_emit(count_call_op, (CELL)RepPredProp(p), Zero, &cglobs->cint);
|
||||
Yap_emit(count_call_op, (CELL)p, Zero, &cglobs->cint);
|
||||
if (op == _functor) {
|
||||
c_functor(Goal, mod, cglobs);
|
||||
}
|
||||
|
11
C/errors.c
11
C/errors.c
@ -518,20 +518,27 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
break;
|
||||
case CALL_COUNTER_UNDERFLOW:
|
||||
/* Do a long jump */
|
||||
PredEntriesCounter--;
|
||||
ReductionsCounterOn = FALSE;
|
||||
PredEntriesCounterOn = FALSE;
|
||||
RetriesCounterOn = FALSE;
|
||||
Yap_JumpToEnv(MkAtomTerm(AtomCallCounter));
|
||||
P = (yamop *)FAILCODE;
|
||||
Yap_PrologMode &= ~InErrorMode;
|
||||
return(P);
|
||||
case PRED_ENTRY_COUNTER_UNDERFLOW:
|
||||
/* Do a long jump */
|
||||
ReductionsCounterOn = FALSE;
|
||||
PredEntriesCounterOn = FALSE;
|
||||
RetriesCounterOn = FALSE;
|
||||
Yap_JumpToEnv(MkAtomTerm(AtomCallAndRetryCounter));
|
||||
P = (yamop *)FAILCODE;
|
||||
Yap_PrologMode &= ~InErrorMode;
|
||||
return(P);
|
||||
case RETRY_COUNTER_UNDERFLOW:
|
||||
/* Do a long jump */
|
||||
PredEntriesCounter--;
|
||||
ReductionsCounterOn = FALSE;
|
||||
PredEntriesCounterOn = FALSE;
|
||||
RetriesCounterOn = FALSE;
|
||||
Yap_JumpToEnv(MkAtomTerm(AtomRetryCounter));
|
||||
P = (yamop *)FAILCODE;
|
||||
Yap_PrologMode &= ~InErrorMode;
|
||||
|
@ -345,26 +345,50 @@
|
||||
OPCODE(trie_trust_null ,e),
|
||||
OPCODE(trie_try_null ,e),
|
||||
OPCODE(trie_retry_null ,e),
|
||||
OPCODE(trie_do_null_in_new_list ,e),
|
||||
OPCODE(trie_trust_null_in_new_list,e),
|
||||
OPCODE(trie_try_null_in_new_list ,e),
|
||||
OPCODE(trie_retry_null_in_new_list,e),
|
||||
OPCODE(trie_do_var ,e),
|
||||
OPCODE(trie_trust_var ,e),
|
||||
OPCODE(trie_try_var ,e),
|
||||
OPCODE(trie_retry_var ,e),
|
||||
OPCODE(trie_do_var_in_new_list ,e),
|
||||
OPCODE(trie_trust_var_in_new_list ,e),
|
||||
OPCODE(trie_try_var_in_new_list ,e),
|
||||
OPCODE(trie_retry_var_in_new_list ,e),
|
||||
OPCODE(trie_do_val ,e),
|
||||
OPCODE(trie_trust_val ,e),
|
||||
OPCODE(trie_try_val ,e),
|
||||
OPCODE(trie_retry_val ,e),
|
||||
OPCODE(trie_do_val_in_new_list ,e),
|
||||
OPCODE(trie_trust_val_in_new_list ,e),
|
||||
OPCODE(trie_try_val_in_new_list ,e),
|
||||
OPCODE(trie_retry_val_in_new_list ,e),
|
||||
OPCODE(trie_do_atom ,e),
|
||||
OPCODE(trie_trust_atom ,e),
|
||||
OPCODE(trie_try_atom ,e),
|
||||
OPCODE(trie_retry_atom ,e),
|
||||
OPCODE(trie_do_atom_in_new_list ,e),
|
||||
OPCODE(trie_trust_atom_in_new_list,e),
|
||||
OPCODE(trie_try_atom_in_new_list ,e),
|
||||
OPCODE(trie_retry_atom_in_new_list,e),
|
||||
OPCODE(trie_do_list ,e),
|
||||
OPCODE(trie_trust_list ,e),
|
||||
OPCODE(trie_try_list ,e),
|
||||
OPCODE(trie_retry_list ,e),
|
||||
OPCODE(trie_do_list_in_new_list ,e),
|
||||
OPCODE(trie_trust_list_in_new_list,e),
|
||||
OPCODE(trie_try_list_in_new_list ,e),
|
||||
OPCODE(trie_retry_list_in_new_list,e),
|
||||
OPCODE(trie_do_struct ,e),
|
||||
OPCODE(trie_trust_struct ,e),
|
||||
OPCODE(trie_try_struct ,e),
|
||||
OPCODE(trie_retry_struct ,e),
|
||||
OPCODE(trie_do_struct_in_new_list ,e),
|
||||
OPCODE(trie_trust_struct_in_new_list,e),
|
||||
OPCODE(trie_try_struct_in_new_list,e),
|
||||
OPCODE(trie_retry_struct_in_new_list,e),
|
||||
OPCODE(trie_do_extension ,e),
|
||||
OPCODE(trie_trust_extension ,e),
|
||||
OPCODE(trie_try_extension ,e),
|
||||
|
24
H/rclause.h
24
H/rclause.h
@ -793,41 +793,65 @@ restore_opcodes(yamop *pc)
|
||||
break;
|
||||
/* instructions type e */
|
||||
case _trie_do_atom:
|
||||
case _trie_do_atom_in_new_list:
|
||||
case _trie_do_extension:
|
||||
case _trie_do_float:
|
||||
case _trie_do_list:
|
||||
case _trie_do_list_in_new_list:
|
||||
case _trie_do_long:
|
||||
case _trie_do_null:
|
||||
case _trie_do_null_in_new_list:
|
||||
case _trie_do_struct:
|
||||
case _trie_do_struct_in_new_list:
|
||||
case _trie_do_val:
|
||||
case _trie_do_val_in_new_list:
|
||||
case _trie_do_var:
|
||||
case _trie_do_var_in_new_list:
|
||||
case _trie_retry_atom:
|
||||
case _trie_retry_atom_in_new_list:
|
||||
case _trie_retry_extension:
|
||||
case _trie_retry_float:
|
||||
case _trie_retry_list:
|
||||
case _trie_retry_list_in_new_list:
|
||||
case _trie_retry_long:
|
||||
case _trie_retry_null:
|
||||
case _trie_retry_null_in_new_list:
|
||||
case _trie_retry_struct:
|
||||
case _trie_retry_struct_in_new_list:
|
||||
case _trie_retry_val:
|
||||
case _trie_retry_val_in_new_list:
|
||||
case _trie_retry_var:
|
||||
case _trie_retry_var_in_new_list:
|
||||
case _trie_trust_atom:
|
||||
case _trie_trust_atom_in_new_list:
|
||||
case _trie_trust_extension:
|
||||
case _trie_trust_float:
|
||||
case _trie_trust_list:
|
||||
case _trie_trust_list_in_new_list:
|
||||
case _trie_trust_long:
|
||||
case _trie_trust_null:
|
||||
case _trie_trust_null_in_new_list:
|
||||
case _trie_trust_struct:
|
||||
case _trie_trust_struct_in_new_list:
|
||||
case _trie_trust_val:
|
||||
case _trie_trust_val_in_new_list:
|
||||
case _trie_trust_var:
|
||||
case _trie_trust_var_in_new_list:
|
||||
case _trie_try_atom:
|
||||
case _trie_try_atom_in_new_list:
|
||||
case _trie_try_extension:
|
||||
case _trie_try_float:
|
||||
case _trie_try_list:
|
||||
case _trie_try_list_in_new_list:
|
||||
case _trie_try_long:
|
||||
case _trie_try_null:
|
||||
case _trie_try_null_in_new_list:
|
||||
case _trie_try_struct:
|
||||
case _trie_try_struct_in_new_list:
|
||||
case _trie_try_val:
|
||||
case _trie_try_val_in_new_list:
|
||||
case _trie_try_var:
|
||||
case _trie_try_var_in_new_list:
|
||||
if (op == _Nstop || op == _copy_idb_term || op == _unify_idb_term) return;
|
||||
pc = NEXTOP(pc,e);
|
||||
break;
|
||||
|
@ -612,41 +612,65 @@
|
||||
break;
|
||||
/* instructions type e */
|
||||
case _trie_do_atom:
|
||||
case _trie_do_atom_in_new_list:
|
||||
case _trie_do_extension:
|
||||
case _trie_do_float:
|
||||
case _trie_do_list:
|
||||
case _trie_do_list_in_new_list:
|
||||
case _trie_do_long:
|
||||
case _trie_do_null:
|
||||
case _trie_do_null_in_new_list:
|
||||
case _trie_do_struct:
|
||||
case _trie_do_struct_in_new_list:
|
||||
case _trie_do_val:
|
||||
case _trie_do_val_in_new_list:
|
||||
case _trie_do_var:
|
||||
case _trie_do_var_in_new_list:
|
||||
case _trie_retry_atom:
|
||||
case _trie_retry_atom_in_new_list:
|
||||
case _trie_retry_extension:
|
||||
case _trie_retry_float:
|
||||
case _trie_retry_list:
|
||||
case _trie_retry_list_in_new_list:
|
||||
case _trie_retry_long:
|
||||
case _trie_retry_null:
|
||||
case _trie_retry_null_in_new_list:
|
||||
case _trie_retry_struct:
|
||||
case _trie_retry_struct_in_new_list:
|
||||
case _trie_retry_val:
|
||||
case _trie_retry_val_in_new_list:
|
||||
case _trie_retry_var:
|
||||
case _trie_retry_var_in_new_list:
|
||||
case _trie_trust_atom:
|
||||
case _trie_trust_atom_in_new_list:
|
||||
case _trie_trust_extension:
|
||||
case _trie_trust_float:
|
||||
case _trie_trust_list:
|
||||
case _trie_trust_list_in_new_list:
|
||||
case _trie_trust_long:
|
||||
case _trie_trust_null:
|
||||
case _trie_trust_null_in_new_list:
|
||||
case _trie_trust_struct:
|
||||
case _trie_trust_struct_in_new_list:
|
||||
case _trie_trust_val:
|
||||
case _trie_trust_val_in_new_list:
|
||||
case _trie_trust_var:
|
||||
case _trie_trust_var_in_new_list:
|
||||
case _trie_try_atom:
|
||||
case _trie_try_atom_in_new_list:
|
||||
case _trie_try_extension:
|
||||
case _trie_try_float:
|
||||
case _trie_try_list:
|
||||
case _trie_try_list_in_new_list:
|
||||
case _trie_try_long:
|
||||
case _trie_try_null:
|
||||
case _trie_try_null_in_new_list:
|
||||
case _trie_try_struct:
|
||||
case _trie_try_struct_in_new_list:
|
||||
case _trie_try_val:
|
||||
case _trie_try_val_in_new_list:
|
||||
case _trie_try_var:
|
||||
case _trie_try_var_in_new_list:
|
||||
pc = NEXTOP(pc,e);
|
||||
break;
|
||||
#endif
|
||||
|
@ -17,7 +17,7 @@
|
||||
** default sizes **
|
||||
** ----------------------- */
|
||||
#define MAX_LENGTH_ANSWER 500
|
||||
#define MAX_DEPTH 1000
|
||||
#define MAX_BRANCH_DEPTH 1000
|
||||
#define MAX_BEST_TIMES 21
|
||||
#define MAX_TABLE_VARS 100
|
||||
#define TABLE_LOCK_BUCKETS 512
|
||||
@ -73,6 +73,11 @@
|
||||
** ----------------------------------------------- */
|
||||
/* #define INCOMPLETE_TABLING 1 */
|
||||
|
||||
/* ----------------------------------------------- **
|
||||
** support trie compact lists? (optional) **
|
||||
** ----------------------------------------------- */
|
||||
/* #define TRIE_COMPACT_LISTS 1 */
|
||||
|
||||
/* --------------------------------------- **
|
||||
** support inner cuts? (optional) **
|
||||
** --------------------------------------- */
|
||||
@ -169,6 +174,7 @@
|
||||
#undef BBREG_TRAIL_SCHEME
|
||||
#undef LIMIT_TABLING
|
||||
#undef INCOMPLETE_TABLING
|
||||
#undef TRIE_COMPACT_LISTS
|
||||
#undef TABLING_ERRORS
|
||||
#endif /* !TABLING */
|
||||
|
||||
|
@ -684,7 +684,7 @@ Int p_abolish_table(void) {
|
||||
sg_node = TrNode_child(TabEnt_subgoal_trie(tab_ent));
|
||||
if (sg_node) {
|
||||
TrNode_child(TabEnt_subgoal_trie(tab_ent)) = NULL;
|
||||
free_subgoal_trie_branch(sg_node, TabEnt_arity(tab_ent));
|
||||
free_subgoal_trie_branch(sg_node, TabEnt_arity(tab_ent), 0);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
@ -704,7 +704,7 @@ Int p_abolish_all_tables(void) {
|
||||
sg_node = TrNode_child(TabEnt_subgoal_trie(tab_ent));
|
||||
if (sg_node) {
|
||||
TrNode_child(TabEnt_subgoal_trie(tab_ent)) = NULL;
|
||||
free_subgoal_trie_branch(sg_node, TabEnt_arity(tab_ent));
|
||||
free_subgoal_trie_branch(sg_node, TabEnt_arity(tab_ent), 0);
|
||||
}
|
||||
tab_ent = TabEnt_next(tab_ent);
|
||||
}
|
||||
@ -811,8 +811,7 @@ Int p_tabling_statistics(void) {
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_ans_node) * sizeof(struct answer_trie_node);
|
||||
fprintf(Yap_stdout, " subgoal hashes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_sg_hash));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_sg_hash) * sizeof(struct subgoal_hash);
|
||||
fprintf(Yap_stdout, "%s answer hashes: %10ld structs in use\n",
|
||||
Pg_str_in_use(GLOBAL_PAGES_ans_hash) == 0 ? " ": "*", Pg_str_in_use(GLOBAL_PAGES_ans_hash));
|
||||
fprintf(Yap_stdout, " answer hashes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_ans_hash));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_ans_hash) * sizeof(struct answer_hash);
|
||||
fprintf(Yap_stdout, "%s dependency frames: %10ld structs in use\n",
|
||||
Pg_str_in_use(GLOBAL_PAGES_dep_fr) == 1 ? " ": "*", Pg_str_in_use(GLOBAL_PAGES_dep_fr));
|
||||
@ -880,8 +879,7 @@ int p_opt_statistics(void) {
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_ans_node) * sizeof(struct answer_trie_node);
|
||||
fprintf(Yap_stdout, " subgoal hashes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_sg_hash));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_sg_hash) * sizeof(struct subgoal_hash);
|
||||
fprintf(Yap_stdout, "%s answer hashes: %10ld structs in use\n",
|
||||
Pg_str_in_use(GLOBAL_PAGES_ans_hash) == 0 ? " ": "*", Pg_str_in_use(GLOBAL_PAGES_ans_hash));
|
||||
fprintf(Yap_stdout, " answer hashes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_ans_hash));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_ans_hash) * sizeof(struct answer_hash);
|
||||
fprintf(Yap_stdout, "%s dependency frames: %10ld structs in use\n",
|
||||
Pg_str_in_use(GLOBAL_PAGES_dep_fr) == 1 ? " ": "*", Pg_str_in_use(GLOBAL_PAGES_dep_fr));
|
||||
@ -1225,8 +1223,7 @@ void shm_answer_hashes(long *pages_in_use, long *bytes_in_use) {
|
||||
pg_hd = PgHd_next(pg_hd);
|
||||
}
|
||||
fprintf(Yap_stdout, "%s answer hashes: %8ld pages %10ld structs in use\n",
|
||||
Pg_str_free(GLOBAL_PAGES_ans_hash) == cont &&
|
||||
Pg_str_in_use(GLOBAL_PAGES_ans_hash) == 0 ? " ": "*",
|
||||
Pg_str_free(GLOBAL_PAGES_ans_hash) == cont ? " ": "*",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_ans_hash), Pg_str_in_use(GLOBAL_PAGES_ans_hash));
|
||||
*pages_in_use += Pg_pg_alloc(GLOBAL_PAGES_ans_hash);
|
||||
*bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_ans_hash) * sizeof(struct answer_hash);
|
||||
|
@ -67,7 +67,7 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr);
|
||||
ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr);
|
||||
void load_answer_trie(ans_node_ptr ans_node, CELL *subs_ptr);
|
||||
void private_completion(sg_fr_ptr sg_fr);
|
||||
void free_subgoal_trie_branch(sg_node_ptr node, int missing_nodes);
|
||||
void free_subgoal_trie_branch(sg_node_ptr node, int nodes_left, int nodes_extra);
|
||||
void free_answer_trie_branch(ans_node_ptr node);
|
||||
void update_answer_trie(sg_fr_ptr sg_fr);
|
||||
void traverse_table(tab_ent_ptr tab_ent, int show_table);
|
||||
|
@ -158,7 +158,7 @@ struct global_data{
|
||||
volatile bitmap pruning_workers;
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
struct global_locks locks;
|
||||
volatile unsigned int branch[MAX_WORKERS][MAX_DEPTH];
|
||||
volatile unsigned int branch[MAX_WORKERS][MAX_BRANCH_DEPTH];
|
||||
volatile char parallel_execution_mode; /* TRUE / FALSE */
|
||||
volatile int answers;
|
||||
#endif /* YAPOR */
|
||||
|
@ -204,7 +204,7 @@ void share_private_nodes(int worker_q) {
|
||||
OrFr_nearest_livenode(previous_or_frame) = OrFr_next(previous_or_frame) = or_frame;
|
||||
}
|
||||
/* update depth */
|
||||
if (depth >= MAX_DEPTH)
|
||||
if (depth >= MAX_BRANCH_DEPTH)
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "maximum depth exceded (share_private_nodes)");
|
||||
or_frame = B->cp_or_fr;
|
||||
while (or_frame != LOCAL_top_or_fr) {
|
||||
|
@ -587,7 +587,7 @@ void share_private_nodes(int worker_q) {
|
||||
#endif /* TABLING */
|
||||
|
||||
/* update depth */
|
||||
if (depth >= MAX_DEPTH)
|
||||
if (depth >= MAX_BRANCH_DEPTH)
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "maximum depth exceded (share_private_nodes)");
|
||||
or_frame = B->cp_or_fr;
|
||||
#ifdef TABLING
|
||||
|
@ -269,7 +269,7 @@ void share_private_nodes(int worker_q) {
|
||||
OrFr_nearest_livenode(previous_or_frame) = OrFr_next(previous_or_frame) = or_frame;
|
||||
}
|
||||
/* update depth */
|
||||
if (depth >= MAX_DEPTH)
|
||||
if (depth >= MAX_BRANCH_DEPTH)
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "maximum depth exceded (share_private_nodes)");
|
||||
or_frame = B->cp_or_fr;
|
||||
|
||||
|
@ -111,6 +111,11 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p
|
||||
#define IsTableVarTerm(TERM) \
|
||||
((CELL) TERM) >= GLOBAL_table_var_enumerator(0) && \
|
||||
((CELL) TERM) <= GLOBAL_table_var_enumerator(MAX_TABLE_VARS - 1)
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
#define PairTermMark NULL
|
||||
#define PairTermInit ((Term *) 0)
|
||||
#define PairTermLast ((Term *) (LowTagBits + 1))
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
|
||||
#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)))
|
||||
|
@ -714,10 +714,35 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
|
||||
} else if (IsAtomOrIntTerm(t)) {
|
||||
current_sg_node = subgoal_trie_node_check_insert(tab_ent, current_sg_node, t);
|
||||
} else if (IsPairTerm(t)) {
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
CELL *aux = RepPair(t);
|
||||
if (aux == PairTermMark) {
|
||||
t = Deref(STACK_POP_DOWN(stack_terms));
|
||||
if (IsPairTerm(t)) {
|
||||
aux = RepPair(t);
|
||||
/* STACK_CHECK_EXPAND(stack_terms, stack_terms_limit + 2, stack_terms_base); */
|
||||
/* STACK_CHECK_EXPAND is not necessary here because the situation of pushing **
|
||||
** up 3 terms has already initially checked for the PairTermInit term */
|
||||
STACK_PUSH_UP(*(aux + 1), stack_terms);
|
||||
STACK_PUSH_UP(AbsPair(PairTermMark), stack_terms);
|
||||
STACK_PUSH_UP(*(aux), stack_terms);
|
||||
} else {
|
||||
current_sg_node = subgoal_trie_node_check_insert(tab_ent, current_sg_node, AbsPair(PairTermLast));
|
||||
STACK_PUSH_UP(t, stack_terms);
|
||||
}
|
||||
} else {
|
||||
current_sg_node = subgoal_trie_node_check_insert(tab_ent, current_sg_node, AbsPair(PairTermInit));
|
||||
STACK_CHECK_EXPAND(stack_terms, stack_terms_limit + 2, stack_terms_base);
|
||||
STACK_PUSH_UP(*(aux + 1), stack_terms);
|
||||
STACK_PUSH_UP(AbsPair(PairTermMark), stack_terms);
|
||||
STACK_PUSH_UP(*(aux), stack_terms);
|
||||
}
|
||||
#else
|
||||
current_sg_node = subgoal_trie_node_check_insert(tab_ent, current_sg_node, AbsPair(NULL));
|
||||
STACK_CHECK_EXPAND(stack_terms, stack_terms_limit + 1, stack_terms_base);
|
||||
STACK_PUSH_UP(*(RepPair(t) + 1), stack_terms);
|
||||
STACK_PUSH_UP(*(RepPair(t)), stack_terms);
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
current_sg_node = subgoal_trie_node_check_insert(tab_ent, current_sg_node, AbsAppl((Term *)f));
|
||||
@ -731,6 +756,10 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
|
||||
} else if (f == FunctorLongInt) {
|
||||
Int li = LongIntOfTerm(t);
|
||||
current_sg_node = subgoal_trie_node_check_insert(tab_ent, current_sg_node, li);
|
||||
} else if (f == FunctorDBRef) {
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "unsupported type tag (FunctorDBRef in subgoal_search)");
|
||||
} else if (f == FunctorBigInt) {
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "unsupported type tag (FunctorBigInt in subgoal_search)");
|
||||
} else {
|
||||
STACK_CHECK_EXPAND(stack_terms, stack_terms_limit + ArityOfFunctor(f) - 1, stack_terms_base);
|
||||
for (j = ArityOfFunctor(f); j >= 1; j--)
|
||||
@ -782,6 +811,11 @@ ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
||||
int i, j, count_vars, subs_arity;
|
||||
CELL *stack_vars, *stack_terms_base, *stack_terms;
|
||||
ans_node_ptr current_ans_node;
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
int in_new_list = 0;
|
||||
#else
|
||||
#define in_new_list 0
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
|
||||
count_vars = 0;
|
||||
subs_arity = *subs_ptr;
|
||||
@ -801,7 +835,7 @@ ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
||||
if (IsVarTerm(t)) {
|
||||
if (IsTableVarTerm(t)) {
|
||||
t = MakeTableVarTerm(VarIndexOfTerm(t));
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, t, _trie_retry_val);
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, t, _trie_retry_val + in_new_list);
|
||||
} else {
|
||||
if (count_vars == MAX_TABLE_VARS)
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "MAX_TABLE_VARS exceeded (answer_search)");
|
||||
@ -809,21 +843,54 @@ ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
||||
*((CELL *)t) = GLOBAL_table_var_enumerator(count_vars);
|
||||
t = MakeTableVarTerm(count_vars);
|
||||
count_vars++;
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, t, _trie_retry_var);
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, t, _trie_retry_var + in_new_list);
|
||||
}
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
in_new_list = 0;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
} else if (IsAtomOrIntTerm(t)) {
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, t, _trie_retry_atom);
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, t, _trie_retry_atom + in_new_list);
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
in_new_list = 0;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
} else if (IsPairTerm(t)) {
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
CELL *aux = RepPair(t);
|
||||
if (aux == PairTermMark) {
|
||||
t = Deref(STACK_POP_DOWN(stack_terms));
|
||||
if (IsPairTerm(t)) {
|
||||
aux = RepPair(t);
|
||||
/* STACK_CHECK_EXPAND(stack_terms, stack_vars + 2, stack_terms_base); */
|
||||
/* STACK_CHECK_EXPAND is not necessary here because the situation of pushing **
|
||||
** up 3 terms has already initially checked for the PairTermInit term */
|
||||
STACK_PUSH_UP(*(aux + 1), stack_terms);
|
||||
STACK_PUSH_UP(AbsPair(PairTermMark), stack_terms);
|
||||
STACK_PUSH_UP(*(aux), stack_terms);
|
||||
in_new_list = 4;
|
||||
} else {
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, AbsPair(PairTermLast), _trie_retry_null);
|
||||
STACK_PUSH_UP(t, stack_terms);
|
||||
}
|
||||
} else {
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, AbsPair(PairTermInit), _trie_retry_list + in_new_list);
|
||||
STACK_CHECK_EXPAND(stack_terms, stack_vars + 2, stack_terms_base);
|
||||
STACK_PUSH_UP(*(aux + 1), stack_terms);
|
||||
STACK_PUSH_UP(AbsPair(PairTermMark), stack_terms);
|
||||
STACK_PUSH_UP(*(aux), stack_terms);
|
||||
in_new_list = 0;
|
||||
}
|
||||
#else
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, AbsPair(NULL), _trie_retry_list);
|
||||
STACK_CHECK_EXPAND(stack_terms, stack_vars + 1, stack_terms_base);
|
||||
STACK_PUSH_UP(*(RepPair(t) + 1), stack_terms);
|
||||
STACK_PUSH_UP(*(RepPair(t)), stack_terms);
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
if (f == FunctorDouble) {
|
||||
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);
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, AbsAppl((Term *)f), _trie_retry_null + in_new_list);
|
||||
#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_INT_P */
|
||||
@ -831,15 +898,22 @@ ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, AbsAppl((Term *)f), _trie_retry_float);
|
||||
} else if (f == FunctorLongInt) {
|
||||
Int li = LongIntOfTerm (t);
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, AbsAppl((Term *)f), _trie_retry_null);
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, AbsAppl((Term *)f), _trie_retry_null + in_new_list);
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, li, _trie_retry_extension);
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, AbsAppl((Term *)f), _trie_retry_long);
|
||||
} else if (f == FunctorDBRef) {
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "unsupported type tag (FunctorDBRef in answer_search)");
|
||||
} else if (f == FunctorBigInt) {
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "unsupported type tag (FunctorBigInt in answer_search)");
|
||||
} else {
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, AbsAppl((Term *)f), _trie_retry_struct);
|
||||
current_ans_node = answer_trie_node_check_insert(sg_fr, current_ans_node, AbsAppl((Term *)f), _trie_retry_struct + in_new_list);
|
||||
STACK_CHECK_EXPAND(stack_terms, stack_vars + ArityOfFunctor(f) - 1, stack_terms_base);
|
||||
for (j = ArityOfFunctor(f); j >= 1; j--)
|
||||
STACK_PUSH_UP(*(RepAppl(t) + j), stack_terms);
|
||||
}
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
in_new_list = 0;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
} else {
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "unknown type tag (answer_search)");
|
||||
}
|
||||
@ -860,6 +934,9 @@ void load_answer_trie(ans_node_ptr ans_node, CELL *subs_ptr) {
|
||||
CELL *stack_vars_base, *stack_vars, *stack_terms_base, *stack_terms;
|
||||
int subs_arity, i, n_vars = -1;
|
||||
Term t;
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
int stack_terms_pair_offset = 0;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
|
||||
if ((subs_arity = *subs_ptr) == 0)
|
||||
return;
|
||||
@ -890,10 +967,31 @@ void load_answer_trie(ans_node_ptr ans_node, CELL *subs_ptr) {
|
||||
STACK_CHECK_EXPAND(stack_terms, stack_vars, stack_terms_base);
|
||||
STACK_PUSH_UP(t, stack_terms);
|
||||
} else if (IsPairTerm(t)) {
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
if (t == AbsPair(PairTermInit)) {
|
||||
Term *stack_aux = stack_terms_base - stack_terms_pair_offset;
|
||||
Term head, tail = STACK_POP_UP(stack_aux);
|
||||
while (STACK_NOT_EMPTY(stack_aux, stack_terms)) {
|
||||
head = STACK_POP_UP(stack_aux);
|
||||
tail = MkPairTerm(head, tail);
|
||||
}
|
||||
stack_terms = stack_terms_base - stack_terms_pair_offset;
|
||||
stack_terms_pair_offset = (int) STACK_POP_DOWN(stack_terms);
|
||||
STACK_PUSH_UP(tail, stack_terms);
|
||||
} else { /* AbsPair(PairTermLast)) */
|
||||
Term last;
|
||||
STACK_CHECK_EXPAND(stack_terms, stack_vars, stack_terms_base);
|
||||
last = STACK_POP_DOWN(stack_terms);
|
||||
STACK_PUSH_UP(stack_terms_pair_offset, stack_terms);
|
||||
stack_terms_pair_offset = (int) (stack_terms_base - stack_terms);
|
||||
STACK_PUSH_UP(last, stack_terms);
|
||||
}
|
||||
#else
|
||||
Term head = STACK_POP_DOWN(stack_terms);
|
||||
Term tail = STACK_POP_DOWN(stack_terms);
|
||||
t = MkPairTerm(head, tail);
|
||||
STACK_PUSH_UP(t, stack_terms);
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor f = (Functor) RepAppl(t);
|
||||
if (f == FunctorDouble) {
|
||||
@ -925,8 +1023,6 @@ void load_answer_trie(ans_node_ptr ans_node, CELL *subs_ptr) {
|
||||
STACK_CHECK_EXPAND(stack_terms, stack_vars, stack_terms_base);
|
||||
STACK_PUSH_UP(t, stack_terms);
|
||||
}
|
||||
} else {
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "unknown type tag (load_answer_trie)");
|
||||
}
|
||||
t = TrNode_entry(ans_node);
|
||||
ans_node = TrNode_parent(ans_node);
|
||||
@ -984,25 +1080,52 @@ void private_completion(sg_fr_ptr sg_fr) {
|
||||
}
|
||||
|
||||
|
||||
void free_subgoal_trie_branch(sg_node_ptr node, int missing_nodes) {
|
||||
Term t;
|
||||
|
||||
void free_subgoal_trie_branch(sg_node_ptr node, int nodes_left, int nodes_extra) {
|
||||
if (TrNode_next(node))
|
||||
free_subgoal_trie_branch(TrNode_next(node), missing_nodes);
|
||||
free_subgoal_trie_branch(TrNode_next(node), nodes_left, nodes_extra);
|
||||
|
||||
t = TrNode_entry(node);
|
||||
if (IsVarTerm(t) || IsAtomOrIntTerm(t)) {
|
||||
missing_nodes -= 1;
|
||||
} else if (IsPairTerm(t)) {
|
||||
missing_nodes += 1;
|
||||
} else if (IsApplTerm(t)) {
|
||||
missing_nodes += ArityOfFunctor((Functor)RepAppl(t)) - 1;
|
||||
if (nodes_extra) {
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
if (nodes_extra < 0) {
|
||||
Term t = TrNode_entry(node);
|
||||
if (IsPairTerm(t)) {
|
||||
if (t == AbsPair(PairTermInit))
|
||||
nodes_extra--;
|
||||
else /* AbsPair(PairTermLast) */
|
||||
nodes_extra++;
|
||||
}
|
||||
} else
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
if (--nodes_extra == 0)
|
||||
nodes_left--;
|
||||
} else {
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "unknown type tag (chain_subgoal_frames)");
|
||||
Term t = TrNode_entry(node);
|
||||
if (IsVarTerm(t) || IsAtomOrIntTerm(t))
|
||||
nodes_left--;
|
||||
else if (IsPairTerm(t))
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
/* AbsPair(PairTermInit) */
|
||||
nodes_extra = -1;
|
||||
#else
|
||||
nodes_left++;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
else if (IsApplTerm(t)) {
|
||||
Functor f = (Functor) RepAppl(t);
|
||||
if (f == FunctorDouble)
|
||||
#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P
|
||||
nodes_extra = 2;
|
||||
#else
|
||||
nodes_extra = 1;
|
||||
#endif /* SIZEOF_DOUBLE x SIZEOF_INT_P */
|
||||
else if (f == FunctorLongInt)
|
||||
nodes_extra = 1;
|
||||
else
|
||||
nodes_left += ArityOfFunctor(f) - 1;
|
||||
}
|
||||
}
|
||||
if (missing_nodes) {
|
||||
free_subgoal_trie_branch(TrNode_child(node), missing_nodes);
|
||||
} else {
|
||||
if (nodes_left)
|
||||
free_subgoal_trie_branch(TrNode_child(node), nodes_left, nodes_extra);
|
||||
else {
|
||||
sg_fr_ptr sg_fr;
|
||||
ans_node_ptr ans_node;
|
||||
sg_fr = (sg_fr_ptr) TrNode_sg_fr(node);
|
||||
@ -1286,6 +1409,12 @@ void traverse_subgoal_trie(sg_node_ptr sg_node, char *str, int str_index, int *a
|
||||
sg_node = *bucket;
|
||||
traverse_subgoal_trie(sg_node, str, str_index, arity, depth, mode);
|
||||
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
|
||||
if (arity[arity[0]] == -1)
|
||||
str[str_index - 1] = '|';
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
else if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
|
||||
str[str_index - 1] = ',';
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
}
|
||||
} while (++bucket != last_bucket);
|
||||
free(current_arity);
|
||||
@ -1301,6 +1430,10 @@ void traverse_subgoal_trie(sg_node_ptr sg_node, char *str, int str_index, int *a
|
||||
free(current_arity);
|
||||
if (arity[arity[0]] == -1)
|
||||
str[str_index - 1] = '|';
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
else if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
|
||||
str[str_index - 1] = ',';
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
}
|
||||
|
||||
/* test the node type */
|
||||
@ -1334,13 +1467,17 @@ void traverse_subgoal_trie(sg_node_ptr sg_node, char *str, int str_index, int *a
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
arity[arity[0]]++;
|
||||
if (arity[arity[0]] == 0) {
|
||||
if (arity[arity[0]] == -2) {
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
str_index += sprintf(& str[str_index], ",");
|
||||
#else
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
arity[arity[0]] = -1;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
break;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "]");
|
||||
arity[0]--;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1363,13 +1500,17 @@ void traverse_subgoal_trie(sg_node_ptr sg_node, char *str, int str_index, int *a
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
arity[arity[0]]++;
|
||||
if (arity[arity[0]] == 0) {
|
||||
if (arity[arity[0]] == -2) {
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
str_index += sprintf(& str[str_index], ",");
|
||||
#else
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
arity[arity[0]] = -1;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
break;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "]");
|
||||
arity[0]--;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1391,13 +1532,17 @@ void traverse_subgoal_trie(sg_node_ptr sg_node, char *str, int str_index, int *a
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
arity[arity[0]]++;
|
||||
if (arity[arity[0]] == 0) {
|
||||
if (arity[arity[0]] == -2) {
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
str_index += sprintf(& str[str_index], ",");
|
||||
#else
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
arity[arity[0]] = -1;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
break;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "]");
|
||||
arity[0]--;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1418,13 +1563,17 @@ void traverse_subgoal_trie(sg_node_ptr sg_node, char *str, int str_index, int *a
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
arity[arity[0]]++;
|
||||
if (arity[arity[0]] == 0) {
|
||||
if (arity[arity[0]] == -2) {
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
str_index += sprintf(& str[str_index], ",");
|
||||
#else
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
arity[arity[0]] = -1;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
break;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "]");
|
||||
arity[0]--;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1445,20 +1594,30 @@ void traverse_subgoal_trie(sg_node_ptr sg_node, char *str, int str_index, int *a
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
arity[arity[0]]++;
|
||||
if (arity[arity[0]] == 0) {
|
||||
if (arity[arity[0]] == -2) {
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
str_index += sprintf(& str[str_index], ",");
|
||||
#else
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
arity[arity[0]] = -1;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
break;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "]");
|
||||
arity[0]--;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (IsPairTerm(t)) {
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
if (t == AbsPair(PairTermLast)) {
|
||||
str[str_index - 1] = '|';
|
||||
arity[arity[0]] = -1;
|
||||
#else
|
||||
if (arity[arity[0]] == -1) {
|
||||
str[str_index - 1] = ',';
|
||||
arity[arity[0]] = -2;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "[");
|
||||
arity[0]++;
|
||||
@ -1475,8 +1634,6 @@ void traverse_subgoal_trie(sg_node_ptr sg_node, char *str, int str_index, int *a
|
||||
arity[0]++;
|
||||
arity[arity[0]] = ArityOfFunctor(f);
|
||||
}
|
||||
} else {
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "unknown type tag (traverse_subgoal_trie)");
|
||||
}
|
||||
|
||||
TrStat_sg_nodes++;
|
||||
@ -1549,6 +1706,12 @@ void traverse_answer_trie(ans_node_ptr ans_node, char *str, int str_index, int *
|
||||
ans_node = *bucket;
|
||||
traverse_answer_trie(ans_node, str, str_index, arity, var_index, depth, mode);
|
||||
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
|
||||
if (arity[arity[0]] == -1)
|
||||
str[str_index - 1] = '|';
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
else if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
|
||||
str[str_index - 1] = ',';
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
}
|
||||
} while (++bucket != last_bucket);
|
||||
free(current_arity);
|
||||
@ -1564,6 +1727,10 @@ void traverse_answer_trie(ans_node_ptr ans_node, char *str, int str_index, int *
|
||||
free(current_arity);
|
||||
if (arity[arity[0]] == -1)
|
||||
str[str_index - 1] = '|';
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
else if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
|
||||
str[str_index - 1] = ',';
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
}
|
||||
|
||||
/* print VAR when starting a term */
|
||||
@ -1602,13 +1769,17 @@ void traverse_answer_trie(ans_node_ptr ans_node, char *str, int str_index, int *
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
arity[arity[0]]++;
|
||||
if (arity[arity[0]] == 0) {
|
||||
if (arity[arity[0]] == -2) {
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
str_index += sprintf(& str[str_index], ",");
|
||||
#else
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
arity[arity[0]] = -1;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
break;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "]");
|
||||
arity[0]--;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1633,13 +1804,17 @@ void traverse_answer_trie(ans_node_ptr ans_node, char *str, int str_index, int *
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
arity[arity[0]]++;
|
||||
if (arity[arity[0]] == 0) {
|
||||
if (arity[arity[0]] == -2) {
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
str_index += sprintf(& str[str_index], ",");
|
||||
#else
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
arity[arity[0]] = -1;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
break;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "]");
|
||||
arity[0]--;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1663,13 +1838,17 @@ void traverse_answer_trie(ans_node_ptr ans_node, char *str, int str_index, int *
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
arity[arity[0]]++;
|
||||
if (arity[arity[0]] == 0) {
|
||||
if (arity[arity[0]] == -2) {
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
str_index += sprintf(& str[str_index], ",");
|
||||
#else
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
arity[arity[0]] = -1;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
break;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "]");
|
||||
arity[0]--;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1690,13 +1869,17 @@ void traverse_answer_trie(ans_node_ptr ans_node, char *str, int str_index, int *
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
arity[arity[0]]++;
|
||||
if (arity[arity[0]] == 0) {
|
||||
if (arity[arity[0]] == -2) {
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
str_index += sprintf(& str[str_index], ",");
|
||||
#else
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
arity[arity[0]] = -1;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
break;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "]");
|
||||
arity[0]--;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1717,20 +1900,30 @@ void traverse_answer_trie(ans_node_ptr ans_node, char *str, int str_index, int *
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
arity[arity[0]]++;
|
||||
if (arity[arity[0]] == 0) {
|
||||
if (arity[arity[0]] == -2) {
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
str_index += sprintf(& str[str_index], ",");
|
||||
#else
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
arity[arity[0]] = -1;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
break;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "]");
|
||||
arity[0]--;
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "|");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (IsPairTerm(t)) {
|
||||
#ifdef TRIE_COMPACT_LISTS
|
||||
if (t == AbsPair(PairTermLast)) {
|
||||
str[str_index - 1] = '|';
|
||||
arity[arity[0]] = -1;
|
||||
#else
|
||||
if (arity[arity[0]] == -1) {
|
||||
str[str_index - 1] = ',';
|
||||
arity[arity[0]] = -2;
|
||||
#endif /* TRIE_COMPACT_LISTS */
|
||||
} else {
|
||||
str_index += sprintf(& str[str_index], "[");
|
||||
arity[0]++;
|
||||
@ -1747,8 +1940,6 @@ void traverse_answer_trie(ans_node_ptr ans_node, char *str, int str_index, int *
|
||||
arity[0]++;
|
||||
arity[arity[0]] = ArityOfFunctor(f);
|
||||
}
|
||||
} else {
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "unknown type tag (traverse_answer_trie)");
|
||||
}
|
||||
|
||||
TrStat_ans_nodes++;
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user