Merge branch 'master' of yap.dcc.fc.up.pt:yap-6
This commit is contained in:
commit
c8c5c3d1dc
1
C/agc.c
1
C/agc.c
@ -126,6 +126,7 @@ AtomAdjust(Atom a)
|
||||
|
||||
#define REINIT_LOCK(P)
|
||||
#define REINIT_RWLOCK(P)
|
||||
#define NoAGCAtomAdjust(P) (P)
|
||||
#define OrArgAdjust(P)
|
||||
#define TabEntryAdjust(P)
|
||||
#define IntegerAdjust(D) (D)
|
||||
|
42
C/amasm.c
42
C/amasm.c
@ -1480,7 +1480,7 @@ a_p(op_numbers opcode, clause_info *clinfo, yamop *code_p, int pass_no, struct i
|
||||
op = _p_equal; /* just to make some compilers happy */
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "internal assembler error for built-in (%d)", (Flags & 0x7f));
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
_longjmp(cip->CompilerBotch, 1);
|
||||
}
|
||||
if (is_test) {
|
||||
UInt lab;
|
||||
@ -1503,7 +1503,7 @@ a_p(op_numbers opcode, clause_info *clinfo, yamop *code_p, int pass_no, struct i
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, TermNil,
|
||||
"user defined predicate cannot be a test predicate");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
_longjmp(cip->CompilerBotch, 1);
|
||||
} else
|
||||
code_p->opc = emit_op(_call_c_wfail);
|
||||
code_p->u.slp.s =
|
||||
@ -2053,7 +2053,7 @@ a_try(op_numbers opcode, CELL lab, CELL opr, int nofalts, int hascut, yamop *cod
|
||||
if ((newcp = (yamop *)Yap_AllocCodeSpace(size)) == NULL) {
|
||||
/* OOOPS, got in trouble, must do a longjmp and recover space */
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch,2);
|
||||
_longjmp(cip->CompilerBotch,2);
|
||||
}
|
||||
Yap_LUIndexSpace_CP += size;
|
||||
#ifdef DEBUG
|
||||
@ -2693,7 +2693,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci
|
||||
case _plus:
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for +/2 (should be XC)");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
_longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _minus:
|
||||
code_p->opc = emit_op(_p_minus_y_cv);
|
||||
@ -2701,7 +2701,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci
|
||||
case _times:
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for */2 (should be XC)");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
_longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _div:
|
||||
code_p->opc = emit_op(_p_div_y_cv);
|
||||
@ -2709,12 +2709,12 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci
|
||||
case _and:
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for /\\/2 (should be XC)");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
_longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _or:
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for \\//2 (should be XC)");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
_longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _sll:
|
||||
code_p->opc = emit_op(_p_sll_y_cv);
|
||||
@ -2744,7 +2744,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci
|
||||
case _minus:
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x2_arg, "internal assembler error XC for -/2");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
_longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _times:
|
||||
code_p->opc = emit_op(_p_times_y_vc);
|
||||
@ -2777,7 +2777,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci
|
||||
case _arg:
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x2_arg, "internal assembler error for arg/3");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
_longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _functor:
|
||||
code_p->opc = emit_op(_p_func2s_y_vc);
|
||||
@ -2838,7 +2838,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci
|
||||
case _plus:
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for +/2");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
_longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _minus:
|
||||
code_p->opc = emit_op(_p_minus_cv);
|
||||
@ -2846,7 +2846,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci
|
||||
case _times:
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for */2");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
_longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _div:
|
||||
code_p->opc = emit_op(_p_div_cv);
|
||||
@ -2854,12 +2854,12 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci
|
||||
case _and:
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for /\\/2");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
_longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _or:
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for \\//2");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
_longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _sll:
|
||||
code_p->opc = emit_op(_p_sll_cv);
|
||||
@ -2889,7 +2889,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci
|
||||
case _minus:
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x2_arg, "internal assembler error XC for -/2");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
_longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _times:
|
||||
code_p->opc = emit_op(_p_times_vc);
|
||||
@ -2922,7 +2922,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci
|
||||
case _arg:
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x2_arg, "internal assembler error for arg/3");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
_longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _functor:
|
||||
code_p->opc = emit_op(_p_func2s_vc);
|
||||
@ -3540,7 +3540,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
||||
if (CellPtr(cip->label_offset+cip->cpc->rnd1) > ASP-256) {
|
||||
Yap_Error_Size = 256+((char *)(cip->label_offset+cip->cpc->rnd1) - (char *)H);
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 3);
|
||||
_longjmp(cip->CompilerBotch, 3);
|
||||
}
|
||||
if ( (char *)(cip->label_offset+cip->cpc->rnd1) >= cip->freep)
|
||||
cip->freep = (char *)(cip->label_offset+(cip->cpc->rnd1+1));
|
||||
@ -3722,7 +3722,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
||||
if (cip->cpc->nextInst->op != bccall_op) {
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "compiling binary test", (int) cip->cpc->op);
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
_longjmp(cip->CompilerBotch, 1);
|
||||
}
|
||||
code_p = a_bfunc(cip->cpc->nextInst->rnd2, &clinfo, code_p, pass_no, cip);
|
||||
break;
|
||||
@ -3762,7 +3762,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
||||
default:
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "instruction %d found while assembling", (int) cip->cpc->op);
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
_longjmp(cip->CompilerBotch, 1);
|
||||
}
|
||||
cip->cpc = cip->cpc->nextInst;
|
||||
}
|
||||
@ -3788,7 +3788,7 @@ fetch_clause_space(Term* tp, UInt size, struct intermediates *cip, UInt *osizep)
|
||||
case OUT_OF_STACK_ERROR:
|
||||
Yap_Error_Size = 256+((char *)cip->freep - (char *)H);
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch,3);
|
||||
_longjmp(cip->CompilerBotch,3);
|
||||
case OUT_OF_TRAIL_ERROR:
|
||||
/* don't just return NULL */
|
||||
ARG1 = *tp;
|
||||
@ -3865,7 +3865,7 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
||||
Yap_LabelFirstArraySz = DEFAULT_NLABELS;
|
||||
if (!Yap_LabelFirstArray) {
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
_longjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
}
|
||||
}
|
||||
if (Yap_LabelFirstArray && max_label <= Yap_LabelFirstArraySz) {
|
||||
@ -3874,7 +3874,7 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
||||
cip->label_offset = (Int *)Yap_AllocCodeSpace(sizeof(Int)*max_label);
|
||||
if (!cip->label_offset) {
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
_longjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
35
C/cdmgr.c
35
C/cdmgr.c
@ -200,7 +200,7 @@
|
||||
* Revision 1.174 2005/12/23 00:20:13 vsc
|
||||
* updates to gprof
|
||||
* support for __POWER__
|
||||
* Try to saveregs before longjmp.
|
||||
* Try to saveregs before _longjmp.
|
||||
*
|
||||
* Revision 1.173 2005/12/17 03:25:39 vsc
|
||||
* major changes to support online event-based profiling
|
||||
@ -5169,6 +5169,31 @@ p_continue_static_clause(void)
|
||||
|
||||
#if LOW_PROF
|
||||
|
||||
static void
|
||||
add_code_in_lu_index(LogUpdIndex *cl, PredEntry *pp)
|
||||
{
|
||||
char *code_end = (char *)cl + cl->ClSize;
|
||||
Yap_inform_profiler_of_clause(cl->ClCode, (yamop *)code_end, pp,0);
|
||||
cl = cl->ChildIndex;
|
||||
while (cl != NULL) {
|
||||
add_code_in_lu_index(cl, pp);
|
||||
cl = cl->SiblingIndex;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_code_in_static_index(StaticIndex *cl, PredEntry *pp)
|
||||
{
|
||||
char *code_end = (char *)cl + cl->ClSize;
|
||||
Yap_inform_profiler_of_clause(cl->ClCode, (yamop *)code_end, pp,0);
|
||||
cl = cl->ChildIndex;
|
||||
while (cl != NULL) {
|
||||
add_code_in_static_index(cl, pp);
|
||||
cl = cl->SiblingIndex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
add_code_in_pred(PredEntry *pp) {
|
||||
yamop *clcode;
|
||||
@ -5192,15 +5217,13 @@ add_code_in_pred(PredEntry *pp) {
|
||||
Yap_inform_profiler_of_clause((yamop *)&(pp->cs.p_code.ExpandCode), (yamop *)(&(pp->cs.p_code.ExpandCode)+1), pp, 1);
|
||||
clcode = pp->cs.p_code.TrueCodeOfPred;
|
||||
if (pp->PredFlags & IndexedPredFlag) {
|
||||
char *code_end;
|
||||
if (pp->PredFlags & LogUpdatePredFlag) {
|
||||
LogUpdIndex *cl = ClauseCodeToLogUpdIndex(clcode);
|
||||
code_end = (char *)cl + cl->ClSize;
|
||||
add_code_in_lu_index(cl, pp);
|
||||
} else {
|
||||
StaticIndex *cl = ClauseCodeToStaticIndex(clcode);
|
||||
code_end = (char *)cl + cl->ClSize;
|
||||
add_code_in_static_index(cl, pp);
|
||||
}
|
||||
Yap_inform_profiler_of_clause(clcode, (yamop *)code_end, pp,0);
|
||||
}
|
||||
clcode = pp->cs.p_code.FirstClause;
|
||||
if (clcode != NULL) {
|
||||
@ -5232,7 +5255,7 @@ add_code_in_pred(PredEntry *pp) {
|
||||
|
||||
code_end = (char *)cl + cl->ClSize;
|
||||
Yap_inform_profiler_of_clause(cl->ClCode, (yamop *)code_end, pp,0);
|
||||
if (cl->ClCode == pp->cs.p_code.FirstClause)
|
||||
if (cl->ClCode == pp->cs.p_code.LastClause)
|
||||
break;
|
||||
cl = cl->ClNext;
|
||||
} while (TRUE);
|
||||
|
92
C/compiler.c
92
C/compiler.c
@ -533,7 +533,7 @@ optimize_ce(Term t, unsigned int arity, unsigned int level, compiler_struct *cgl
|
||||
if (H >= (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
p->NextCE = cglobs->common_exps;
|
||||
cglobs->common_exps = p;
|
||||
@ -568,7 +568,7 @@ compile_sf_term(Term t, int argno, int level)
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "illegal argument of soft functor";
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
}
|
||||
else
|
||||
c_var(t, -argno, arity, level, cglobs);
|
||||
@ -595,7 +595,7 @@ c_args(Term app, unsigned int level, compiler_struct *cglobs)
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "exceed maximum arity of compiled goal";
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
}
|
||||
if (Arity > cglobs->max_args)
|
||||
cglobs->max_args = Arity;
|
||||
@ -615,7 +615,7 @@ try_store_as_dbterm(Term t, Int argno, unsigned int arity, int level, compiler_s
|
||||
/* oops, too deep a term */
|
||||
save_machine_regs();
|
||||
Yap_Error_Size = 0;
|
||||
longjmp(cglobs->cint.CompilerBotch, OUT_OF_AUX_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch, OUT_OF_AUX_BOTCH);
|
||||
}
|
||||
if (g < 16)
|
||||
return FALSE;
|
||||
@ -626,18 +626,18 @@ try_store_as_dbterm(Term t, Int argno, unsigned int arity, int level, compiler_s
|
||||
switch(Yap_Error_TYPE) {
|
||||
case OUT_OF_STACK_ERROR:
|
||||
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||
longjmp(cglobs->cint.CompilerBotch,OUT_OF_STACK_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_STACK_BOTCH);
|
||||
case OUT_OF_TRAIL_ERROR:
|
||||
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||
longjmp(cglobs->cint.CompilerBotch,OUT_OF_TRAIL_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TRAIL_BOTCH);
|
||||
case OUT_OF_HEAP_ERROR:
|
||||
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||
longjmp(cglobs->cint.CompilerBotch,OUT_OF_HEAP_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_HEAP_BOTCH);
|
||||
case OUT_OF_AUXSPACE_ERROR:
|
||||
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||
longjmp(cglobs->cint.CompilerBotch,OUT_OF_AUX_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_AUX_BOTCH);
|
||||
default:
|
||||
longjmp(cglobs->cint.CompilerBotch,COMPILER_ERR_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch,COMPILER_ERR_BOTCH);
|
||||
}
|
||||
}
|
||||
H = h0;
|
||||
@ -1004,7 +1004,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2 with output bound", s);
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,1);
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
}
|
||||
} else { /* t1 is bound */
|
||||
@ -1019,7 +1019,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/3",s);
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,1);
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
} else {
|
||||
if (Op == _functor) {
|
||||
@ -1035,7 +1035,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling functor/3");
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,1);
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
i2 = IntegerOfTerm(t2);
|
||||
if (i2 < 0) {
|
||||
@ -1047,7 +1047,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling functor/3");
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,1);
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
if (IsNumTerm(t1)) {
|
||||
/* we will always fail */
|
||||
@ -1062,7 +1062,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling functor/3");
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,1);
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
if (i2 == 0)
|
||||
c_eq(t1, t3, cglobs);
|
||||
@ -1074,7 +1074,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
if (H+2 >= (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
RESET_VARIABLE(H);
|
||||
RESET_VARIABLE(H+1);
|
||||
@ -1086,7 +1086,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
if (H >= (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
RESET_VARIABLE(H);
|
||||
H++;
|
||||
@ -1098,7 +1098,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Prop p0 = PredPropByFunc(f, mod);
|
||||
if (EndOfPAEntr(p0)) {
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
}
|
||||
c_args(Goal, 0, cglobs);
|
||||
Yap_emit(safe_call_op, (CELL)p0 , Zero, &cglobs->cint);
|
||||
@ -1120,7 +1120,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,1);
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
if (IsAtomicTerm(t2) ||
|
||||
(IsApplTerm(t2) && IsExtensionFunctor(FunctorOfTerm(t2)))) {
|
||||
@ -1132,7 +1132,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,1);
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
} else if (IsApplTerm(t2)) {
|
||||
Functor f = FunctorOfTerm(t2);
|
||||
if (i1 < 1 || i1 > ArityOfFunctor(f)) {
|
||||
@ -1163,7 +1163,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,1);
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
}
|
||||
if (Op == _functor) {
|
||||
@ -1176,7 +1176,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,1);
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
} else {
|
||||
if (!IsVarTerm(t2)) {
|
||||
Int arity;
|
||||
@ -1191,7 +1191,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,1);
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
arity = IntOfTerm(t2);
|
||||
if (arity < 0) {
|
||||
@ -1209,12 +1209,12 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2", s);
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,1);
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
if (H+1+arity >= (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
tnew = AbsAppl(H);
|
||||
*H++ = (CELL)Yap_MkFunctor(AtomOfTerm(t1),arity);
|
||||
@ -1253,7 +1253,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2 with output bound", s);
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,1);
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
}
|
||||
/* then we compile the opcode/result */
|
||||
@ -1263,7 +1263,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
if (H == (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
c_var(tmpvar,f_flag,(unsigned int)Op, 0, cglobs);
|
||||
c_eq(tmpvar,t3, cglobs);
|
||||
@ -1276,7 +1276,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
|
||||
Yap_bip_name(Op, s);
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2 with input unbound", s);
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,1);
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
} else if (IsNewVar(t3) && cglobs->curbranch == 0 && cglobs->cint.CurrentPred->PredFlags & TabledPredFlag) {
|
||||
Term nv = MkVarTerm();
|
||||
@ -1342,7 +1342,7 @@ c_functor(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
|
||||
if (EndOfPAEntr(p0)) {
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
}
|
||||
if (profiling)
|
||||
Yap_emit(enter_profiling_op, (CELL)RepPredProp(p0), Zero, &cglobs->cint);
|
||||
@ -1443,7 +1443,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
Yap_Error_Term = M;
|
||||
Yap_ErrorMessage = "in module name";
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
}
|
||||
Goal = ArgOfTerm(2, Goal);
|
||||
mod = M;
|
||||
@ -1561,7 +1561,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
p = RepPredProp(p0 = Yap_PredPropByAtomNonThreadLocal(atom, mod));
|
||||
if (EndOfPAEntr(p0)) {
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
}
|
||||
/* if we are profiling, make sure we register we entered this predicate */
|
||||
if (profiling)
|
||||
@ -1574,7 +1574,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
p = RepPredProp(p0 = Yap_PredPropByFunctorNonThreadLocal(f, mod));
|
||||
if (EndOfPAEntr(p0)) {
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
}
|
||||
if (f == FunctorOr || f == FunctorVBar) {
|
||||
Term arg;
|
||||
@ -1649,7 +1649,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
if (H == (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
savecpc = cglobs->cint.cpc;
|
||||
savencpc = FirstP->nextInst;
|
||||
@ -1732,7 +1732,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
if (H == (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
push_branch(cglobs->onbranch, commitvar, cglobs);
|
||||
++cglobs->curbranch;
|
||||
@ -1767,7 +1767,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
if (H == (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
cglobs->onlast = FALSE;
|
||||
c_var(commitvar, save_b_flag, 1, 0, cglobs);
|
||||
@ -1882,7 +1882,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
Yap_ErrorMessage = Yap_ErrorSay;
|
||||
sprintf(Yap_ErrorMessage, "compiling %s/2 with second arg unbound", RepAtom(NameOfFunctor(p->FunctorOfPred))->StrOfAE);
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,1);
|
||||
_longjmp(cglobs->cint.CompilerBotch,1);
|
||||
}
|
||||
c_var(a1, bt1_flag, 2, 0, cglobs);
|
||||
cglobs->current_p0 = p0;
|
||||
@ -1893,7 +1893,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
if (H == (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
c_eq(t2, a2, cglobs);
|
||||
c_var(a1, bt1_flag, 2, 0, cglobs);
|
||||
@ -1906,7 +1906,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
if (H == (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
c_eq(t1, a1, cglobs);
|
||||
|
||||
@ -1920,7 +1920,7 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
||||
if (H == (CELL *)cglobs->cint.freep0) {
|
||||
/* oops, too many new variables */
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch,OUT_OF_TEMPS_BOTCH);
|
||||
}
|
||||
c_eq(t2, a2, cglobs);
|
||||
c_var(t1, bt1_flag, 2, 0, cglobs);
|
||||
@ -2287,7 +2287,7 @@ clear_bvarray(int var, CELL *bvarray
|
||||
Yap_ErrorMessage = "compiler internal error: variable initialised twice";
|
||||
fprintf(stderr," vsc: compiling7\n");
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
}
|
||||
cglobs->pbvars++;
|
||||
#endif
|
||||
@ -2328,7 +2328,7 @@ push_bvmap(int label, PInstr *pcpc, compiler_struct *cglobs)
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "Too many embedded disjunctions";
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
}
|
||||
/* the label instruction */
|
||||
bvstack[bvindex].lab = label;
|
||||
@ -2351,7 +2351,7 @@ reset_bvmap(CELL *bvarray, int nperm, compiler_struct *cglobs)
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "No embedding in disjunctions";
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
}
|
||||
env_size = (bvstack[bvindex-1].pc)->rnd1;
|
||||
size = env_size/(8*sizeof(CELL));
|
||||
@ -2371,7 +2371,7 @@ pop_bvmap(CELL *bvarray, int nperm, compiler_struct *cglobs)
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "Too few embedded disjunctions";
|
||||
/* save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH); */
|
||||
_longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH); */
|
||||
}
|
||||
reset_bvmap(bvarray, nperm, cglobs);
|
||||
bvindex--;
|
||||
@ -2641,7 +2641,7 @@ checktemp(Int arg, Int rn, compiler_vm_op ic, compiler_struct *cglobs)
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "too many temporaries";
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch, COMPILER_ERR_BOTCH);
|
||||
}
|
||||
v->NoOfVE = cglobs->vadr = vadr = TempVar | target1;
|
||||
v->KindOfVE = TempVar;
|
||||
@ -2774,7 +2774,7 @@ c_layout(compiler_struct *cglobs)
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "wrong number of variables found in bitmap";
|
||||
save_machine_regs();
|
||||
longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
_longjmp(cglobs->cint.CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -3319,7 +3319,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
|
||||
|
||||
/* make sure we know there was no error yet */
|
||||
Yap_ErrorMessage = NULL;
|
||||
if ((botch_why = setjmp(cglobs.cint.CompilerBotch))) {
|
||||
if ((botch_why = _setjmp(cglobs.cint.CompilerBotch))) {
|
||||
restore_machine_regs();
|
||||
reset_vars(cglobs.vtable);
|
||||
Yap_ReleaseCMem(&cglobs.cint);
|
||||
@ -3420,7 +3420,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src)
|
||||
cglobs.vtable = NULL;
|
||||
Yap_Error_Size = (256+maxvnum)*sizeof(CELL);
|
||||
save_machine_regs();
|
||||
longjmp(cglobs.cint.CompilerBotch,3);
|
||||
_longjmp(cglobs.cint.CompilerBotch,3);
|
||||
}
|
||||
cglobs.Uses = (Int *)(H+maxvnum);
|
||||
cglobs.Contents = (Term *)(H+maxvnum+(sizeof(Int)/sizeof(CELL))*MaxTemps);
|
||||
|
@ -122,7 +122,7 @@ AllocCMem (UInt size, struct intermediates *cip)
|
||||
if (!p) {
|
||||
Yap_Error_Size = size;
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
_longjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
}
|
||||
Yap_CMemFirstBlock = p;
|
||||
Yap_CMemFirstBlockSz = blksz;
|
||||
@ -132,7 +132,7 @@ AllocCMem (UInt size, struct intermediates *cip)
|
||||
if (!p) {
|
||||
Yap_Error_Size = size;
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
_longjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||
}
|
||||
}
|
||||
p->u.next = cip->blks;
|
||||
@ -152,7 +152,7 @@ AllocCMem (UInt size, struct intermediates *cip)
|
||||
if (ASP <= CellPtr (cip->freep) + 256) {
|
||||
Yap_Error_Size = 256+((char *)cip->freep - (char *)H);
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, OUT_OF_STACK_BOTCH);
|
||||
_longjmp(cip->CompilerBotch, OUT_OF_STACK_BOTCH);
|
||||
}
|
||||
return (p);
|
||||
#endif
|
||||
|
@ -34,7 +34,7 @@ static char SccsId[] = "%W% %G%";
|
||||
/* There are two options to implement traditional immediate update semantics.
|
||||
|
||||
- In the first option, we only remove an element of the chain when
|
||||
it is phisically disposed of. This simplifies things, because
|
||||
it is physically disposed of. This simplifies things, because
|
||||
pointers are always valid, but it complicates some stuff a bit:
|
||||
|
||||
o You may have go through long lines of deleted db entries before you
|
||||
|
15
C/errors.c
15
C/errors.c
@ -798,6 +798,21 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
serious = TRUE;
|
||||
}
|
||||
break;
|
||||
case DOMAIN_ERROR_STREAM_ENCODING:
|
||||
{
|
||||
int i;
|
||||
Term ti[2];
|
||||
|
||||
i = strlen(tmpbuf);
|
||||
ti[0] = MkAtomTerm(AtomEncoding);
|
||||
ti[1] = where;
|
||||
nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti);
|
||||
tp = tmpbuf+i;
|
||||
psize -= i;
|
||||
fun = FunctorError;
|
||||
serious = TRUE;
|
||||
}
|
||||
break;
|
||||
case DOMAIN_ERROR_STREAM_POSITION:
|
||||
{
|
||||
int i;
|
||||
|
507
C/gprof.c
507
C/gprof.c
@ -126,7 +126,6 @@ typedef greg_t context_reg;
|
||||
static Int ProfCalls, ProfGCs, ProfHGrows, ProfSGrows, ProfMallocs, ProfOn, ProfOns;
|
||||
|
||||
#define TIMER_DEFAULT 100
|
||||
#define MORE_INFO_FILE 1
|
||||
#define PROFILING_FILE 1
|
||||
#define PROFPREDS_FILE 2
|
||||
|
||||
@ -148,13 +147,13 @@ static rb_red_blk_node *ProfilerRoot, *ProfilerNil;
|
||||
static rb_red_blk_node *
|
||||
RBMalloc(UInt size)
|
||||
{
|
||||
return (rb_red_blk_node *)Yap_AllocCodeSpace(size);
|
||||
return (rb_red_blk_node *)malloc(size);
|
||||
}
|
||||
|
||||
static void
|
||||
RBfree(rb_red_blk_node *ptr)
|
||||
{
|
||||
Yap_FreeCodeSpace((char *)ptr);
|
||||
free((char *)ptr);
|
||||
}
|
||||
|
||||
static rb_red_blk_node *
|
||||
@ -712,19 +711,10 @@ static Int order=0;
|
||||
ProfOn = TRUE;
|
||||
if (FPreds != NULL) {
|
||||
Int temp;
|
||||
|
||||
order++;
|
||||
if (index_code) temp=-order; else temp=order;
|
||||
fprintf(FPreds,"+%p %p %p %ld",code_start,code_end, pe, (long int)temp);
|
||||
#if MORE_INFO_FILE
|
||||
if (pe->FunctorOfPred->KindOfPE==47872) {
|
||||
if (pe->ArityOfPE) {
|
||||
fprintf(FPreds," %s/%d", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE);
|
||||
} else {
|
||||
fprintf(FPreds," %s",RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
fprintf(FPreds,"\n");
|
||||
fprintf(FPreds,"+%p %p %p %ld\n",code_start,code_end, pe, (long int)temp);
|
||||
}
|
||||
ProfOn = FALSE;
|
||||
}
|
||||
@ -737,228 +727,189 @@ typedef struct clause_entry {
|
||||
int ts; /* start end timestamp towards retracts, eventually */
|
||||
} clauseentry;
|
||||
|
||||
static int
|
||||
cl_cmp(const void *c1, const void *c2)
|
||||
{
|
||||
const clauseentry *cl1 = (const clauseentry *)c1;
|
||||
const clauseentry *cl2 = (const clauseentry *)c2;
|
||||
if (cl1->beg > cl2->beg) return 1;
|
||||
if (cl1->beg < cl2->beg) return -1;
|
||||
return 0;
|
||||
static Int profend(void);
|
||||
|
||||
static void
|
||||
clean_tree(rb_red_blk_node* node) {
|
||||
if (node == ProfilerNil)
|
||||
return;
|
||||
clean_tree(node->left);
|
||||
clean_tree(node->right);
|
||||
Yap_FreeCodeSpace((char *)node);
|
||||
}
|
||||
|
||||
static void
|
||||
reset_tree(void) {
|
||||
clean_tree(ProfilerRoot);
|
||||
Yap_FreeCodeSpace((char *)ProfilerNil);
|
||||
ProfilerNil = ProfilerRoot = NULL;
|
||||
ProfCalls = ProfGCs = ProfHGrows = ProfSGrows = ProfMallocs = ProfOns = 0L;
|
||||
}
|
||||
|
||||
static int
|
||||
p_cmp(const void *c1, const void *c2)
|
||||
InitProfTree(void)
|
||||
{
|
||||
const clauseentry *cl1 = (const clauseentry *)c1;
|
||||
const clauseentry *cl2 = (const clauseentry *)c2;
|
||||
if (cl1->pp > cl2->pp) return 1;
|
||||
if (cl1->pp < cl2->pp) return -1;
|
||||
|
||||
/* else same pp, but they are always different on the ts */
|
||||
if (cl1->ts > cl2->ts) return 1;
|
||||
else return -1;
|
||||
if (ProfilerRoot)
|
||||
reset_tree();
|
||||
while (!(ProfilerRoot = RBTreeCreate())) {
|
||||
if (!Yap_growheap(FALSE, 0, NULL)) {
|
||||
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "while initialisating profiler");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static clauseentry *
|
||||
search_pc_pred(yamop *pc_ptr,clauseentry *beg, clauseentry *end) {
|
||||
Int i, j, f, l;
|
||||
f = 0; l = (end-beg);
|
||||
i = l/2;
|
||||
while (TRUE) {
|
||||
if (beg[i].beg > pc_ptr) {
|
||||
l = i-1;
|
||||
if (l < f) {
|
||||
return NULL;
|
||||
}
|
||||
j = i;
|
||||
i = (f+l)/2;
|
||||
} else if (beg[i].end < pc_ptr) {
|
||||
f = i+1;
|
||||
if (f > l) {
|
||||
return NULL;
|
||||
}
|
||||
i = (f+l)/2;
|
||||
} else if (beg[i].beg <= pc_ptr && beg[i].end >= pc_ptr) {
|
||||
return (&beg[i]);
|
||||
} else {
|
||||
return NULL;
|
||||
static void LookupNode(yamop *current_p) {
|
||||
rb_red_blk_node *node;
|
||||
|
||||
if ((node = RBLookup(current_p))) {
|
||||
node->pcs++;
|
||||
return;
|
||||
} else {
|
||||
PredEntry *pp = NULL;
|
||||
CODEADDR start, end;
|
||||
|
||||
pp = Yap_PredEntryForCode(current_p, FIND_PRED_FROM_ANYWHERE, &start, &end);
|
||||
if (!pp) {
|
||||
#if DEBUG
|
||||
fprintf(stderr,"lost %p, %d\n", P, Yap_op_from_opcode(P->opc));
|
||||
#endif
|
||||
/* lost profiler event !! */
|
||||
return;
|
||||
}
|
||||
#if !USE_SYSTEM_MALLOC
|
||||
/* add this clause as new node to the tree */
|
||||
if (start < (CODEADDR)Yap_HeapBase || start > (CODEADDR)HeapTop ||
|
||||
end < (CODEADDR)Yap_HeapBase || end > (CODEADDR)HeapTop) {
|
||||
#if DEBUG
|
||||
fprintf(stderr,"Oops2: %p->%lu %p, %p\n", current_p, (unsigned long int)(current_p->opc), start, end);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (pp->ArityOfPE > 100) {
|
||||
#if DEBUG
|
||||
fprintf(stderr,"%p(%lu)-->%p\n",current_p,(unsigned long int)Yap_op_from_opcode(current_p->opc),pp);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
node = RBTreeInsert((yamop *)start, (yamop *)end);
|
||||
node->pe = pp;
|
||||
node->pcs = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static Int profend(void);
|
||||
static void RemoveCode(CODEADDR clau)
|
||||
{
|
||||
rb_red_blk_node* x, *node;
|
||||
PredEntry *pp;
|
||||
UInt count;
|
||||
|
||||
if (!ProfilerRoot) return;
|
||||
if (!(x = RBExactQuery((yamop *)clau))) {
|
||||
/* send message */
|
||||
ProfOn = FALSE;
|
||||
return;
|
||||
}
|
||||
pp = x->pe;
|
||||
count = x->pcs;
|
||||
RBDelete(x);
|
||||
/* use a single node to represent all deleted clauses */
|
||||
if (!(node = RBExactQuery((yamop *)(pp->OpcodeOfPred)))) {
|
||||
node = RBTreeInsert((yamop *)(pp->OpcodeOfPred), NEXTOP((yamop *)(pp->OpcodeOfPred),e));
|
||||
node->lim = (yamop *)pp;
|
||||
node->pe = pp;
|
||||
node->pcs = count;
|
||||
/* send message */
|
||||
ProfOn = FALSE;
|
||||
return;
|
||||
} else {
|
||||
node->pcs += count;
|
||||
}
|
||||
}
|
||||
|
||||
#define MAX_LINE_SIZE 1024
|
||||
|
||||
static int
|
||||
showprofres(UInt type) {
|
||||
clauseentry *pr, *t, *t2;
|
||||
PredEntry *mype;
|
||||
UInt count=0, ProfCalls=0, InGrowHeap=0, InGrowStack=0, InGC=0, InError=0, InUnify=0, InCCall=0;
|
||||
yamop *pc_ptr,*y; void *oldpc;
|
||||
showprofres(void) {
|
||||
char line[MAX_LINE_SIZE];
|
||||
yamop *pr_beg, *pr_end;
|
||||
PredEntry *pr_pp;
|
||||
long int pr_count;
|
||||
|
||||
|
||||
profend(); /* Make sure profiler has ended */
|
||||
|
||||
/* First part: Read information about predicates and store it on yap trail */
|
||||
|
||||
FPreds=fopen(profile_names(PROFPREDS_FILE),"r");
|
||||
|
||||
if (FPreds == NULL) { printf("Sorry, profiler couldn't find PROFPREDS file. \n"); return FALSE; }
|
||||
|
||||
ProfPreds=0;
|
||||
pr=(clauseentry *) TR;
|
||||
while (fscanf(FPreds,"+%p %p %p %d",&(pr->beg),&(pr->end),&(pr->pp),&(pr->ts)) > 0){
|
||||
int c;
|
||||
pr->pcs = 0L;
|
||||
pr++;
|
||||
if (pr > (clauseentry *)Yap_TrailTop - 1024) {
|
||||
Yap_growtrail(K64, FALSE);
|
||||
}
|
||||
ProfPreds++;
|
||||
|
||||
do {
|
||||
c=fgetc(FPreds);
|
||||
} while(c!=EOF && c!='\n');
|
||||
}
|
||||
fclose(FPreds);
|
||||
if (ProfPreds==0) return(TRUE);
|
||||
|
||||
qsort((void *)TR, ProfPreds, sizeof(clauseentry), cl_cmp);
|
||||
|
||||
/* Second part: Read Profiling to know how many times each predicate has been profiled */
|
||||
|
||||
InitProfTree();
|
||||
FProf=fopen(profile_names(PROFILING_FILE),"r");
|
||||
if (FProf==NULL) { printf("Sorry, profiler couldn't find PROFILING file. \n"); return FALSE; }
|
||||
if (FProf==NULL) { fclose(FProf); return FALSE; }
|
||||
while (fgets(line, MAX_LINE_SIZE, FProf) != NULL) {
|
||||
if (line[0] == '+') {
|
||||
rb_red_blk_node *node;
|
||||
sscanf(line+1,"%p %p %p %ld",&pr_beg,&pr_end,&pr_pp,&pr_count);
|
||||
node = RBTreeInsert(pr_beg, pr_end);
|
||||
node->pe = pr_pp;
|
||||
node->pcs = 0;
|
||||
} else if (line[0] == '-') {
|
||||
sscanf(line+1,"%p",&pr_beg);
|
||||
RemoveCode((CODEADDR)pr_beg);
|
||||
} else {
|
||||
rb_red_blk_node *node;
|
||||
|
||||
t2=NULL;
|
||||
ProfCalls=0;
|
||||
while(fscanf(FProf,"%p %p %p\n",&oldpc, &pc_ptr,&mype) >0){
|
||||
if (type<10) ProfCalls++;
|
||||
|
||||
if (oldpc!=0 && type<=2) {
|
||||
if ((unsigned long)oldpc< 70000) {
|
||||
if ((unsigned long) oldpc & GrowHeapMode) { InGrowHeap++; continue; }
|
||||
if ((unsigned long)oldpc & GrowStackMode) { InGrowStack++; continue; }
|
||||
if ((unsigned long)oldpc & GCMode) { InGC++; continue; }
|
||||
if ((unsigned long)oldpc & (ErrorHandlingMode | InErrorMode)) { InError++; continue; }
|
||||
sscanf(line,"%p",&pr_beg);
|
||||
node = RBLookup(pr_beg);
|
||||
if (!node) {
|
||||
#if DEBUG
|
||||
fprintf(stderr,"Oops: %p\n", pr_beg);
|
||||
#endif
|
||||
} else {
|
||||
node->pcs++;
|
||||
}
|
||||
if (oldpc>(void *) Yap_rational_tree_loop && oldpc<(void *) Yap_InitAbsmi) { InUnify++; continue; }
|
||||
y=(yamop *) ((long) pc_ptr-20);
|
||||
if (y->opc==Yap_opcode(_call_cpred) || y->opc==Yap_opcode(_call_usercpred)) {
|
||||
InCCall++; /* I Was in a C Call */
|
||||
pc_ptr=y;
|
||||
/*
|
||||
printf("Aqui está um call_cpred(%p) \n",y->u.Osbpp.p->cs.f_code);
|
||||
for(i=0;i<_std_top && pc_ptr->opc!=Yap_ABSMI_OPCODES[i];i++);
|
||||
printf("Outro syscall diferente %s\n", Yap_op_names[i]);
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
/* I should never get here, but since I'm, it is certanly Unknown Code, so
|
||||
continue running to try to count it as Prolog Code */
|
||||
}
|
||||
|
||||
t=search_pc_pred(pc_ptr,(clauseentry *)TR,pr);
|
||||
if (t!=NULL) { /* pc was found */
|
||||
if (type<10) t->pcs++;
|
||||
else {
|
||||
if (t->pp==(PredEntry *)type) {
|
||||
ProfCalls++;
|
||||
if (t2!=NULL) t2->pcs++;
|
||||
}
|
||||
}
|
||||
t2=t;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fclose(FProf);
|
||||
if (ProfCalls==0) return(TRUE);
|
||||
if (ProfCalls==0)
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*I have the counting by clauses, but we also need them by predicate */
|
||||
qsort((void *)TR, ProfPreds, sizeof(clauseentry), p_cmp);
|
||||
t = (clauseentry *)TR;
|
||||
while (t < pr) {
|
||||
UInt calls=t->pcs;
|
||||
static Int
|
||||
p_test(void) {
|
||||
char line[MAX_LINE_SIZE];
|
||||
yamop *pr_beg, *pr_end;
|
||||
PredEntry *pr_pp;
|
||||
long int pr_count;
|
||||
|
||||
t2=t+1;
|
||||
while(t2<pr && t2->pp==t->pp) {
|
||||
calls+=t2->pcs;
|
||||
t2++;
|
||||
}
|
||||
while(t<t2) {
|
||||
t->pca=calls;
|
||||
t++;
|
||||
}
|
||||
}
|
||||
|
||||
/* counting done: now it is time to present the results */
|
||||
fflush(stdout);
|
||||
profend(); /* Make sure profiler has ended */
|
||||
|
||||
/*
|
||||
if (type>10) {
|
||||
PredEntry *myp = (PredEntry *)type;
|
||||
if (myp->FunctorOfPred->KindOfPE==47872) {
|
||||
printf("Details on predicate:");
|
||||
printf(" %s",RepAtom(AtomOfTerm(myp->ModuleOfPred))->StrOfAE);
|
||||
printf(":%s",RepAtom(NameOfFunctor(myp->FunctorOfPred))->StrOfAE);
|
||||
if (myp->ArityOfPE) printf("/%d\n",myp->ArityOfPE);
|
||||
}
|
||||
type=1;
|
||||
}
|
||||
*/
|
||||
/* First part: Read information about predicates and store it on yap trail */
|
||||
|
||||
if (type==0 || type==1 || type==3) { /* Results by predicate */
|
||||
t = (clauseentry *)TR;
|
||||
while (t < pr) {
|
||||
UInt calls=t->pca;
|
||||
PredEntry *myp = t->pp;
|
||||
|
||||
if (calls && myp->FunctorOfPred->KindOfPE==47872) {
|
||||
count+=calls;
|
||||
printf("%p",myp);
|
||||
if (myp->ModuleOfPred) printf(" %s",RepAtom(AtomOfTerm(myp->ModuleOfPred))->StrOfAE);
|
||||
printf(":%s",RepAtom(NameOfFunctor(myp->FunctorOfPred))->StrOfAE);
|
||||
if (myp->ArityOfPE) printf("/%d",myp->ArityOfPE);
|
||||
printf(" -> %lu (%3.1f%c)\n",(unsigned long int)calls,(float) calls*100/ProfCalls,'%');
|
||||
}
|
||||
while (t<pr && t->pp == myp) t++;
|
||||
}
|
||||
} else { /* Results by clauses */
|
||||
t = (clauseentry *)TR;
|
||||
while (t < pr) {
|
||||
if (t->pca!=0 && (t->ts>=0 || t->pcs!=0) && t->pp->FunctorOfPred->KindOfPE==47872) {
|
||||
UInt calls=t->pcs;
|
||||
if (t->ts<0) { /* join all index entries */
|
||||
t2=t+1;
|
||||
while(t2<pr && t2->pp==t->pp && t2->ts<0) {
|
||||
t++;
|
||||
calls+=t->pcs;
|
||||
t2++;
|
||||
}
|
||||
printf("IDX");
|
||||
} else {
|
||||
printf(" ");
|
||||
}
|
||||
count+=calls;
|
||||
// printf("%p %p",t->pp, t->beg);
|
||||
if (t->pp->ModuleOfPred) printf(" %s",RepAtom(AtomOfTerm(t->pp->ModuleOfPred))->StrOfAE);
|
||||
printf(":%s",RepAtom(NameOfFunctor(t->pp->FunctorOfPred))->StrOfAE);
|
||||
if (t->pp->ArityOfPE) printf("/%d",t->pp->ArityOfPE);
|
||||
printf(" -> %lu (%3.1f%c)\n",(unsigned long int)calls,(float) calls*100/ProfCalls,'%');
|
||||
}
|
||||
t++;
|
||||
InitProfTree();
|
||||
FProf=fopen("PROFILING_93920","r");
|
||||
if (FProf==NULL) { fclose(FProf); return FALSE; }
|
||||
while (fgets(line, MAX_LINE_SIZE, FProf) != NULL) {
|
||||
if (line[0] == '+') {
|
||||
rb_red_blk_node *node;
|
||||
sscanf(line+1,"%p %p %p %ld",&pr_beg,&pr_end,&pr_pp,&pr_count);
|
||||
node = RBTreeInsert(pr_beg, pr_end);
|
||||
node->pe = pr_pp;
|
||||
node->pcs = 0;
|
||||
} else if (line[0] == '-') {
|
||||
sscanf(line+1,"%p",&pr_beg);
|
||||
RemoveCode((CODEADDR)pr_beg);
|
||||
} else {
|
||||
rb_red_blk_node *node = RBTreeInsert(pr_beg, pr_end);
|
||||
node->pe = pr_pp;
|
||||
node->pcs = 1;
|
||||
}
|
||||
}
|
||||
count=ProfCalls-(count+InGrowHeap+InGrowStack+InGC+InError+InUnify+InCCall); // Falta +InCCall
|
||||
if (InGrowHeap>0) printf("%p sys: GrowHeap -> %lu (%3.1f%c)\n",(void *) GrowHeapMode,(unsigned long int)InGrowHeap,(float) InGrowHeap*100/ProfCalls,'%');
|
||||
if (InGrowStack>0) printf("%p sys: GrowStack -> %lu (%3.1f%c)\n",(void *) GrowStackMode,(unsigned long int)InGrowStack,(float) InGrowStack*100/ProfCalls,'%');
|
||||
if (InGC>0) printf("%p sys: GC -> %lu (%3.1f%c)\n",(void *) GCMode,(unsigned long int)InGC,(float) InGC*100/ProfCalls,'%');
|
||||
if (InError>0) printf("%p sys: ErrorHandling -> %lu (%3.1f%c)\n",(void *) ErrorHandlingMode,(unsigned long int)InError,(float) InError*100/ProfCalls,'%');
|
||||
if (InUnify>0) printf("%p sys: Unify -> %lu (%3.1f%c)\n",(void *) UnifyMode,(unsigned long int)InUnify,(float) InUnify*100/ProfCalls,'%');
|
||||
if (InCCall>0) printf("%p sys: C Code -> %lu (%3.1f%c)\n",(void *) CCallMode,(unsigned long int)InCCall,(float) InCCall*100/ProfCalls,'%');
|
||||
if (count>0) printf("Unknown:Unknown -> %lu (%3.1f%c)\n",(unsigned long int)count,(float) count*100/ProfCalls,'%');
|
||||
printf("Total of Calls=%lu \n",(unsigned long int)ProfCalls);
|
||||
|
||||
fclose(FProf);
|
||||
if (ProfCalls==0)
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -970,17 +921,16 @@ static void
|
||||
prof_alrm(int signo, siginfo_t *si, void *scv)
|
||||
{
|
||||
void * oldpc=(void *) CONTEXT_PC(scv);
|
||||
rb_red_blk_node *node = NULL;
|
||||
yamop *current_p;
|
||||
|
||||
ProfCalls++;
|
||||
/* skip an interrupt */
|
||||
if (ProfOn) {
|
||||
ProfOns++;
|
||||
return;
|
||||
}
|
||||
ProfOn = TRUE;
|
||||
if (Yap_PrologMode & TestMode) {
|
||||
if (Yap_OffLineProfiler) {
|
||||
fprintf(FProf,"%p %p\n", (void *) ((CELL)Yap_PrologMode & TestMode), P);
|
||||
ProfOn = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Yap_PrologMode & GCMode) {
|
||||
ProfGCs++;
|
||||
ProfOn = FALSE;
|
||||
@ -1034,60 +984,18 @@ prof_alrm(int signo, siginfo_t *si, void *scv)
|
||||
#if DEBUG
|
||||
fprintf(stderr,"Oops: %p, %p\n", oldpc, current_p);
|
||||
#endif
|
||||
ProfOn = FALSE;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Yap_OffLineProfiler) {
|
||||
fprintf(FProf,"%p %p ", oldpc, current_p);
|
||||
ProfOn = FALSE;
|
||||
// return;
|
||||
}
|
||||
|
||||
if (ProfOn) {
|
||||
ProfOns++;
|
||||
return;
|
||||
}
|
||||
ProfOn = TRUE;
|
||||
if ((node = RBLookup((yamop *)current_p))) {
|
||||
node->pcs++;
|
||||
if (Yap_OffLineProfiler) fprintf(FProf,"%p\n", node->pe);
|
||||
fprintf(FProf,"%p\n", current_p);
|
||||
ProfOn = FALSE;
|
||||
return;
|
||||
} else {
|
||||
PredEntry *pp = NULL;
|
||||
CODEADDR start, end;
|
||||
|
||||
pp = Yap_PredEntryForCode(current_p, FIND_PRED_FROM_ANYWHERE, &start, &end);
|
||||
if (Yap_OffLineProfiler) fprintf(FProf,"%p\n", pp);
|
||||
if (!pp) {
|
||||
#if DEBUG
|
||||
fprintf(stderr,"lost %p, %d\n", P, Yap_op_from_opcode(P->opc));
|
||||
#endif
|
||||
/* lost profiler event !! */
|
||||
ProfOn=FALSE;
|
||||
return;
|
||||
}
|
||||
#if !USE_SYSTEM_MALLOC
|
||||
/* add this clause as new node to the tree */
|
||||
if (start < (CODEADDR)Yap_HeapBase || start > (CODEADDR)HeapTop ||
|
||||
end < (CODEADDR)Yap_HeapBase || end > (CODEADDR)HeapTop) {
|
||||
#if DEBUG
|
||||
fprintf(stderr,"Oops2: %p->%lu %p, %p\n", current_p, (unsigned long int)(current_p->opc), start, end);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (pp->ArityOfPE > 100) {
|
||||
#if DEBUG
|
||||
fprintf(stderr,"%p:%p(%lu)-->%p\n",oldpc,current_p,(unsigned long int)Yap_op_from_opcode(current_p->opc),pp);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
node = RBTreeInsert((yamop *)start, (yamop *)end);
|
||||
node->pe = pp;
|
||||
node->pcs = 1;
|
||||
}
|
||||
|
||||
LookupNode(current_p);
|
||||
ProfOn = FALSE;
|
||||
}
|
||||
|
||||
@ -1095,59 +1003,17 @@ prof_alrm(int signo, siginfo_t *si, void *scv)
|
||||
void
|
||||
Yap_InformOfRemoval(CODEADDR clau)
|
||||
{
|
||||
rb_red_blk_node* x, *node;
|
||||
UInt count;
|
||||
PredEntry *pp;
|
||||
|
||||
if (FPreds != NULL) {
|
||||
/* ricardo? */
|
||||
/* do something */
|
||||
return;
|
||||
}
|
||||
if (!ProfilerRoot) return;
|
||||
ProfOn = TRUE;
|
||||
if (!(x = RBExactQuery((yamop *)clau))) {
|
||||
/* send message */
|
||||
if (FPreds != NULL) {
|
||||
/* just store info about what is going on */
|
||||
fprintf(FPreds,"-%p\n",clau);
|
||||
ProfOn = FALSE;
|
||||
return;
|
||||
}
|
||||
/* just keep within the other profiler for now */
|
||||
pp = x->pe;
|
||||
count = x->pcs;
|
||||
/* fprintf(stderr,"D %p:%p\n",x,pp); */
|
||||
RBDelete(x);
|
||||
/* use a single node to represent all deleted clauses */
|
||||
if (!(node = RBExactQuery((yamop *)(pp->OpcodeOfPred)))) {
|
||||
node = RBTreeInsert((yamop *)(pp->OpcodeOfPred), NEXTOP((yamop *)(pp->OpcodeOfPred),e));
|
||||
node->lim = (yamop *)pp;
|
||||
node->pe = pp;
|
||||
node->pcs = count;
|
||||
/* send message */
|
||||
ProfOn = FALSE;
|
||||
return;
|
||||
} else {
|
||||
node->pcs += count;
|
||||
}
|
||||
RemoveCode(clau);
|
||||
ProfOn = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
clean_tree(rb_red_blk_node* node) {
|
||||
if (node == ProfilerNil)
|
||||
return;
|
||||
clean_tree(node->left);
|
||||
clean_tree(node->right);
|
||||
Yap_FreeCodeSpace((char *)node);
|
||||
}
|
||||
|
||||
static void
|
||||
reset_tree(void) {
|
||||
clean_tree(ProfilerRoot);
|
||||
Yap_FreeCodeSpace((char *)ProfilerNil);
|
||||
ProfilerNil = ProfilerRoot = NULL;
|
||||
ProfCalls = ProfGCs = ProfHGrows = ProfSGrows = ProfMallocs = ProfOns = 0L;
|
||||
}
|
||||
|
||||
static Int profend(void);
|
||||
|
||||
static Int
|
||||
@ -1201,21 +1067,15 @@ static Int
|
||||
do_profinit(void)
|
||||
{
|
||||
if (Yap_OffLineProfiler) {
|
||||
FPreds=fopen(profile_names(PROFPREDS_FILE),"w+");
|
||||
if (FPreds == NULL) return FALSE;
|
||||
// FPreds=fopen(profile_names(PROFPREDS_FILE),"w+");
|
||||
// if (FPreds == NULL) return FALSE;
|
||||
FProf=fopen(profile_names(PROFILING_FILE),"w+");
|
||||
if (FProf==NULL) { fclose(FPreds); return FALSE; }
|
||||
if (FProf==NULL) { fclose(FProf); return FALSE; }
|
||||
FPreds = FProf;
|
||||
|
||||
Yap_dump_code_area_for_profiler();
|
||||
} else {
|
||||
if (ProfilerRoot)
|
||||
reset_tree();
|
||||
while (!(ProfilerRoot = RBTreeCreate())) {
|
||||
if (!Yap_growheap(FALSE, 0, NULL)) {
|
||||
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "while initialisating profiler");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
InitProfTree();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -1330,7 +1190,9 @@ static Int profend(void)
|
||||
if (ProfilerOn==0) return(FALSE);
|
||||
profoff(); /* Make sure profiler is off */
|
||||
ProfilerOn=0;
|
||||
|
||||
if (Yap_OffLineProfiler) {
|
||||
fclose(FProf);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1370,15 +1232,8 @@ static Int getpredinfo(void)
|
||||
Yap_unify(ARG4, MkIntegerTerm(arity));
|
||||
}
|
||||
|
||||
static Int profres(void) {
|
||||
Term p;
|
||||
p=Deref(ARG1);
|
||||
if (IsLongIntTerm(p)) return(showprofres(LongIntOfTerm(p)));
|
||||
else return(showprofres(IntOfTerm(p)));
|
||||
}
|
||||
|
||||
static Int profres0(void) {
|
||||
return(showprofres(0));
|
||||
return(showprofres());
|
||||
}
|
||||
|
||||
#endif /* LOW_PROF */
|
||||
@ -1399,11 +1254,11 @@ Yap_InitLowProf(void)
|
||||
Yap_InitCPred("profoff", 0, profoff, SafePredFlag);
|
||||
Yap_InitCPred("profalt", 0, profalt, SafePredFlag);
|
||||
Yap_InitCPred("$offline_showprofres", 0, profres0, SafePredFlag);
|
||||
Yap_InitCPred("$offline_showprofres", 1, profres, SafePredFlag);
|
||||
Yap_InitCPred("$profnode", 6, profnode, SafePredFlag);
|
||||
Yap_InitCPred("$profglobs", 6, profglobs, SafePredFlag);
|
||||
Yap_InitCPred("$profison",0 , profison, SafePredFlag);
|
||||
Yap_InitCPred("$get_pred_pinfo", 4, getpredinfo, SafePredFlag);
|
||||
Yap_InitCPred("showprofres", 4, getpredinfo, SafePredFlag);
|
||||
Yap_InitCPred("prof_test", 0, p_test, 0);
|
||||
#endif
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ gc_growtrail(int committed, tr_fr_ptr begsTR, cont *old_cont_top0)
|
||||
#endif
|
||||
/* could not find more trail */
|
||||
save_machine_regs();
|
||||
longjmp(Yap_gc_restore, 2);
|
||||
_longjmp(Yap_gc_restore, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -425,7 +425,7 @@ check_pr_trail(tr_fr_ptr trp)
|
||||
if (!Yap_growtrail(0, TRUE) || TRUE) {
|
||||
/* could not find more trail */
|
||||
save_machine_regs();
|
||||
longjmp(Yap_gc_restore, 2);
|
||||
_longjmp(Yap_gc_restore, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3782,7 +3782,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||
}
|
||||
#endif
|
||||
time_start = Yap_cputime();
|
||||
if (setjmp(Yap_gc_restore) == 2) {
|
||||
if (_setjmp(Yap_gc_restore) == 2) {
|
||||
UInt sz;
|
||||
|
||||
/* we cannot recover, fail system */
|
||||
|
52
C/index.c
52
C/index.c
@ -188,7 +188,7 @@
|
||||
* Revision 1.150 2005/12/23 00:20:13 vsc
|
||||
* updates to gprof
|
||||
* support for __POWER__
|
||||
* Try to saveregs before longjmp.
|
||||
* Try to saveregs before _longjmp.
|
||||
*
|
||||
* Revision 1.149 2005/12/17 03:25:39 vsc
|
||||
* major changes to support online event-based profiling
|
||||
@ -832,14 +832,14 @@ sort_group(GroupDef *grp, CELL *top, struct intermediates *cint)
|
||||
if (!(base = (CELL *)Yap_AllocCodeSpace(2*max*sizeof(CELL)))) {
|
||||
save_machine_regs();
|
||||
Yap_Error_Size = 2*max*sizeof(CELL);
|
||||
longjmp(cint->CompilerBotch,2);
|
||||
_longjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
#else
|
||||
base = top;
|
||||
while (top+2*max > (CELL *)Yap_TrailTop) {
|
||||
if (!Yap_growtrail(2*max*CellSize, TRUE)) {
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,4);
|
||||
_longjmp(cint->CompilerBotch,4);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2046,11 +2046,11 @@ groups_in(ClauseDef *min, ClauseDef *max, GroupDef *grp, struct intermediates *c
|
||||
Yap_Error_Size = sz;
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,4);
|
||||
_longjmp(cint->CompilerBotch,4);
|
||||
#else
|
||||
if (!Yap_growtrail(sz, TRUE)) {
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,4);
|
||||
_longjmp(cint->CompilerBotch,4);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@ -2179,7 +2179,7 @@ emit_switch_space(UInt n, UInt item_size, struct intermediates *cint, CELL func_
|
||||
if (cl == NULL) {
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,2);
|
||||
_longjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
Yap_LUIndexSpace_SW += sz;
|
||||
cl->ClFlags = SwitchTableMask|LogUpdMask|func_mask;
|
||||
@ -2199,7 +2199,7 @@ emit_switch_space(UInt n, UInt item_size, struct intermediates *cint, CELL func_
|
||||
if (cl == NULL) {
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,2);
|
||||
_longjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
Yap_IndexSpace_SW += sz;
|
||||
cl->ClFlags = SwitchTableMask;
|
||||
@ -2518,7 +2518,7 @@ suspend_indexing(ClauseDef *min, ClauseDef *max, PredEntry *ap, struct intermedi
|
||||
sz = (UInt)NEXTOP((yamop *)NULL,sssllp)+tels*sizeof(yamop *);
|
||||
if ((ncode = (yamop *)Yap_AllocCodeSpace(sz)) == NULL) {
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch, 2);
|
||||
_longjmp(cint->CompilerBotch, 2);
|
||||
}
|
||||
#if DEBUG
|
||||
Yap_ExpandClauses++;
|
||||
@ -3130,7 +3130,7 @@ copy_clauses(ClauseDef *max0, ClauseDef *min0, CELL *top, struct intermediates *
|
||||
Yap_Error_Size = sz;
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,4);
|
||||
_longjmp(cint->CompilerBotch,4);
|
||||
}
|
||||
memcpy((void *)top, (void *)min0, sz);
|
||||
return (ClauseDef *)top;
|
||||
@ -3324,7 +3324,7 @@ compile_index(struct intermediates *cint)
|
||||
Yap_Error_Size += NClauses*sizeof(ClauseDef);
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,2);
|
||||
_longjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
}
|
||||
cint->freep = (char *)H;
|
||||
@ -3336,7 +3336,7 @@ compile_index(struct intermediates *cint)
|
||||
Yap_Error_Size += NClauses*sizeof(ClauseDef);
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,3);
|
||||
_longjmp(cint->CompilerBotch,3);
|
||||
}
|
||||
cint->freep = (char *)(cint->cls+NClauses);
|
||||
#endif
|
||||
@ -3381,7 +3381,7 @@ Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc)
|
||||
cint.cls = NULL;
|
||||
Yap_Error_Size = 0;
|
||||
|
||||
if ((setjres = setjmp(cint.CompilerBotch)) == 3) {
|
||||
if ((setjres = _setjmp(cint.CompilerBotch)) == 3) {
|
||||
restore_machine_regs();
|
||||
recover_from_failed_susp_on_cls(&cint, 0);
|
||||
if (!Yap_gcl(Yap_Error_Size, ap->ArityOfPE+NSlots, ENV, next_pc)) {
|
||||
@ -3463,7 +3463,7 @@ push_stack(istack_entry *sp, Int arg, Term Tag, Term extra, struct intermediates
|
||||
{
|
||||
if (sp+1 > (istack_entry *)Yap_TrailTop) {
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,4);
|
||||
_longjmp(cint->CompilerBotch,4);
|
||||
}
|
||||
sp->pos = arg;
|
||||
sp->val = Tag;
|
||||
@ -4349,7 +4349,7 @@ expand_index(struct intermediates *cint) {
|
||||
Yap_Error_Size += NClauses*sizeof(ClauseDef);
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,2);
|
||||
_longjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@ -4359,7 +4359,7 @@ expand_index(struct intermediates *cint) {
|
||||
Yap_Error_Size += 2*NClauses*sizeof(ClauseDef);
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,3);
|
||||
_longjmp(cint->CompilerBotch,3);
|
||||
}
|
||||
#endif
|
||||
if (ap->PredFlags & LogUpdatePredFlag) {
|
||||
@ -4377,7 +4377,7 @@ expand_index(struct intermediates *cint) {
|
||||
Yap_Error_Size += NClauses*sizeof(ClauseDef);
|
||||
/* grow stack */
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,2);
|
||||
_longjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@ -4386,7 +4386,7 @@ expand_index(struct intermediates *cint) {
|
||||
/* tell how much space we need (worst case) */
|
||||
Yap_Error_Size += 2*NClauses*sizeof(ClauseDef);
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,3);
|
||||
_longjmp(cint->CompilerBotch,3);
|
||||
}
|
||||
#endif
|
||||
if (ap->PredFlags & LogUpdatePredFlag) {
|
||||
@ -4485,7 +4485,7 @@ ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop) {
|
||||
cint.cls = NULL;
|
||||
cint.code_addr = NULL;
|
||||
cint.label_offset = NULL;
|
||||
if ((cb = setjmp(cint.CompilerBotch)) == 3) {
|
||||
if ((cb = _setjmp(cint.CompilerBotch)) == 3) {
|
||||
restore_machine_regs();
|
||||
/* grow stack */
|
||||
recover_from_failed_susp_on_cls(&cint, 0);
|
||||
@ -4695,7 +4695,7 @@ push_path(path_stack_entry *sp, yamop **pipc, ClauseDef *clp, struct intermediat
|
||||
{
|
||||
if (sp+1 > (path_stack_entry *)Yap_TrailTop) {
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,4);
|
||||
_longjmp(cint->CompilerBotch,4);
|
||||
}
|
||||
sp->flag = pc_entry;
|
||||
sp->u.pce.pi_pc = pipc;
|
||||
@ -4711,7 +4711,7 @@ fetch_new_block(path_stack_entry *sp, yamop **pipc, PredEntry *ap, struct interm
|
||||
{
|
||||
if (sp+1 > (path_stack_entry *)Yap_TrailTop) {
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,4);
|
||||
_longjmp(cint->CompilerBotch,4);
|
||||
}
|
||||
/* add current position */
|
||||
sp->flag = block_entry;
|
||||
@ -5484,9 +5484,9 @@ add_try(PredEntry *ap, ClauseDef *cls, yamop *next, struct intermediates *cint)
|
||||
LogUpdClause *lcl = ClauseCodeToLogUpdClause(cls->Code);
|
||||
|
||||
if ((newcp = (yamop *)Yap_AllocCodeSpace(size)) == NULL) {
|
||||
/* OOOPS, got in trouble, must do a longjmp and recover space */
|
||||
/* OOOPS, got in trouble, must do a _longjmp and recover space */
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,2);
|
||||
_longjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
Yap_LUIndexSpace_CP += size;
|
||||
#ifdef DEBUG
|
||||
@ -5510,9 +5510,9 @@ add_trust(LogUpdIndex *icl, ClauseDef *cls, struct intermediates *cint)
|
||||
PredEntry *ap = lcl->ClPred;
|
||||
|
||||
if ((newcp = (yamop *)Yap_AllocCodeSpace(size)) == NULL) {
|
||||
/* OOOPS, got in trouble, must do a longjmp and recover space */
|
||||
/* OOOPS, got in trouble, must do a _longjmp and recover space */
|
||||
save_machine_regs();
|
||||
longjmp(cint->CompilerBotch,2);
|
||||
_longjmp(cint->CompilerBotch,2);
|
||||
}
|
||||
Yap_LUIndexSpace_CP += size;
|
||||
#ifdef DEBUG
|
||||
@ -6000,7 +6000,7 @@ Yap_AddClauseToIndex(PredEntry *ap, yamop *beg, int first) {
|
||||
cint.CurrentPred = ap;
|
||||
cint.expand_block = NULL;
|
||||
cint.CodeStart = cint.BlobsStart = cint.cpc = cint.icpc = NIL;
|
||||
if ((cb = setjmp(cint.CompilerBotch)) == 3) {
|
||||
if ((cb = _setjmp(cint.CompilerBotch)) == 3) {
|
||||
restore_machine_regs();
|
||||
Yap_gcl(Yap_Error_Size, ap->ArityOfPE, ENV, CP);
|
||||
save_machine_regs();
|
||||
@ -6476,7 +6476,7 @@ Yap_RemoveClauseFromIndex(PredEntry *ap, yamop *beg) {
|
||||
}
|
||||
cint.expand_block = NULL;
|
||||
cint.CodeStart = cint.BlobsStart = cint.cpc = cint.icpc = NULL;
|
||||
if ((cb = setjmp(cint.CompilerBotch)) == 3) {
|
||||
if ((cb = _setjmp(cint.CompilerBotch)) == 3) {
|
||||
restore_machine_regs();
|
||||
Yap_gcl(Yap_Error_Size, ap->ArityOfPE, ENV, CP);
|
||||
save_machine_regs();
|
||||
|
2
C/init.c
2
C/init.c
@ -416,7 +416,7 @@ static Opdef Ops[] = {
|
||||
{">>", yfx, 400},
|
||||
{"mod", yfx, 400},
|
||||
{"rem", yfx, 400},
|
||||
{"+", fx, 200},
|
||||
{"+", fy, 200},
|
||||
{"-", fy, 200},
|
||||
{"\\", fy, 200},
|
||||
{"//", yfx, 400},
|
||||
|
230
C/iopreds.c
Executable file → Normal file
230
C/iopreds.c
Executable file → Normal file
@ -1736,6 +1736,21 @@ PlUnGetc376 (int sno)
|
||||
return ch;
|
||||
}
|
||||
|
||||
/* give back 0376+ch */
|
||||
static int
|
||||
PlUnGetc00 (int sno)
|
||||
{
|
||||
register StreamDesc *s = &Stream[sno];
|
||||
Int ch;
|
||||
|
||||
if (s->stream_getc != PlUnGetc00)
|
||||
return(s->stream_getc(sno));
|
||||
s->stream_getc = PlUnGetc;
|
||||
ch = s->och;
|
||||
s->och = 0x00;
|
||||
return ch;
|
||||
}
|
||||
|
||||
/* give back 0377+ch */
|
||||
static int
|
||||
PlUnGetc377 (int sno)
|
||||
@ -1781,6 +1796,66 @@ PlUnGetc357273 (int sno)
|
||||
return ch;
|
||||
}
|
||||
|
||||
/* give back 000+000+ch */
|
||||
static int
|
||||
PlUnGetc0000 (int sno)
|
||||
{
|
||||
register StreamDesc *s = &Stream[sno];
|
||||
Int ch;
|
||||
|
||||
if (s->stream_getc != PlUnGetc0000)
|
||||
return(s->stream_getc(sno));
|
||||
s->stream_getc = PlUnGetc00;
|
||||
ch = s->och;
|
||||
s->och = 0x00;
|
||||
return ch;
|
||||
}
|
||||
|
||||
/* give back 000+000+ch */
|
||||
static int
|
||||
PlUnGetc0000fe (int sno)
|
||||
{
|
||||
register StreamDesc *s = &Stream[sno];
|
||||
Int ch;
|
||||
|
||||
if (s->stream_getc != PlUnGetc0000fe)
|
||||
return(s->stream_getc(sno));
|
||||
s->stream_getc = PlUnGetc0000;
|
||||
ch = s->och;
|
||||
s->och = 0xfe;
|
||||
return ch;
|
||||
}
|
||||
|
||||
/* give back 0377+0376+ch */
|
||||
static int
|
||||
PlUnGetc377376 (int sno)
|
||||
{
|
||||
register StreamDesc *s = &Stream[sno];
|
||||
Int ch;
|
||||
|
||||
if (s->stream_getc != PlUnGetc377376)
|
||||
return(s->stream_getc(sno));
|
||||
s->stream_getc = PlUnGetc377;
|
||||
ch = s->och;
|
||||
s->och = 0xFE;
|
||||
return ch;
|
||||
}
|
||||
|
||||
/* give back 0377+0376+000+ch */
|
||||
static int
|
||||
PlUnGetc37737600 (int sno)
|
||||
{
|
||||
register StreamDesc *s = &Stream[sno];
|
||||
Int ch;
|
||||
|
||||
if (s->stream_getc != PlUnGetc37737600)
|
||||
return(s->stream_getc(sno));
|
||||
s->stream_getc = PlUnGetc377376;
|
||||
ch = s->och;
|
||||
s->och = 0x00;
|
||||
return ch;
|
||||
}
|
||||
|
||||
static int
|
||||
utf8_nof(char ch)
|
||||
{
|
||||
@ -1886,6 +1961,26 @@ get_wchar(int sno)
|
||||
how_many=1;
|
||||
wch = ch;
|
||||
break;
|
||||
case ENC_ISO_UTF32_LE:
|
||||
if (!how_many) {
|
||||
how_many = 4;
|
||||
wch = 0;
|
||||
}
|
||||
how_many--;
|
||||
wch += ((unsigned char) (ch & 0xff)) << (how_many*8);
|
||||
if (how_many == 0)
|
||||
return wch;
|
||||
break;
|
||||
case ENC_ISO_UTF32_BE:
|
||||
if (!how_many) {
|
||||
how_many = 4;
|
||||
wch = 0;
|
||||
}
|
||||
how_many--;
|
||||
wch += ((unsigned char) (ch & 0xff)) << ((3-how_many)*8);
|
||||
if (how_many == 0)
|
||||
return wch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return EOF;
|
||||
@ -1992,6 +2087,16 @@ put_wchar(int sno, wchar_t ch)
|
||||
case ENC_UNICODE_LE:
|
||||
Stream[sno].stream_putc(sno, (ch&0xff));
|
||||
return Stream[sno].stream_putc(sno, (ch>>8));
|
||||
case ENC_ISO_UTF32_BE:
|
||||
Stream[sno].stream_putc(sno, (ch>>24) & 0xff);
|
||||
Stream[sno].stream_putc(sno, (ch>>16) &0xff);
|
||||
Stream[sno].stream_putc(sno, (ch>>8) & 0xff);
|
||||
return Stream[sno].stream_putc(sno, ch&0xff);
|
||||
case ENC_ISO_UTF32_LE:
|
||||
Stream[sno].stream_putc(sno, ch&0xff);
|
||||
Stream[sno].stream_putc(sno, (ch>>8) & 0xff);
|
||||
Stream[sno].stream_putc(sno, (ch>>16) &0xff);
|
||||
return Stream[sno].stream_putc(sno, (ch>>24) & 0xff);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@ -2219,6 +2324,24 @@ write_bom(int sno, StreamDesc *st)
|
||||
return FALSE;
|
||||
if (st->stream_putc(sno,0xFE)<0)
|
||||
return FALSE;
|
||||
case ENC_ISO_UTF32_BE:
|
||||
if (st->stream_putc(sno,0x00)<0)
|
||||
return FALSE;
|
||||
if (st->stream_putc(sno,0x00)<0)
|
||||
return FALSE;
|
||||
if (st->stream_putc(sno,0xFE)<0)
|
||||
return FALSE;
|
||||
if (st->stream_putc(sno,0xFF)<0)
|
||||
return FALSE;
|
||||
case ENC_ISO_UTF32_LE:
|
||||
if (st->stream_putc(sno,0xFF)<0)
|
||||
return FALSE;
|
||||
if (st->stream_putc(sno,0xFE)<0)
|
||||
return FALSE;
|
||||
if (st->stream_putc(sno,0x00)<0)
|
||||
return FALSE;
|
||||
if (st->stream_putc(sno,0x00)<0)
|
||||
return FALSE;
|
||||
default:
|
||||
return TRUE;
|
||||
}
|
||||
@ -2240,34 +2363,86 @@ check_bom(int sno, StreamDesc *st)
|
||||
return TRUE;
|
||||
}
|
||||
switch(ch) {
|
||||
case 0x00:
|
||||
{
|
||||
ch = st->stream_getc(sno);
|
||||
if (ch == EOFCHAR || ch != 0x00) {
|
||||
st->och = ch;
|
||||
st->stream_getc = PlUnGetc00;
|
||||
st->stream_wgetc = get_wchar;
|
||||
st->stream_gets = DefaultGets;
|
||||
return TRUE;
|
||||
} else {
|
||||
ch = st->stream_getc(sno);
|
||||
if (ch == EOFCHAR || ch != 0xFE) {
|
||||
st->och = ch;
|
||||
st->stream_getc = PlUnGetc0000;
|
||||
st->stream_wgetc = get_wchar;
|
||||
st->stream_gets = DefaultGets;
|
||||
return TRUE;
|
||||
} else {
|
||||
ch = st->stream_getc(sno);
|
||||
if (ch == EOFCHAR || ch != 0xFF) {
|
||||
st->och = ch;
|
||||
st->stream_getc = PlUnGetc0000fe;
|
||||
st->stream_wgetc = get_wchar;
|
||||
st->stream_gets = DefaultGets;
|
||||
return TRUE;
|
||||
} else {
|
||||
st->status |= HAS_BOM_f;
|
||||
st->encoding = ENC_ISO_UTF32_BE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case 0xFE:
|
||||
{
|
||||
ch = st->stream_getc(sno);
|
||||
if (ch != 0xFF) {
|
||||
st->och = ch;
|
||||
st->stream_getc = PlUnGetc376;
|
||||
st->stream_wgetc = get_wchar;
|
||||
st->stream_gets = DefaultGets;
|
||||
return TRUE;
|
||||
st->och = ch;
|
||||
st->stream_getc = PlUnGetc376;
|
||||
st->stream_wgetc = get_wchar;
|
||||
st->stream_gets = DefaultGets;
|
||||
return TRUE;
|
||||
} else {
|
||||
st->status |= HAS_BOM_f;
|
||||
st->encoding = ENC_UNICODE_BE;
|
||||
return TRUE;
|
||||
st->status |= HAS_BOM_f;
|
||||
st->encoding = ENC_UNICODE_BE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
case 0xFF:
|
||||
{
|
||||
ch = st->stream_getc(sno);
|
||||
if (ch != 0xFE) {
|
||||
st->och = ch;
|
||||
st->stream_getc = PlUnGetc377;
|
||||
st->stream_wgetc = get_wchar;
|
||||
st->stream_gets = DefaultGets;
|
||||
return TRUE;
|
||||
st->och = ch;
|
||||
st->stream_getc = PlUnGetc377;
|
||||
st->stream_wgetc = get_wchar;
|
||||
st->stream_gets = DefaultGets;
|
||||
return TRUE;
|
||||
} else {
|
||||
st->status |= HAS_BOM_f;
|
||||
st->encoding = ENC_UNICODE_LE;
|
||||
return TRUE;
|
||||
ch = st->stream_getc(sno);
|
||||
if (ch == EOFCHAR || ch != 0x00) {
|
||||
st->och = ch;
|
||||
st->stream_getc = PlUnGetc377376;
|
||||
st->stream_wgetc = get_wchar;
|
||||
st->stream_gets = DefaultGets;
|
||||
} else {
|
||||
ch = st->stream_getc(sno);
|
||||
if (ch == EOFCHAR || ch != 0x00) {
|
||||
st->och = ch;
|
||||
st->stream_getc = PlUnGetc37737600;
|
||||
st->stream_wgetc = get_wchar;
|
||||
st->stream_gets = DefaultGets;
|
||||
} else {
|
||||
st->status |= HAS_BOM_f;
|
||||
st->encoding = ENC_ISO_UTF32_LE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
st->status |= HAS_BOM_f;
|
||||
st->encoding = ENC_UNICODE_LE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
case 0xEF:
|
||||
@ -2281,15 +2456,15 @@ check_bom(int sno, StreamDesc *st)
|
||||
} else {
|
||||
ch = st->stream_getc(sno);
|
||||
if (ch != 0xBF) {
|
||||
st->och = ch;
|
||||
st->stream_getc = PlUnGetc357273;
|
||||
st->stream_wgetc = get_wchar;
|
||||
st->stream_gets = DefaultGets;
|
||||
return TRUE;
|
||||
st->och = ch;
|
||||
st->stream_getc = PlUnGetc357273;
|
||||
st->stream_wgetc = get_wchar;
|
||||
st->stream_gets = DefaultGets;
|
||||
return TRUE;
|
||||
} else {
|
||||
st->status |= HAS_BOM_f;
|
||||
st->encoding = ENC_ISO_UTF8;
|
||||
return TRUE;
|
||||
st->status |= HAS_BOM_f;
|
||||
st->encoding = ENC_ISO_UTF8;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
default:
|
||||
@ -2628,6 +2803,13 @@ p_open (void)
|
||||
(needs_bom || (st->status & Seekable_Stream_f))) {
|
||||
if (!check_bom(sno, st))
|
||||
return FALSE;
|
||||
if (st->encoding == ENC_ISO_UTF32_BE) {
|
||||
Yap_Error(DOMAIN_ERROR_STREAM_ENCODING, ARG1, "UTF-32 (BE) stream encoding unsupported");
|
||||
return FALSE;
|
||||
} else if (st->encoding == ENC_ISO_UTF32_LE) {
|
||||
Yap_Error(DOMAIN_ERROR_STREAM_ENCODING, ARG1, "UTF-32 (LE) stream encoding unsupported");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
st->status &= ~(Free_Stream_f);
|
||||
return (Yap_unify (ARG3, t));
|
||||
|
10
C/parser.c
10
C/parser.c
@ -81,7 +81,7 @@ STATIC_PROTO(Term ParseTerm, (int, JMPBUFF *));
|
||||
Volatile CELL *saveH=H; \
|
||||
Volatile int savecurprio=curprio; \
|
||||
saveenv=FailBuff; \
|
||||
if(!setjmp(newenv.JmpBuff)) { \
|
||||
if(!_setjmp(newenv.JmpBuff)) { \
|
||||
FailBuff = &newenv; \
|
||||
S; \
|
||||
FailBuff=saveenv; \
|
||||
@ -99,7 +99,7 @@ STATIC_PROTO(Term ParseTerm, (int, JMPBUFF *));
|
||||
Volatile TokEntry *saveT=Yap_tokptr; \
|
||||
Volatile CELL *saveH=H; \
|
||||
saveenv=FailBuff; \
|
||||
if(!setjmp(newenv.JmpBuff)) { \
|
||||
if(!_setjmp(newenv.JmpBuff)) { \
|
||||
FailBuff = &newenv; \
|
||||
S; \
|
||||
FailBuff=saveenv; \
|
||||
@ -113,7 +113,7 @@ STATIC_PROTO(Term ParseTerm, (int, JMPBUFF *));
|
||||
}
|
||||
|
||||
|
||||
#define FAIL longjmp(FailBuff->JmpBuff,1)
|
||||
#define FAIL _longjmp(FailBuff->JmpBuff,1)
|
||||
|
||||
VarEntry *
|
||||
Yap_LookupVar(char *var) /* lookup variable in variables table */
|
||||
@ -181,7 +181,7 @@ VarNames(VarEntry *p,Term l)
|
||||
VarNames(p->VarLeft,l)));
|
||||
if (H > ASP-4096) {
|
||||
save_machine_regs();
|
||||
longjmp(Yap_IOBotch,1);
|
||||
_longjmp(Yap_IOBotch,1);
|
||||
}
|
||||
return(o);
|
||||
} else {
|
||||
@ -710,7 +710,7 @@ Yap_Parse(void)
|
||||
Volatile Term t;
|
||||
JMPBUFF FailBuff;
|
||||
|
||||
if (!setjmp(FailBuff.JmpBuff)) {
|
||||
if (!_setjmp(FailBuff.JmpBuff)) {
|
||||
t = ParseTerm(1200, &FailBuff);
|
||||
if (Yap_tokptr->Tok != Ord(eot_tok))
|
||||
return (0L);
|
||||
|
17
C/stdpreds.c
17
C/stdpreds.c
@ -1937,7 +1937,7 @@ p_number_chars(void)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (IsNonVarTerm(t1) && IsVarTerm(t)) {
|
||||
if (IsNonVarTerm(t1) && !Yap_IsGroundTerm(t)) {
|
||||
Term NewT;
|
||||
if (!IsNumTerm(t1)) {
|
||||
Yap_Error(TYPE_ERROR_NUMBER, t1, "number_chars/2");
|
||||
@ -1973,7 +1973,7 @@ p_number_chars(void)
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsPairTerm(t) && t != TermNil) {
|
||||
Yap_Error(TYPE_ERROR_LIST, t, "number_chars/2");
|
||||
Yap_Error(TYPE_ERROR_LIST, ARG2, "number_chars/2");
|
||||
return(FALSE);
|
||||
}
|
||||
s = String;
|
||||
@ -2031,6 +2031,8 @@ p_number_chars(void)
|
||||
} else if (IsAtomTerm(Head) && !has_ints) {
|
||||
has_atoms = TRUE;
|
||||
is = RepAtom(AtomOfTerm(Head))->StrOfAE;
|
||||
if (is[0] == '\0')
|
||||
goto next_in_loop;
|
||||
if (is[1] != '\0') {
|
||||
Yap_Error(TYPE_ERROR_CHARACTER,Head,"number_chars/2");
|
||||
return FALSE;
|
||||
@ -2057,12 +2059,13 @@ p_number_chars(void)
|
||||
String = nString;
|
||||
}
|
||||
*s++ = ch;
|
||||
next_in_loop:
|
||||
t = TailOfTerm(t);
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_Error(INSTANTIATION_ERROR,t,"number_chars/2");
|
||||
return(FALSE);
|
||||
} else if (!IsPairTerm(t) && t != TermNil) {
|
||||
Yap_Error(TYPE_ERROR_LIST,t,"number_chars/2");
|
||||
Yap_Error(TYPE_ERROR_LIST,ARG2,"number_chars/2");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@ -2131,7 +2134,7 @@ p_number_atom(void)
|
||||
return(FALSE);
|
||||
}
|
||||
if (!IsAtomTerm(t)) {
|
||||
Yap_Error(TYPE_ERROR_LIST, t, "number_atom/2");
|
||||
Yap_Error(TYPE_ERROR_ATOM, t, "number_atom/2");
|
||||
return(FALSE);
|
||||
}
|
||||
s = RepAtom(AtomOfTerm(t))->StrOfAE;
|
||||
@ -2159,7 +2162,7 @@ p_number_codes(void)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (IsNonVarTerm(t1) && IsVarTerm(t)) {
|
||||
if (IsNonVarTerm(t1) && !Yap_IsGroundTerm(t)) {
|
||||
if (IsIntTerm(t1)) {
|
||||
sprintf(String, Int_FORMAT, IntOfTerm(t1));
|
||||
} else if (IsFloatTerm(t1)) {
|
||||
@ -2187,7 +2190,7 @@ p_number_codes(void)
|
||||
Yap_Error(INSTANTIATION_ERROR, t, "number_codes/2");
|
||||
}
|
||||
if (!IsPairTerm(t) && t != TermNil) {
|
||||
Yap_Error(TYPE_ERROR_LIST, t, "number_codes/2");
|
||||
Yap_Error(TYPE_ERROR_LIST, ARG2, "number_codes/2");
|
||||
return(FALSE);
|
||||
}
|
||||
s = String; /* alloc temp space on Trail */
|
||||
@ -2223,7 +2226,7 @@ p_number_codes(void)
|
||||
Yap_Error(INSTANTIATION_ERROR,t,"number_codes/2");
|
||||
return(FALSE);
|
||||
} else if (!IsPairTerm(t) && t != TermNil) {
|
||||
Yap_Error(TYPE_ERROR_LIST, t, "number_codes/2");
|
||||
Yap_Error(TYPE_ERROR_LIST, ARG2, "number_codes/2");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ InitPageSize(void)
|
||||
GetSystemInfo(&si);
|
||||
Yap_page_size = si.dwPageSize;
|
||||
#elif HAVE_UNISTD_H
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
Yap_page_size = getpagesize();
|
||||
#elif defined(_AIX)
|
||||
Yap_page_size = sysconf(_SC_PAGE_SIZE);
|
||||
@ -575,7 +575,7 @@ void Yap_systime_interval(Int *now,Int *interval)
|
||||
#define TicksPerSec CLK_TCK
|
||||
#endif
|
||||
|
||||
#if defined(__alpha) || defined(__FreeBSD__) || defined(__linux__)
|
||||
#if defined(__alpha) || defined(__FreeBSD__) || defined(__linux__) || defined(__DragonFly__)
|
||||
|
||||
#if HAVE_TIME_H
|
||||
#include <time.h>
|
||||
|
10
H/Yap.h
10
H/Yap.h
@ -245,6 +245,11 @@ typedef unsigned long int YAP_ULONG_LONG;
|
||||
#define LOW_PROF 1
|
||||
#endif
|
||||
|
||||
#if !HAVE__SETJMP
|
||||
#define _longjmp(A,B) longjmp(A,B)
|
||||
#define _setjmp(A) setjmp(A)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
extern char Yap_Option[20];
|
||||
#endif
|
||||
@ -257,7 +262,7 @@ extern char Yap_Option[20];
|
||||
#endif
|
||||
|
||||
#if !defined(IN_SECOND_QUADRANT)
|
||||
#if __linux__ || __FreeBSD__ || __NetBSD__ || mips || __APPLE__
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(mips) || defined(__APPLE__) || defined(__DragonFly__)
|
||||
#if defined(YAPOR) && defined(__alpha)
|
||||
|
||||
#define MMAP_ADDR 0x40000000
|
||||
@ -471,6 +476,7 @@ typedef enum
|
||||
DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW,
|
||||
DOMAIN_ERROR_SOURCE_SINK,
|
||||
DOMAIN_ERROR_STREAM,
|
||||
DOMAIN_ERROR_STREAM_ENCODING,
|
||||
DOMAIN_ERROR_STREAM_OR_ALIAS,
|
||||
DOMAIN_ERROR_STREAM_POSITION,
|
||||
DOMAIN_ERROR_TIMEOUT_SPEC,
|
||||
@ -683,7 +689,7 @@ typedef enum
|
||||
if you place things in the lower addresses (power to the libc people).
|
||||
*/
|
||||
|
||||
#if (defined(_AIX) || (defined(__APPLE__) && !defined(__LP64__)) || defined(_WIN32) || defined(sparc) || defined(__sparc) || defined(mips) || defined(__FreeBSD__) || defined(_POWER) || defined(__POWERPC__) || defined(__linux__) || defined(IN_SECOND_QUADRANT) || defined(__CYGWIN__)) || defined(__NetBSD__)
|
||||
#if (defined(_AIX) || (defined(__APPLE__) && !defined(__LP64__)) || defined(_WIN32) || defined(sparc) || defined(__sparc) || defined(mips) || defined(__FreeBSD__) || defined(_POWER) || defined(__POWERPC__) || defined(__linux__) || defined(IN_SECOND_QUADRANT) || defined(__CYGWIN__)) || defined(__NetBSD__) || defined(__DragonFly__)
|
||||
#define USE_LOW32_TAGS 1
|
||||
#endif
|
||||
|
||||
|
@ -84,6 +84,7 @@
|
||||
AtomEOFBeforeEOT = Yap_LookupAtom("end_of_file_found_before_end_of_term");
|
||||
AtomEQ = Yap_LookupAtom("=");
|
||||
AtomEmptyAtom = Yap_LookupAtom("");
|
||||
AtomEncoding = Yap_LookupAtom("encoding");
|
||||
AtomEndOfStream = Yap_LookupAtom("$end_of_stream");
|
||||
AtomEof = Yap_LookupAtom("end_of_file");
|
||||
AtomEq = Yap_LookupAtom("=");
|
||||
|
@ -84,6 +84,7 @@
|
||||
AtomEOFBeforeEOT = AtomAdjust(AtomEOFBeforeEOT);
|
||||
AtomEQ = AtomAdjust(AtomEQ);
|
||||
AtomEmptyAtom = AtomAdjust(AtomEmptyAtom);
|
||||
AtomEncoding = AtomAdjust(AtomEncoding);
|
||||
AtomEndOfStream = AtomAdjust(AtomEndOfStream);
|
||||
AtomEof = AtomAdjust(AtomEof);
|
||||
AtomEq = AtomAdjust(AtomEq);
|
||||
|
@ -391,7 +391,7 @@ RestoreAtoms(void)
|
||||
PtoAtomHashEntryAdjust(Yap_heap_regs->hash_chain);
|
||||
HashPtr = HashChain;
|
||||
for (i = 0; i < AtomHashTableSize; ++i) {
|
||||
HashPtr->Entry = AtomAdjust(HashPtr->Entry);
|
||||
HashPtr->Entry = NoAGCAtomAdjust(HashPtr->Entry);
|
||||
RestoreAtomList(HashPtr->Entry);
|
||||
HashPtr++;
|
||||
}
|
||||
|
16
H/sshift.h
16
H/sshift.h
@ -320,6 +320,14 @@ AtomAdjust (Atom at)
|
||||
return (Atom) ((at));
|
||||
}
|
||||
|
||||
inline EXTERN Atom NoAGCAtomAdjust (Atom);
|
||||
|
||||
inline EXTERN Atom
|
||||
NoAGCAtomAdjust (Atom at)
|
||||
{
|
||||
return (Atom) ((at));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Prop PropAdjust (Prop);
|
||||
@ -341,6 +349,14 @@ AtomAdjust (Atom at)
|
||||
return (Atom) ((at == NULL ? (at) : (Atom) (CharP (at) + HDiff)));
|
||||
}
|
||||
|
||||
inline EXTERN Atom NoAGCAtomAdjust (Atom);
|
||||
|
||||
inline EXTERN Atom
|
||||
NoAGCAtomAdjust (Atom at)
|
||||
{
|
||||
return (Atom) ((at == NULL ? (at) : (Atom) (CharP (at) + HDiff)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline EXTERN Prop PropAdjust (Prop);
|
||||
|
@ -166,6 +166,8 @@
|
||||
#define AtomEQ Yap_heap_regs->AtomEQ_
|
||||
Atom AtomEmptyAtom_;
|
||||
#define AtomEmptyAtom Yap_heap_regs->AtomEmptyAtom_
|
||||
Atom AtomEncoding_;
|
||||
#define AtomEncoding Yap_heap_regs->AtomEncoding_
|
||||
Atom AtomEndOfStream_;
|
||||
#define AtomEndOfStream Yap_heap_regs->AtomEndOfStream_
|
||||
Atom AtomEof_;
|
||||
|
@ -256,7 +256,9 @@ typedef enum {
|
||||
ENC_ISO_ANSI = 4,
|
||||
ENC_ISO_UTF8 = 8,
|
||||
ENC_UNICODE_BE = 16,
|
||||
ENC_UNICODE_LE = 32
|
||||
ENC_UNICODE_LE = 32,
|
||||
ENC_ISO_UTF32_BE = 64,
|
||||
ENC_ISO_UTF32_LE = 128
|
||||
} encoding_t;
|
||||
#endif
|
||||
|
||||
|
@ -30,7 +30,7 @@ INFODIR=$(SHAREDIR)/info
|
||||
#
|
||||
# where to store documentaion files
|
||||
#
|
||||
DOCSDIR=$(SHAREDIR)/docs/Yap
|
||||
DOCSDIR=$(SHAREDIR)/doc/Yap
|
||||
|
||||
#
|
||||
# Add this flag to YAP_EXTRAS if you need the extension:
|
||||
@ -730,6 +730,13 @@ install_docs:
|
||||
$(INSTALL_DATA) yap.html* $(DESTDIR)$(DOCSDIR)
|
||||
$(INSTALL_DATA) yap.pdf $(DESTDIR)$(DOCSDIR)
|
||||
$(INSTALL_DATA) $(srcdir)/README $(DESTDIR)$(DOCSDIR)
|
||||
$(INSTALL_DATA) $(srcdir)/Artistic $(DESTDIR)$(DOCSDIR)
|
||||
$(INSTALL_DATA) $(srcdir)/COPYING $(DESTDIR)$(DOCSDIR)
|
||||
$(INSTALL_DATA) $(srcdir)/changes4.3.html $(DESTDIR)$(DOCSDIR)
|
||||
$(INSTALL_DATA) $(srcdir)/changes-5.0.html $(DESTDIR)$(DOCSDIR)
|
||||
$(INSTALL_DATA) $(srcdir)/changes-5.1.html $(DESTDIR)$(DOCSDIR)
|
||||
$(INSTALL_DATA) $(srcdir)/changes-6.0.html $(DESTDIR)$(DOCSDIR)
|
||||
|
||||
|
||||
info: yap.info
|
||||
|
||||
|
@ -167,6 +167,7 @@
|
||||
#undef RETSIGTYPE
|
||||
|
||||
#undef HAVE__NSGETENVIRON
|
||||
#undef HAVE__SETJMP
|
||||
#undef HAVE_ACCESS
|
||||
#undef HAVE_ACOSH
|
||||
#undef HAVE_ALARM
|
||||
|
42
configure
vendored
42
configure
vendored
@ -7166,7 +7166,7 @@ fi
|
||||
YAPLIB_LD="$CC -dynamiclib -Wl,-install_name,$prefix/lib/libYap.dylib"
|
||||
PRE_INSTALL_ENV="DYLD_LIBRARY_PATH=\$(abs_top_builddir)"
|
||||
;;
|
||||
*netbsd*|*freebsd*)
|
||||
*netbsd*|*openbsd*|*freebsd*|*dragonfly*)
|
||||
if echo __ELF__ | ${CC:-cc} -E - | grep -q __ELF__
|
||||
then
|
||||
#an a.out system
|
||||
@ -8569,6 +8569,46 @@ $as_echo "#define HAVE_SIGSETJMP 0" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _setjmp" >&5
|
||||
$as_echo_n "checking for _setjmp... " >&6; }
|
||||
if ${yap_cv__setjmp+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
#include <setjmp.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
jmp_buf RestartEnv;
|
||||
|
||||
_longjmp (RestartEnv, 1);
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
yap_cv__setjmp=yes
|
||||
else
|
||||
yap_cv__setjmp=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv__setjmp" >&5
|
||||
$as_echo "$yap_cv__setjmp" >&6; }
|
||||
if test "$yap_cv__setjmp" = yes
|
||||
then
|
||||
$as_echo "#define HAVE__SETJMP 1" >>confdefs.h
|
||||
|
||||
else
|
||||
$as_echo "#define HAVE__SETJMP 0" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigsegv" >&5
|
||||
$as_echo_n "checking for sigsegv... " >&6; }
|
||||
if ${yap_cv_sigsegv+:} false; then :
|
||||
|
21
configure.in
21
configure.in
@ -1069,7 +1069,7 @@ dnl Linux has both elf and a.out, in this case we found elf
|
||||
YAPLIB_LD="$CC -dynamiclib -Wl,-install_name,$prefix/lib/libYap.dylib"
|
||||
PRE_INSTALL_ENV="DYLD_LIBRARY_PATH=\$(abs_top_builddir)"
|
||||
;;
|
||||
*netbsd*|*freebsd*)
|
||||
*netbsd*|*openbsd*|*freebsd*|*dragonfly*)
|
||||
if echo __ELF__ | ${CC:-cc} -E - | grep -q __ELF__
|
||||
then
|
||||
#an a.out system
|
||||
@ -1567,6 +1567,25 @@ else
|
||||
AC_DEFINE(HAVE_SIGSETJMP,0)
|
||||
fi
|
||||
|
||||
dnl check for _setjmp
|
||||
AC_MSG_CHECKING(for _setjmp)
|
||||
AC_CACHE_VAL(yap_cv__setjmp,[
|
||||
AC_TRY_COMPILE(
|
||||
#include <setjmp.h>
|
||||
,
|
||||
jmp_buf RestartEnv;
|
||||
|
||||
_longjmp (RestartEnv, 1);
|
||||
,
|
||||
yap_cv__setjmp=yes,yap_cv__setjmp=no)])
|
||||
AC_MSG_RESULT($yap_cv__setjmp)
|
||||
if test "$yap_cv__setjmp" = yes
|
||||
then
|
||||
AC_DEFINE(HAVE__SETJMP,1)
|
||||
else
|
||||
AC_DEFINE(HAVE__SETJMP,0)
|
||||
fi
|
||||
|
||||
dnl check for sigsegv
|
||||
AC_MSG_CHECKING(for sigsegv)
|
||||
AC_CACHE_VAL(yap_cv_sigsegv,[
|
||||
|
57
docs/yap.tex
57
docs/yap.tex
@ -2339,14 +2339,16 @@ with the current source module:
|
||||
@cnindex meta_predicate/1 (directive)
|
||||
Each @var{Gi} is a mode specification.
|
||||
|
||||
If the argument is @code{:} or an integer, the argument is a call and
|
||||
must be expanded. Otherwise, the argument is not expanded. Note
|
||||
that the system already includes declarations for all built-ins.
|
||||
If the argument is @code{:}, it does not refer directly to a predicate
|
||||
but must be module expanded. If the argument is an integer, the argument
|
||||
is a goal or a closure and must be expanded. Otherwise, the argument is
|
||||
not expanded. Note that the system already includes declarations for all
|
||||
built-ins.
|
||||
|
||||
For example, the declaration for @code{call/1} and @code{setof/3} are:
|
||||
|
||||
@example
|
||||
:- meta_predicate call(:), setof(?,:,?).
|
||||
:- meta_predicate call(0), setof(?,0,?).
|
||||
@end example
|
||||
|
||||
@end table
|
||||
@ -6125,6 +6127,22 @@ Number of clauses in the predicate definition. Always one if external
|
||||
or built-in.
|
||||
@end table
|
||||
|
||||
@item predicate_statistics(@var{P},@var{NCls},@var{Sz},@var{IndexSz})
|
||||
@findex predicate_statistics/4
|
||||
|
||||
Given predicate @var{P}, @var{NCls} is the number of clauses for
|
||||
@var{P}, @var{Sz} is the amount of space taken to store those clauses
|
||||
(in bytes), and @var{IndexSz} is the amount of space required to store
|
||||
indices to those clauses (in bytes).
|
||||
|
||||
@item predicate_erased_statistics(@var{P},@var{NCls},@var{Sz},@var{IndexSz})
|
||||
@findex predicate_statistics/4
|
||||
|
||||
Given predicate @var{P}, @var{NCls} is the number of erased clauses for
|
||||
@var{P} that could not be discarded yet, @var{Sz} is the amount of space
|
||||
taken to store those clauses (in bytes), and @var{IndexSz} is the amount
|
||||
of space required to store indices to those clauses (in bytes).
|
||||
|
||||
@end table
|
||||
|
||||
@node Database References, Internal Database, Looking at the Database, Database
|
||||
@ -7298,6 +7316,7 @@ Show profiling info for the top-most @var{N} predicates.
|
||||
|
||||
@end table
|
||||
|
||||
The @code{showprofres/0} and @code{showprofres/1} predicates call a user-defined multifile hook predicate, @code{user:prolog_predicate_name/2}, that can be used for converting a possibly explicitly-qualified callable term into an atom that will used when printing the profiling information.
|
||||
|
||||
@node Call Counting, Arrays, Profiling, Top
|
||||
@section Counting Calls
|
||||
@ -11613,15 +11632,6 @@ is considered. Otherwise, the term is considered only up to depth
|
||||
@code{1}, where the constants and the principal functor have depth
|
||||
@code{1}, and an argument of a term with depth @var{I} has depth @var{I+1}.
|
||||
|
||||
@item term_variables(?@var{Term}, -@var{Variables})
|
||||
@findex term_variables/2
|
||||
@syindex term_variables/2
|
||||
@cnindex term_variables/2
|
||||
|
||||
Unify @var{Variables} with the list of all variables of term
|
||||
@var{Term}. The variables occur in the order of their first
|
||||
appearance when traversing the term depth-first, left-to-right.
|
||||
|
||||
@item variables_within_term(+@var{Variables},?@var{Term}, -@var{OutputVariables})
|
||||
@findex variables_within_term/3
|
||||
@snindex variables_within_term/3
|
||||
@ -13285,6 +13295,16 @@ defined.
|
||||
@cnindex copy_term_nat/2
|
||||
As @code{copy_term/2}. Attributes however, are @emph{not} copied but replaced
|
||||
by fresh variables.
|
||||
|
||||
@item term_variables(?@var{Term}, -@var{Variables})
|
||||
@findex term_variables/2
|
||||
@syindex term_variables/2
|
||||
@cnindex term_variables/2
|
||||
|
||||
Unify @var{Variables} with the list of all variables of term
|
||||
@var{Term}. The variables occur in the order of their first
|
||||
appearance when traversing the term depth-first, left-to-right.
|
||||
|
||||
@end table
|
||||
|
||||
@node Old Style Attribute Declarations, , New Style Attribute Declarations, Attributed Variables
|
||||
@ -15711,12 +15731,11 @@ loop(Env) :-
|
||||
|
||||
@section Profiling
|
||||
|
||||
The indexation mechanism restricts the set of clauses to be tried in a
|
||||
procedure by using information about the status of a selected argument of
|
||||
the goal (in YAP, as in most compilers, the first argument).
|
||||
This argument
|
||||
is then used as a key, selecting a restricted set of a clauses from all the
|
||||
clauses forming the procedure.
|
||||
The indexation mechanism restricts the set of clauses to be tried in a
|
||||
procedure by using information about the status of the instantiated
|
||||
arguments of the goal. These arguments are then used as a key,
|
||||
selecting a restricted set of a clauses from all the clauses forming the
|
||||
procedure.
|
||||
|
||||
As an example, the two clauses for concatenate:
|
||||
|
||||
|
@ -31,6 +31,10 @@
|
||||
with_output_to_chars/4
|
||||
]).
|
||||
|
||||
:- meta_predicate(with_output_to_chars(0,?)).
|
||||
:- meta_predicate(with_output_to_chars(0,-,?)).
|
||||
:- meta_predicate(with_output_to_chars(0,-,?,?)).
|
||||
|
||||
format_to_chars(Form, Args, OUT) :-
|
||||
format_to_chars(Form, Args, OUT, []).
|
||||
|
||||
|
@ -89,6 +89,7 @@ A E N "e"
|
||||
A EOFBeforeEOT N "end_of_file_found_before_end_of_term"
|
||||
A EQ N "="
|
||||
A EmptyAtom N ""
|
||||
A Encoding N "encoding"
|
||||
A EndOfStream N "$end_of_stream"
|
||||
A Eof N "end_of_file"
|
||||
A Eq N "="
|
||||
|
@ -1,7 +1,7 @@
|
||||
#%define _unpackaged_files_terminate_build 0
|
||||
#%undefine __check_files
|
||||
|
||||
Name: Yap
|
||||
Name: yap
|
||||
Summary: Prolog Compiler
|
||||
Version: 6.2.0
|
||||
Packager: Vitor Santos Costa <vsc@dcc.fc.up.pt>
|
||||
@ -36,6 +36,8 @@ rm -rf $RPM_BUILD_ROOT
|
||||
make DESTDIR=$RPM_BUILD_ROOT install
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/share/info
|
||||
make DESTDIR=$RPM_BUILD_ROOT install_info
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/share/doc/Yap
|
||||
make DESTDIR=$RPM_BUILD_ROOT install_docs
|
||||
|
||||
%post
|
||||
/sbin/install-info --quiet /usr/share/info/yap.info --section "Programming Languages" /usr/share/info/dir
|
||||
@ -54,6 +56,9 @@ rm -rf $RPM_BUILD_ROOT $RPM_BUILD_DIR/file.list.%{name}
|
||||
%defattr(-,root,root,-)
|
||||
%doc README*
|
||||
%doc INSTALL
|
||||
%doc changes-6.0.html
|
||||
%doc changes-5.1.html
|
||||
%doc changes-5.0.html
|
||||
%doc changes4.3.html
|
||||
%doc docs/yap.tex
|
||||
/usr/bin/yap
|
||||
@ -63,6 +68,7 @@ rm -rf $RPM_BUILD_ROOT $RPM_BUILD_DIR/file.list.%{name}
|
||||
/usr/share/Yap/
|
||||
/usr/share/info/yap.info*
|
||||
/usr/share/info/pillow_doc.info*
|
||||
/usr/share/doc/Yap
|
||||
|
||||
%changelog
|
||||
|
||||
|
74
misc/Yap64.spec
Normal file
74
misc/Yap64.spec
Normal file
@ -0,0 +1,74 @@
|
||||
#%define _unpackaged_files_terminate_build 0
|
||||
#%undefine __check_files
|
||||
|
||||
Name: yap
|
||||
Summary: Prolog Compiler
|
||||
Version: 6.2.0
|
||||
Packager: Vitor Santos Costa <vsc@dcc.fc.up.pt>
|
||||
Release: 1
|
||||
Source: http://www.dcc.fc.up.pt/~vsc/Yap/%{name}-%{version}.tar.gz
|
||||
License: Perl Artistic License, LGPL
|
||||
Provides: yap
|
||||
Requires: readline, unixODBC, gmp, cudd
|
||||
Group: Development/Languages
|
||||
URL: http://www.dcc.fc.up.pt/~vsc/Yap
|
||||
Prefix: /usr
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
||||
|
||||
%description
|
||||
A high-performance Prolog compiler developed at
|
||||
Universidade do Porto and Universidade Federal do Rio de Janeiro. The Prolog engine is based in the WAM (Warren
|
||||
Abstract Machine), with several optimizations for better
|
||||
performance. YAP follows the Edinburgh tradition, and is largely
|
||||
compatible with the ISO-Prolog standard and with Quintus and SICStus
|
||||
Prolog.
|
||||
|
||||
%prep
|
||||
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
./configure --prefix=/usr --prefix=/usr --libdir=/usr/lib64 --enable-max-performance --enable-depth-limit
|
||||
make
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make DESTDIR=$RPM_BUILD_ROOT install
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/share/info
|
||||
make DESTDIR=$RPM_BUILD_ROOT install_info
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/share/doc/Yap
|
||||
make DESTDIR=$RPM_BUILD_ROOT install_docs
|
||||
|
||||
%post
|
||||
/sbin/install-info --quiet /usr/share/info/yap.info --section "Programming Languages" /usr/share/info/dir
|
||||
/sbin/install-info --quiet /usr/share/info/pillow_doc.info --section "Programming Languages" /usr/share/info/dir
|
||||
|
||||
%postun
|
||||
/sbin/install-info --quiet --delete yap.info /usr/share/info/dir
|
||||
/sbin/install-info --quiet --delete pillow_doc.info /usr/share/info/dir
|
||||
|
||||
rm -f /usr/info/yap.info*
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT $RPM_BUILD_DIR/file.list.%{name}
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%doc README*
|
||||
%doc INSTALL
|
||||
%doc changes-6.0.html
|
||||
%doc changes-5.1.html
|
||||
%doc changes-5.0.html
|
||||
%doc changes4.3.html
|
||||
%doc docs/yap.tex
|
||||
/usr/bin/yap
|
||||
/usr/lib64/Yap/
|
||||
/usr/lib64/libYap.a
|
||||
/usr/include/Yap/
|
||||
/usr/share/Yap/
|
||||
/usr/share/info/yap.info*
|
||||
/usr/share/info/pillow_doc.info*
|
||||
/usr/share/doc/Yap
|
||||
|
||||
%changelog
|
||||
|
28
misc/yap.nsi
28
misc/yap.nsi
@ -29,7 +29,7 @@ ComponentText "This will install YAP on your computer."
|
||||
DirText "This program will install YAP on your computer.\
|
||||
Choose a directory"
|
||||
|
||||
LicenseData c:\Yap\share\docs\Yap\Artistic
|
||||
LicenseData c:\Yap\share\doc\Yap\Artistic
|
||||
LicenseText "YAP is governed by the Artistic License,\
|
||||
but includes code under the GPL and LGPL."
|
||||
|
||||
@ -65,12 +65,12 @@ Section "Base system (required)"
|
||||
; SYSTEM STUFF
|
||||
File /r c:\Yap\share\Yap\*
|
||||
|
||||
SetOutPath $INSTDIR\docs\Yap
|
||||
File c:\Yap\share\docs\Yap\yap.html
|
||||
File c:\Yap\share\docs\Yap\yap.pdf
|
||||
File c:\Yap\share\docs\Yap\Artistic
|
||||
File c:\Yap\share\docs\Yap\README.TXT
|
||||
File c:\Yap\share\docs\Yap\COPYING.TXT
|
||||
SetOutPath $INSTDIR\doc\Yap
|
||||
File c:\Yap\share\doc\Yap\yap.html
|
||||
File c:\Yap\share\doc\Yap\yap.pdf
|
||||
File c:\Yap\share\doc\Yap\Artistic
|
||||
File c:\Yap\share\doc\Yap\README.TXT
|
||||
File c:\Yap\share\doc\Yap\COPYING.TXT
|
||||
|
||||
WriteRegStr HKLM ${REGKEY} "home" "$INSTDIR"
|
||||
WriteRegStr HKLM ${REGKEY} "startup" "$INSTDIR\lib\startup.yss"
|
||||
@ -94,16 +94,16 @@ Section "Start Menu shortcuts"
|
||||
0
|
||||
SetOutPath $INSTDIR
|
||||
CreateShortCut "$SMPROGRAMS\${GRP}\Readme.lnk" \
|
||||
"$INSTDIR\docs\Yap\README.TXT" "" \
|
||||
"$INSTDIR\docs\Yap\README.TXT" 0 \
|
||||
"$INSTDIR\doc\Yap\README.TXT" "" \
|
||||
"$INSTDIR\doc\Yap\README.TXT" 0 \
|
||||
"SW_SHOWNORMAL" "" "View readme"
|
||||
CreateShortCut "$SMPROGRAMS\${GRP}\Manual Html.lnk" \
|
||||
"$INSTDIR\docs\Yap\yap.html" "" \
|
||||
"$INSTDIR\docs\Yap\yap.html" 0 \
|
||||
"$INSTDIR\doc\Yap\yap.html" "" \
|
||||
"$INSTDIR\doc\Yap\yap.html" 0 \
|
||||
"SW_SHOWNORMAL" "" "View readme"
|
||||
CreateShortCut "$SMPROGRAMS\${GRP}\Manual PDF.lnk" \
|
||||
"$INSTDIR\docs\Yap\yap.pdf" "" \
|
||||
"$INSTDIR\docs\Yap\yap.pdf" 0 \
|
||||
"$INSTDIR\doc\Yap\yap.pdf" "" \
|
||||
"$INSTDIR\doc\Yap\yap.pdf" 0 \
|
||||
"SW_SHOWNORMAL" "" "View readme"
|
||||
CreateShortCut "$SMPROGRAMS\${GRP}\Uninstall.lnk" \
|
||||
"$INSTDIR\uninstall.exe" \
|
||||
@ -256,7 +256,7 @@ FunctionEnd
|
||||
|
||||
Function .onInstSuccess
|
||||
MessageBox MB_YESNO "Installation complete. View readme?" IDNO NoReadme
|
||||
ExecShell "open" "$INSTDIR\docs\README.TXT"
|
||||
ExecShell "open" "$INSTDIR\doc\README.TXT"
|
||||
NoReadme:
|
||||
FunctionEnd
|
||||
|
||||
|
@ -19,8 +19,9 @@ LIBDIR=@libdir@
|
||||
YAPLIBDIR=@libdir@/Yap
|
||||
#
|
||||
#
|
||||
DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1
|
||||
CC=@CC@
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -D_YAP_NOT_INSTALLED_=1 -I$(srcdir) -I../.. -I$(srcdir)/../../include @CPPFLAGS@
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include @CPPFLAGS@
|
||||
#
|
||||
#
|
||||
# You shouldn't need to change what follows.
|
||||
|
@ -51,6 +51,8 @@ PROBLOG_PROGRAMS= \
|
||||
$(srcdir)/problog/print_learning.yap \
|
||||
$(srcdir)/problog/utils_learning.yap \
|
||||
$(srcdir)/problog/version_control.yap \
|
||||
$(srcdir)/problog/nestedtries.yap \
|
||||
$(srcdir)/problog/utils.yap \
|
||||
$(srcdir)/problog/variables.yap
|
||||
|
||||
PROBLOG_EXAMPLES = \
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-09-30 13:50:45 +0200 (Thu, 30 Sep 2010) $
|
||||
% $Revision: 4857 $
|
||||
% $Date: 2010-10-11 14:14:11 +0200 (Mon, 11 Oct 2010) $
|
||||
% $Revision: 4892 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
@ -206,7 +206,6 @@
|
||||
|
||||
|
||||
:- module(logger,[logger_define_variable/2,
|
||||
logger_define_variables/2,
|
||||
logger_set_filename/1,
|
||||
logger_set_delimiter/1,
|
||||
logger_set_variable/2,
|
||||
@ -238,25 +237,35 @@
|
||||
%= +Name, +Type
|
||||
%========================================================================
|
||||
|
||||
logger_define_variable(Name,int) :-
|
||||
logger_define_variable(Name,Type) :-
|
||||
bb_get(logger_variables,Variables),
|
||||
member((Name,_),Variables),
|
||||
!,
|
||||
throw(error(variable_redefined(logger_define_variable(Name,Type)))).
|
||||
logger_define_variable(Name,Type) :-
|
||||
ground(Name),
|
||||
atomic(Name),
|
||||
!,
|
||||
logger_define_variable_intern(Type,Name).
|
||||
logger_define_variable(Name,Type) :-
|
||||
throw(error(illegal_variable_name(logger_define_variable(Name,Type)))).
|
||||
|
||||
logger_define_variable_intern(int,Name) :-
|
||||
!,
|
||||
is_variable_already_defined(Name),
|
||||
bb_delete(logger_variables,OldVariables),
|
||||
append(OldVariables,[(Name,int)],NewVariables),
|
||||
bb_put(logger_variables,NewVariables),
|
||||
atom_concat(logger_data_,Name,Key),
|
||||
bb_put(Key,null).
|
||||
logger_define_variable(Name,float) :-
|
||||
logger_define_variable_intern(float,Name) :-
|
||||
!,
|
||||
is_variable_already_defined(Name),
|
||||
bb_delete(logger_variables,OldVariables),
|
||||
append(OldVariables,[(Name,float)],NewVariables),
|
||||
bb_put(logger_variables,NewVariables),
|
||||
atom_concat(logger_data_,Name,Key),
|
||||
bb_put(Key,null).
|
||||
logger_define_variable(Name,time) :-
|
||||
logger_define_variable_intern(time,Name) :-
|
||||
!,
|
||||
is_variable_already_defined(Name),
|
||||
bb_delete(logger_variables,OldVariables),
|
||||
append(OldVariables,[(Name,time)],NewVariables),
|
||||
bb_put(logger_variables,NewVariables),
|
||||
@ -264,34 +273,9 @@ logger_define_variable(Name,time) :-
|
||||
atom_concat(logger_start_time_,Name,Key2),
|
||||
bb_put(Key,null),
|
||||
bb_put(Key2,null).
|
||||
logger_define_variable(Name,Unknown) :-
|
||||
is_variable_already_defined(Name),
|
||||
write('logger_define_variable, unknown type '),
|
||||
write(Unknown),
|
||||
write(' for variable '),
|
||||
write(Name),
|
||||
nl,
|
||||
fail.
|
||||
logger_define_variable_intern(Type,Name) :-
|
||||
throw(error(unknown_variable_type(logger_define_variable(Name,Type)))).
|
||||
|
||||
is_variable_already_defined(Name) :-
|
||||
bb_get(logger_variables,Variables),
|
||||
member((Name,_),Variables),!,
|
||||
write('logger_define_variable, Variable '),
|
||||
write(Name),
|
||||
write(' is already defined!\n'),
|
||||
fail;
|
||||
true.
|
||||
|
||||
%========================================================================
|
||||
%=
|
||||
%=
|
||||
%= +ListOfNames, +Type
|
||||
%========================================================================
|
||||
|
||||
logger_define_variables([],_).
|
||||
logger_define_variables([H|T],Type) :-
|
||||
logger_define_variable(H,Type),
|
||||
logger_define_variables(T,Type).
|
||||
|
||||
%========================================================================
|
||||
%= Set the filename, to which the output should be appended
|
||||
|
423
packages/ProbLog/problog/nestedtries.yap
Normal file
423
packages/ProbLog/problog/nestedtries.yap
Normal file
@ -0,0 +1,423 @@
|
||||
%%% -*- Mode: Prolog; -*-
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-11-03 19:13:53 +0100 (Wed, 03 Nov 2010) $
|
||||
% $Revision: 4986 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
%
|
||||
% ProbLog was developed at Katholieke Universiteit Leuven
|
||||
%
|
||||
% Copyright 2008, 2009, 2010
|
||||
% Katholieke Universiteit Leuven
|
||||
%
|
||||
% Main authors of this file:
|
||||
% Theofrastos Mantadelis
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% Artistic License 2.0
|
||||
%
|
||||
% Copyright (c) 2000-2006, The Perl Foundation.
|
||||
%
|
||||
% Everyone is permitted to copy and distribute verbatim copies of this
|
||||
% license document, but changing it is not allowed. Preamble
|
||||
%
|
||||
% This license establishes the terms under which a given free software
|
||||
% Package may be copied, modified, distributed, and/or
|
||||
% redistributed. The intent is that the Copyright Holder maintains some
|
||||
% artistic control over the development of that Package while still
|
||||
% keeping the Package available as open source and free software.
|
||||
%
|
||||
% You are always permitted to make arrangements wholly outside of this
|
||||
% license directly with the Copyright Holder of a given Package. If the
|
||||
% terms of this license do not permit the full use that you propose to
|
||||
% make of the Package, you should contact the Copyright Holder and seek
|
||||
% a different licensing arrangement. Definitions
|
||||
%
|
||||
% "Copyright Holder" means the individual(s) or organization(s) named in
|
||||
% the copyright notice for the entire Package.
|
||||
%
|
||||
% "Contributor" means any party that has contributed code or other
|
||||
% material to the Package, in accordance with the Copyright Holder's
|
||||
% procedures.
|
||||
%
|
||||
% "You" and "your" means any person who would like to copy, distribute,
|
||||
% or modify the Package.
|
||||
%
|
||||
% "Package" means the collection of files distributed by the Copyright
|
||||
% Holder, and derivatives of that collection and/or of those files. A
|
||||
% given Package may consist of either the Standard Version, or a
|
||||
% Modified Version.
|
||||
%
|
||||
% "Distribute" means providing a copy of the Package or making it
|
||||
% accessible to anyone else, or in the case of a company or
|
||||
% organization, to others outside of your company or organization.
|
||||
%
|
||||
% "Distributor Fee" means any fee that you charge for Distributing this
|
||||
% Package or providing support for this Package to another party. It
|
||||
% does not mean licensing fees.
|
||||
%
|
||||
% "Standard Version" refers to the Package if it has not been modified,
|
||||
% or has been modified only in ways explicitly requested by the
|
||||
% Copyright Holder.
|
||||
%
|
||||
% "Modified Version" means the Package, if it has been changed, and such
|
||||
% changes were not explicitly requested by the Copyright Holder.
|
||||
%
|
||||
% "Original License" means this Artistic License as Distributed with the
|
||||
% Standard Version of the Package, in its current version or as it may
|
||||
% be modified by The Perl Foundation in the future.
|
||||
%
|
||||
% "Source" form means the source code, documentation source, and
|
||||
% configuration files for the Package.
|
||||
%
|
||||
% "Compiled" form means the compiled bytecode, object code, binary, or
|
||||
% any other form resulting from mechanical transformation or translation
|
||||
% of the Source form.
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% Permission for Use and Modification Without Distribution
|
||||
%
|
||||
% (1) You are permitted to use the Standard Version and create and use
|
||||
% Modified Versions for any purpose without restriction, provided that
|
||||
% you do not Distribute the Modified Version.
|
||||
%
|
||||
% Permissions for Redistribution of the Standard Version
|
||||
%
|
||||
% (2) You may Distribute verbatim copies of the Source form of the
|
||||
% Standard Version of this Package in any medium without restriction,
|
||||
% either gratis or for a Distributor Fee, provided that you duplicate
|
||||
% all of the original copyright notices and associated disclaimers. At
|
||||
% your discretion, such verbatim copies may or may not include a
|
||||
% Compiled form of the Package.
|
||||
%
|
||||
% (3) You may apply any bug fixes, portability changes, and other
|
||||
% modifications made available from the Copyright Holder. The resulting
|
||||
% Package will still be considered the Standard Version, and as such
|
||||
% will be subject to the Original License.
|
||||
%
|
||||
% Distribution of Modified Versions of the Package as Source
|
||||
%
|
||||
% (4) You may Distribute your Modified Version as Source (either gratis
|
||||
% or for a Distributor Fee, and with or without a Compiled form of the
|
||||
% Modified Version) provided that you clearly document how it differs
|
||||
% from the Standard Version, including, but not limited to, documenting
|
||||
% any non-standard features, executables, or modules, and provided that
|
||||
% you do at least ONE of the following:
|
||||
%
|
||||
% (a) make the Modified Version available to the Copyright Holder of the
|
||||
% Standard Version, under the Original License, so that the Copyright
|
||||
% Holder may include your modifications in the Standard Version. (b)
|
||||
% ensure that installation of your Modified Version does not prevent the
|
||||
% user installing or running the Standard Version. In addition, the
|
||||
% modified Version must bear a name that is different from the name of
|
||||
% the Standard Version. (c) allow anyone who receives a copy of the
|
||||
% Modified Version to make the Source form of the Modified Version
|
||||
% available to others under (i) the Original License or (ii) a license
|
||||
% that permits the licensee to freely copy, modify and redistribute the
|
||||
% Modified Version using the same licensing terms that apply to the copy
|
||||
% that the licensee received, and requires that the Source form of the
|
||||
% Modified Version, and of any works derived from it, be made freely
|
||||
% available in that license fees are prohibited but Distributor Fees are
|
||||
% allowed.
|
||||
%
|
||||
% Distribution of Compiled Forms of the Standard Version or
|
||||
% Modified Versions without the Source
|
||||
%
|
||||
% (5) You may Distribute Compiled forms of the Standard Version without
|
||||
% the Source, provided that you include complete instructions on how to
|
||||
% get the Source of the Standard Version. Such instructions must be
|
||||
% valid at the time of your distribution. If these instructions, at any
|
||||
% time while you are carrying out such distribution, become invalid, you
|
||||
% must provide new instructions on demand or cease further
|
||||
% distribution. If you provide valid instructions or cease distribution
|
||||
% within thirty days after you become aware that the instructions are
|
||||
% invalid, then you do not forfeit any of your rights under this
|
||||
% license.
|
||||
%
|
||||
% (6) You may Distribute a Modified Version in Compiled form without the
|
||||
% Source, provided that you comply with Section 4 with respect to the
|
||||
% Source of the Modified Version.
|
||||
%
|
||||
% Aggregating or Linking the Package
|
||||
%
|
||||
% (7) You may aggregate the Package (either the Standard Version or
|
||||
% Modified Version) with other packages and Distribute the resulting
|
||||
% aggregation provided that you do not charge a licensing fee for the
|
||||
% Package. Distributor Fees are permitted, and licensing fees for other
|
||||
% components in the aggregation are permitted. The terms of this license
|
||||
% apply to the use and Distribution of the Standard or Modified Versions
|
||||
% as included in the aggregation.
|
||||
%
|
||||
% (8) You are permitted to link Modified and Standard Versions with
|
||||
% other works, to embed the Package in a larger work of your own, or to
|
||||
% build stand-alone binary or bytecode versions of applications that
|
||||
% include the Package, and Distribute the result without restriction,
|
||||
% provided the result does not expose a direct interface to the Package.
|
||||
%
|
||||
% Items That are Not Considered Part of a Modified Version
|
||||
%
|
||||
% (9) Works (including, but not limited to, modules and scripts) that
|
||||
% merely extend or make use of the Package, do not, by themselves, cause
|
||||
% the Package to be a Modified Version. In addition, such works are not
|
||||
% considered parts of the Package itself, and are not subject to the
|
||||
% terms of this license.
|
||||
%
|
||||
% General Provisions
|
||||
%
|
||||
% (10) Any use, modification, and distribution of the Standard or
|
||||
% Modified Versions is governed by this Artistic License. By using,
|
||||
% modifying or distributing the Package, you accept this license. Do not
|
||||
% use, modify, or distribute the Package, if you do not accept this
|
||||
% license.
|
||||
%
|
||||
% (11) If your Modified Version has been derived from a Modified Version
|
||||
% made by someone other than you, you are nevertheless required to
|
||||
% ensure that your Modified Version complies with the requirements of
|
||||
% this license.
|
||||
%
|
||||
% (12) This license does not grant you the right to use any trademark,
|
||||
% service mark, tradename, or logo of the Copyright Holder.
|
||||
%
|
||||
% (13) This license includes the non-exclusive, worldwide,
|
||||
% free-of-charge patent license to make, have made, use, offer to sell,
|
||||
% sell, import and otherwise transfer the Package with respect to any
|
||||
% patent claims licensable by the Copyright Holder that are necessarily
|
||||
% infringed by the Package. If you institute patent litigation
|
||||
% (including a cross-claim or counterclaim) against any party alleging
|
||||
% that the Package constitutes direct or contributory patent
|
||||
% infringement, then this Artistic License to you shall terminate on the
|
||||
% date that such litigation is filed.
|
||||
%
|
||||
% (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT
|
||||
% HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
% WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
% PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT
|
||||
% PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT
|
||||
% HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
% INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
|
||||
% OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% nested tries handling
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
:- module(nestedtries, [nested_trie_to_depth_breadth_trie/4]).
|
||||
|
||||
:- use_module(library(ordsets), [list_to_ord_set/2, ord_subset/2]). % this two might be better to do a custom fast implementation
|
||||
:- use_module(library(lists), [memberchk/2, delete/3]).
|
||||
:- use_module(library(tries), [trie_to_depth_breadth_trie/6, trie_get_depth_breadth_reduction_entry/1, trie_dup/2, trie_close/1, trie_open/1, trie_replace_nested_trie/3, trie_remove_entry/1, trie_get_entry/2, trie_put_entry/3, trie_traverse/2]).
|
||||
|
||||
:- use_module(flags, [problog_define_flag/5, problog_flag/2]).
|
||||
|
||||
:- style_check(all).
|
||||
:- yap_flag(unknown,error).
|
||||
|
||||
:- initialization((
|
||||
% problog_define_flag(subset_check, problog_flag_validate_boolean, 'perform subset check in nested tries', true, nested_tries),
|
||||
problog_define_flag(loop_refine_ancs, problog_flag_validate_boolean, 'refine ancestors if no loop exists', true, nested_tries)
|
||||
% problog_define_flag(trie_preprocess, problog_flag_validate_boolean, 'perform a preprocess step to nested tries', false, nested_tries),
|
||||
% problog_define_flag(refine_anclst, problog_flag_validate_boolean, 'refine the ancestor list with their childs', false, nested_tries),
|
||||
% problog_define_flag(anclst_represent,problog_flag_validate_in_list([list, integer]), 'represent the ancestor list', list, nested_tries)
|
||||
)).
|
||||
|
||||
|
||||
trie_replace_entry(_Trie, Entry, _E, false):-
|
||||
!, trie_remove_entry(Entry).
|
||||
trie_replace_entry(Trie, Entry, E, true):-
|
||||
!, trie_get_entry(Entry, Proof),
|
||||
delete(Proof, E, NewProof),
|
||||
(NewProof == [] ->
|
||||
trie_delete(Trie),
|
||||
trie_put_entry(Trie, [true], _)
|
||||
;
|
||||
trie_remove_entry(Entry),
|
||||
trie_put_entry(Trie, NewProof, _)
|
||||
).
|
||||
trie_replace_entry(Trie, _Entry, t(ID), R):-
|
||||
trie_replace_nested_trie(Trie, ID, R).
|
||||
|
||||
trie_delete(Trie):-
|
||||
trie_traverse(Trie, R),
|
||||
trie_remove_entry(R),
|
||||
fail.
|
||||
trie_delete(_Trie).
|
||||
|
||||
is_state(Variable):-
|
||||
Variable == true, !.
|
||||
is_state(Variable):-
|
||||
Variable == false.
|
||||
is_state(Variable):-
|
||||
nonvar(Variable),
|
||||
Variable = not(NestedVariable),
|
||||
is_state(NestedVariable).
|
||||
|
||||
is_trie(Trie, ID):-
|
||||
nonvar(Trie),
|
||||
Trie = t(ID), !.
|
||||
is_trie(Trie, ID):-
|
||||
nonvar(Trie),
|
||||
Trie = not(NestedTrie),
|
||||
is_trie(NestedTrie, ID).
|
||||
|
||||
is_label(Label, ID):-
|
||||
atom(Label), !,
|
||||
atomic_concat('L', ID, Label).
|
||||
is_label(Label, ID):-
|
||||
nonvar(Label),
|
||||
Label = not(NestedLabel),
|
||||
is_label(NestedLabel, ID).
|
||||
|
||||
% Ancestor related stuff
|
||||
|
||||
initialise_ancestors(0):-
|
||||
problog_flag(anclst_represent, integer).
|
||||
initialise_ancestors([]):-
|
||||
problog_flag(anclst_represent, list).
|
||||
|
||||
add_to_ancestors(ID, Ancestors, NewAncestors):-
|
||||
integer(Ancestors), !,
|
||||
NewAncestors is (1 << (ID - 1)) \/ Ancestors.
|
||||
add_to_ancestors(ID, Ancestors, NewAncestors):-
|
||||
is_list(Ancestors),
|
||||
list_to_ord_set([ID|Ancestors], NewAncestors).
|
||||
|
||||
ancestor_subset_check(SubAncestors, Ancestors):-
|
||||
integer(SubAncestors), !,
|
||||
SubAncestors is Ancestors /\ SubAncestors.
|
||||
ancestor_subset_check(SubAncestors, Ancestors):-
|
||||
is_list(SubAncestors),
|
||||
ord_subset(SubAncestors, Ancestors).
|
||||
|
||||
ancestor_loop_refine(Loop, Ancestors, 0):-
|
||||
var(Loop), integer(Ancestors), !.
|
||||
ancestor_loop_refine(Loop, Ancestors, []):-
|
||||
var(Loop), is_list(Ancestors), !.
|
||||
ancestor_loop_refine(true, Ancestors, Ancestors).
|
||||
|
||||
% Cycle check related stuff
|
||||
% missing synonym check
|
||||
|
||||
cycle_check(ID, Ancestors):-
|
||||
integer(Ancestors), !,
|
||||
Bit is 1 << (ID - 1),
|
||||
Bit is Bit /\ Ancestors.
|
||||
cycle_check(ID, Ancestors):-
|
||||
is_list(Ancestors),
|
||||
memberchk(ID, Ancestors).
|
||||
|
||||
preprocess(Index, DepthBreadthTrie, OptimizationLevel, StartCount, FinalEndCount):-
|
||||
problog:problog_chktabled(Index, Trie), !,
|
||||
trie_dup(Trie, CopyTrie),
|
||||
initialise_ancestors(Ancestors),
|
||||
make_nested_trie_base_cases(CopyTrie, t(Index), DepthBreadthTrie, OptimizationLevel, StartCount, EndCount, Ancestors),
|
||||
trie_close(CopyTrie),
|
||||
Next is Index + 1,
|
||||
preprocess(Next, DepthBreadthTrie, OptimizationLevel, EndCount, FinalEndCount).
|
||||
preprocess(_, _, _, FinalEndCount, FinalEndCount).
|
||||
|
||||
make_nested_trie_base_cases(Trie, t(ID), DepthBreadthTrie, OptimizationLevel, StartCount, FinalEndCount, Ancestors):-
|
||||
trie_to_depth_breadth_trie(Trie, DepthBreadthTrie, Label, OptimizationLevel, StartCount, EndCount),
|
||||
(is_trie(Label, SID) ->
|
||||
trie_get_depth_breadth_reduction_entry(NestedEntry),
|
||||
trie_replace_entry(Trie, NestedEntry, Label, false),
|
||||
add_to_ancestors(SID, Ancestors, NewAncestors),
|
||||
make_nested_trie_base_cases(Trie, t(ID), DepthBreadthTrie, OptimizationLevel, EndCount, FinalEndCount, NewAncestors)
|
||||
;
|
||||
FinalEndCount = EndCount,
|
||||
get_set_trie(ID, Label, Ancestors)
|
||||
).
|
||||
|
||||
nested_trie_to_depth_breadth_trie(Trie, DepthBreadthTrie, FinalLabel, OptimizationLevel):-
|
||||
integer(OptimizationLevel),
|
||||
trie_open(DepthBreadthTrie),
|
||||
(problog_flag(trie_preprocess, true) ->
|
||||
preprocess(1, DepthBreadthTrie, OptimizationLevel, 0, StartCount)
|
||||
;
|
||||
StartCount = 0
|
||||
),
|
||||
initialise_ancestors(Ancestors),
|
||||
% initialise_ancestors(Childs),
|
||||
(problog_flag(loop_refine_ancs, true) ->
|
||||
trie_2_dbtrie_init(Trie, DepthBreadthTrie, OptimizationLevel, StartCount, _, Ancestors, FinalLabel, _)
|
||||
;
|
||||
trie_2_dbtrie_init(Trie, DepthBreadthTrie, OptimizationLevel, StartCount, _, Ancestors, FinalLabel, true)
|
||||
),
|
||||
eraseall(problog_trie_table).
|
||||
|
||||
trie_2_dbtrie_init(ID, DepthBreadthTrie, OptimizationLevel, StartCount, EndCount, Ancestors, Label, ContainLoop):-
|
||||
get_trie_pointer(ID, Trie),
|
||||
trie_dup(Trie, CopyTrie),
|
||||
trie_2_dbtrie_intern(CopyTrie, DepthBreadthTrie, OptimizationLevel, StartCount, EndCount, Ancestors, Label, ContainLoop),
|
||||
trie_close(CopyTrie).
|
||||
|
||||
trie_2_dbtrie_intern(Trie, DepthBreadthTrie, OptimizationLevel, StartCount, FinalEndCount, Ancestors, TrieLabel, ContainLoop):-
|
||||
trie_to_depth_breadth_trie(Trie, DepthBreadthTrie, Label, OptimizationLevel, StartCount, EndCount),
|
||||
(is_trie(Label, ID) -> % Label might have issues with negation
|
||||
trie_get_depth_breadth_reduction_entry(NestedEntry),
|
||||
% check if Trie introduces a loop
|
||||
(cycle_check(ID, Ancestors) ->
|
||||
ContainLoop = true,
|
||||
NewLabel = false,
|
||||
NewEndCount = EndCount
|
||||
;
|
||||
% check if Trie is resolved and extract it
|
||||
(get_set_trie(ID, NewLabel, Ancestors) ->
|
||||
NewEndCount = EndCount
|
||||
;
|
||||
% calculate the nested trie
|
||||
add_to_ancestors(ID, Ancestors, NewAncestors), % to be able to support 2 representations
|
||||
trie_2_dbtrie_init(ID, DepthBreadthTrie, OptimizationLevel, EndCount, NewEndCount, NewAncestors, NewLabel, NewContainLoop),
|
||||
ancestor_loop_refine(NewContainLoop, Ancestors, RefinedAncestors),
|
||||
get_set_trie(ID, NewLabel, RefinedAncestors),
|
||||
ContainLoop = NewContainLoop
|
||||
)
|
||||
),
|
||||
trie_replace_entry(Trie, NestedEntry, t(ID), NewLabel), % should be careful to verify that it works also with not(t(ID))
|
||||
trie_2_dbtrie_intern(Trie, DepthBreadthTrie, OptimizationLevel, NewEndCount, FinalEndCount, Ancestors, TrieLabel, ContainLoop)
|
||||
;
|
||||
% else we can terminate and return
|
||||
FinalEndCount = EndCount,
|
||||
TrieLabel = Label
|
||||
).
|
||||
|
||||
% predicate to check/remember resolved tries
|
||||
% no refiment of ancestor list included
|
||||
|
||||
get_trie_pointer(ID, Trie):-
|
||||
problog:problog_chktabled(ID, Trie), !.
|
||||
get_trie_pointer(Trie, Trie).
|
||||
|
||||
get_set_trie(Trie, Label, Ancestors):-
|
||||
recorded(problog_trie_table, store(Trie, StoredAncestors, Label), _),
|
||||
(problog_flag(subset_check, true) ->
|
||||
ancestor_subset_check(StoredAncestors, Ancestors)
|
||||
;
|
||||
StoredAncestors == Ancestors
|
||||
), !.
|
||||
get_set_trie(Trie, Label, Ancestors):-
|
||||
ground(Label),
|
||||
recordz(problog_trie_table, store(Trie, Ancestors, Label), _).
|
||||
|
||||
|
||||
% chk_negated([H|T], ID):-
|
||||
% simplify(H, not(t(ID))), !.
|
||||
% chk_negated([_|T], ID):-
|
||||
% chk_negated(T, ID).
|
||||
|
||||
|
||||
/*
|
||||
chk_negated([], ID, ID).
|
||||
chk_negated([H|T], ID, not(ID)):-
|
||||
simplify(H, not(t(ID))), !.
|
||||
chk_negated([H|T], ID, ID):-
|
||||
simplify(H, t(ID)), !.
|
||||
chk_negated([_|T], ID, FID):-
|
||||
chk_negated(T, ID, FID).*/
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-10-06 12:56:13 +0200 (Wed, 06 Oct 2010) $
|
||||
% $Revision: 4877 $
|
||||
% $Date: 2010-11-03 19:08:13 +0100 (Wed, 03 Nov 2010) $
|
||||
% $Revision: 4984 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
@ -445,6 +445,7 @@ problog_neg(M:G):-
|
||||
functor(G, Name, Arity),
|
||||
\+ problog_tabled(M:Name/Arity),
|
||||
\+ problog:problog_predicate(Name, Arity),
|
||||
\+ (Name == problog_neg, Arity == 1),
|
||||
throw(problog_neg_error('Error: goal must be dynamic and tabled', M:G)).
|
||||
problog_neg(M:G):-
|
||||
% exact inference
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
% $Date: 2010-10-15 17:09:55 +0200 (Fri, 15 Oct 2010) $
|
||||
% $Revision: 4939 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
@ -208,9 +208,10 @@
|
||||
:- module(timer,[timer_start/1, % +ID
|
||||
timer_stop/2, % +ID,-Duration
|
||||
timer_pause/1, % +ID
|
||||
timer_pause/2, % +ID
|
||||
timer_resume/1]). % +ID
|
||||
|
||||
timer_pause/2, % +ID,-Duration
|
||||
timer_resume/1, % +ID
|
||||
timer_elapsed/2, % +ID, -Duration
|
||||
timer_reset/1]). % +ID
|
||||
:- yap_flag(unknown,error).
|
||||
:- style_check(single_var).
|
||||
|
||||
@ -228,6 +229,11 @@ timer_start(Name) :-
|
||||
assertz(timer(Name,StartTime))
|
||||
).
|
||||
|
||||
timer_start_forced(Name) :-
|
||||
retractall(timer(Name,_)),
|
||||
statistics(walltime,[StartTime,_]),
|
||||
assertz(timer(Name,StartTime)).
|
||||
|
||||
timer_stop(Name,Duration) :-
|
||||
(
|
||||
retract(timer(Name,StartTime))
|
||||
@ -270,3 +276,17 @@ timer_resume(Name):-
|
||||
|
||||
throw(timer_not_paused(timer_resume(Name)))
|
||||
).
|
||||
|
||||
timer_elapsed(Name,Duration) :-
|
||||
(
|
||||
timer(Name,StartTime)
|
||||
->
|
||||
statistics(walltime,[StopTime,_]),
|
||||
Duration is StopTime-StartTime;
|
||||
|
||||
throw(timer_not_started(timer_elapsed(Name,Duration)))
|
||||
).
|
||||
|
||||
timer_reset(Name) :-
|
||||
retractall(timer(Name,_)),
|
||||
retractall(timer_paused(Name,_)).
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
% $Date: 2010-11-03 19:08:13 +0100 (Wed, 03 Nov 2010) $
|
||||
% $Revision: 4984 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
@ -247,11 +247,15 @@
|
||||
% load library modules
|
||||
:- use_module(library(tries)).
|
||||
:- use_module(library(lists), [append/3, member/2, memberchk/2, delete/3]).
|
||||
:- use_module(library(system), [delete_file/1, shell/1]).
|
||||
:- use_module(library(system), [tmpnam/1]).
|
||||
:- use_module(library(ordsets), [ord_intersection/3, ord_union/3]).
|
||||
|
||||
|
||||
|
||||
% load our own modules
|
||||
:- use_module(flags).
|
||||
:- use_module(utils).
|
||||
:- use_module(nestedtries, [nested_trie_to_depth_breadth_trie/4]).
|
||||
|
||||
% switch on all tests to reduce bug searching time
|
||||
:- style_check(all).
|
||||
@ -463,30 +467,31 @@ name_vars([A|B]) :-
|
||||
|
||||
nested_ptree_to_BDD_struct_script(Trie, BDDFileName, Variables):-
|
||||
tmpnam(TmpFile1),
|
||||
tmpnam(TmpFile2),
|
||||
open(TmpFile1, 'write', BDDS),
|
||||
(generate_BDD_from_trie(Trie, Inter, BDDS) ->
|
||||
next_intermediate_step(TMP), InterCNT is TMP - 1,
|
||||
write(BDDS, Inter), nl(BDDS),
|
||||
|
||||
(
|
||||
generate_BDD_from_trie(Trie, Inter, BDDS)
|
||||
->
|
||||
(
|
||||
next_intermediate_step(TMP),
|
||||
InterCNT is TMP - 1,
|
||||
format(BDDS,'~q~n',[Inter]),
|
||||
close(BDDS),
|
||||
(get_used_vars(Variables, VarCNT);VarCNT = 0),
|
||||
open(TmpFile2, 'write', HEADERS),
|
||||
write(HEADERS, '@BDD1'), nl(HEADERS),
|
||||
write(HEADERS, VarCNT), nl(HEADERS),
|
||||
write(HEADERS, 0), nl(HEADERS),
|
||||
write(HEADERS, InterCNT), nl(HEADERS),
|
||||
close(HEADERS),
|
||||
atomic_concat(['cat ', TmpFile2, ' ', TmpFile1, ' > ', BDDFileName], CMD),
|
||||
shell(CMD),
|
||||
delete_file(TmpFile1),
|
||||
delete_file(TmpFile2),
|
||||
(
|
||||
get_used_vars(Variables, VarCNT)
|
||||
->
|
||||
true;
|
||||
VarCNT = 0
|
||||
),
|
||||
create_bdd_file_with_header(BDDFileName,VarCNT,InterCNT,TmpFile1),
|
||||
delete_file_silent(TmpFile1),
|
||||
cleanup_BDD_generation
|
||||
;
|
||||
);(
|
||||
close(BDDS),
|
||||
(delete_file(TmpFile1);true),
|
||||
(delete_file(TmpFile2);true),
|
||||
delete_file_silent(TmpFile1),
|
||||
cleanup_BDD_generation,
|
||||
fail
|
||||
)
|
||||
).
|
||||
|
||||
trie_to_bdd_struct_trie(A, B, OutputFile, OptimizationLevel, Variables) :-
|
||||
@ -528,7 +533,8 @@ trie_to_bdd_struct_trie(A, B, OutputFile, OptimizationLevel, Variables) :-
|
||||
).
|
||||
|
||||
nested_trie_to_bdd_struct_trie(A, B, OutputFile, OptimizationLevel, Variables):-
|
||||
trie_nested_to_depth_breadth_trie(A, B, LL, OptimizationLevel, problog:problog_chktabled),
|
||||
%trie_nested_to_depth_breadth_trie(A, B, LL, OptimizationLevel, problog:problog_chktabled),
|
||||
nested_trie_to_depth_breadth_trie(A, B, LL, OptimizationLevel),
|
||||
(is_label(LL) ->
|
||||
retractall(deref(_,_)),
|
||||
(problog_flag(deref_terms, true) ->
|
||||
@ -571,15 +577,20 @@ nested_trie_to_bdd_struct_trie(A, B, OutputFile, OptimizationLevel, Variables):-
|
||||
write(1), nl,
|
||||
write(0), nl,
|
||||
write(1), nl,
|
||||
get_var_name(LL, NLL),
|
||||
write('L1 = '),write(NLL),nl,
|
||||
simplify(LL, FLL),
|
||||
(FLL = not(_) ->
|
||||
write('L1 = ~')
|
||||
;
|
||||
write('L1 = ')
|
||||
),
|
||||
get_var_name(FLL, NLL),
|
||||
write(NLL),nl,
|
||||
write('L1'), nl,
|
||||
told
|
||||
).
|
||||
|
||||
ptree_decomposition_struct(Trie, BDDFileName, Variables) :-
|
||||
tmpnam(TmpFile1),
|
||||
tmpnam(TmpFile2),
|
||||
nb_setval(next_inter_step, 1),
|
||||
variables_in_dbtrie(Trie, Variables),
|
||||
length(Variables, VarCnt),
|
||||
@ -599,16 +610,8 @@ ptree_decomposition_struct(Trie, BDDFileName, Variables) :-
|
||||
write('L1'), nl
|
||||
),
|
||||
told,
|
||||
tell(TmpFile2),
|
||||
write('@BDD1'),nl,
|
||||
write(VarCnt),nl,
|
||||
write('0'),nl,
|
||||
write(LCnt),nl,
|
||||
told,
|
||||
atomic_concat(['cat ', TmpFile2, ' ', TmpFile1, ' > ', BDDFileName], CMD),
|
||||
shell(CMD),
|
||||
delete_file(TmpFile1),
|
||||
delete_file(TmpFile2).
|
||||
create_bdd_file_with_header(BDDFileName,VarCnt,LCnt,TmpFile1),
|
||||
delete_file_silent(TmpFile1).
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% write BDD info for given ptree to file
|
||||
@ -696,10 +699,10 @@ bdd_vars_script_intern(A) :-
|
||||
).
|
||||
bdd_vars_script_intern2(A) :-
|
||||
get_var_name(A,NameA),
|
||||
atom_chars(A,A_Chars),
|
||||
atom_codes(A,A_Codes),
|
||||
|
||||
once(append(Part1,[95|Part2],A_Chars)), % 95 = '_'
|
||||
number_chars(ID,Part1),
|
||||
once(append(Part1,[95|Part2],A_Codes)), % 95 = '_'
|
||||
number_codes(ID,Part1),
|
||||
|
||||
( % let's check whether Part2 contains an 'l' (l=low)
|
||||
member(108,Part2)
|
||||
@ -709,7 +712,7 @@ bdd_vars_script_intern2(A) :-
|
||||
format('@~w~n0~n0~n~12f;~12f~n',[NameA,Mu,Sigma])
|
||||
);
|
||||
(
|
||||
number_chars(Grounding_ID,Part2),
|
||||
number_codes(Grounding_ID,Part2),
|
||||
(problog:decision_fact(ID,_) ->
|
||||
% it's a non-ground decision
|
||||
(problog:problog_control(check,internal_strategy) ->
|
||||
@ -987,8 +990,44 @@ get_next_name(Name) :-
|
||||
% create BDD-var as fact id prefixed by x
|
||||
% learning.yap relies on this format!
|
||||
% when changing, also adapt test_var_name/1 below
|
||||
|
||||
|
||||
simplify_list(List, SList):-
|
||||
findall(NEL, (member(El, List), simplify(El, NEL)), SList).
|
||||
|
||||
simplify(not(false), true):- !.
|
||||
simplify(not(true), false):- !.
|
||||
simplify(not(not(A)), B):-
|
||||
!, simplify(A, B).
|
||||
simplify(A, A).
|
||||
|
||||
|
||||
|
||||
simplify(not(false), true):- !.
|
||||
simplify(not(true), false):- !.
|
||||
simplify(not(not(A)), B):-
|
||||
!, simplify(A, B).
|
||||
simplify(A, A).
|
||||
|
||||
get_var_name(true, 'TRUE'):- !.
|
||||
get_var_name(false, 'FALSE'):- !.
|
||||
get_var_name(Variable, Name):-
|
||||
atomic(Variable), !,
|
||||
atomic_concat([x, Variable], Name),
|
||||
(recorded(map, m(Variable, Name), _) ->
|
||||
true
|
||||
;
|
||||
recorda(map, m(Variable, Name), _)
|
||||
).
|
||||
get_var_name(not(A), NameA):-
|
||||
get_var_name(A, NameA).
|
||||
|
||||
|
||||
/*
|
||||
get_var_name(true, 'TRUE') :-!.
|
||||
get_var_name(false, 'FALSE') :-!.
|
||||
get_var_name(not(A), NameA):-
|
||||
!, get_var_name(A, NameA).
|
||||
get_var_name(A, NameA) :-
|
||||
atomic_concat([x, A], NameA),
|
||||
(
|
||||
@ -997,7 +1036,7 @@ get_var_name(A, NameA) :-
|
||||
true
|
||||
;
|
||||
recorda(map, m(A, NameA), _)
|
||||
).
|
||||
).*/
|
||||
|
||||
% test used by base case of compression mapping to detect single-variable tree
|
||||
% has to match above naming scheme
|
||||
@ -1060,39 +1099,29 @@ spacy_print(Msg, Level, Space):-
|
||||
:- dynamic(generated_trie/2).
|
||||
:- dynamic(next_intermediate_step/1).
|
||||
|
||||
%
|
||||
% This needs to be modified
|
||||
% Include nasty code of temporary file usage
|
||||
% also it is OS depended (requires the cat utility)
|
||||
%
|
||||
|
||||
nested_ptree_to_BDD_script(Trie, BDDFileName, VarFileName):-
|
||||
tmpnam(TmpFile1),
|
||||
tmpnam(TmpFile2),
|
||||
open(TmpFile1, 'write', BDDS),
|
||||
(generate_BDD_from_trie(Trie, Inter, BDDS) ->
|
||||
next_intermediate_step(TMP), InterCNT is TMP - 1,
|
||||
write(BDDS, Inter), nl(BDDS),
|
||||
close(BDDS),
|
||||
(get_used_vars(Vars, VarCNT);VarCNT = 0),
|
||||
open(TmpFile2, 'write', HEADERS),
|
||||
write(HEADERS, '@BDD1'), nl(HEADERS),
|
||||
write(HEADERS, VarCNT), nl(HEADERS),
|
||||
write(HEADERS, 0), nl(HEADERS),
|
||||
write(HEADERS, InterCNT), nl(HEADERS),
|
||||
close(HEADERS),
|
||||
atomic_concat(['cat ', TmpFile2, ' ', TmpFile1, ' > ', BDDFileName], CMD),
|
||||
shell(CMD),
|
||||
delete_file(TmpFile1),
|
||||
delete_file(TmpFile2),
|
||||
(
|
||||
get_used_vars(Vars, VarCNT)
|
||||
->
|
||||
true;
|
||||
VarCNT = 0
|
||||
),
|
||||
create_bdd_file_with_header(BDDFileName,VarCNT,InterCNT,TmpFile1),
|
||||
delete_file_silent(TmpFile1),
|
||||
open(VarFileName, 'write', VarStream),
|
||||
bddvars_to_script(Vars, VarStream),
|
||||
close(VarStream),
|
||||
cleanup_BDD_generation
|
||||
;
|
||||
close(BDDS),
|
||||
(delete_file(TmpFile1);true),
|
||||
(delete_file(TmpFile2);true),
|
||||
delete_file_silent(TmpFile1),
|
||||
cleanup_BDD_generation,
|
||||
fail
|
||||
).
|
||||
@ -1136,7 +1165,7 @@ write_bdd_lineterm([LineTerm|LineTerms], Operator, Stream):-
|
||||
|
||||
generate_line([], [], Inter, _Stream):-
|
||||
!, get_next_intermediate_step(Inter).
|
||||
generate_line([neg(t(Hash))|L], [TrieInter|T] , Inter, Stream):-
|
||||
generate_line([not(t(Hash))|L], [TrieInter|T] , Inter, Stream):-
|
||||
!, problog:problog_chktabled(Hash, Trie),
|
||||
generate_BDD_from_trie(Trie, TrieInterTmp, Stream),
|
||||
atomic_concat(['~', TrieInterTmp], TrieInter),
|
||||
@ -1159,11 +1188,11 @@ bddvars_to_script([H|T], Stream):-
|
||||
(number(H) ->
|
||||
CurVar = H
|
||||
;
|
||||
atom_chars(H, H_Chars),
|
||||
atom_codes(H, H_Codes),
|
||||
% 95 = '_'
|
||||
append(Part1, [95|Part2], H_Chars),
|
||||
number_chars(CurVar, Part1),
|
||||
number_chars(Grounding_ID, Part2)
|
||||
append(Part1, [95|Part2], H_Codes),
|
||||
number_codes(CurVar, Part1),
|
||||
number_codes(Grounding_ID, Part2)
|
||||
),
|
||||
(problog:dynamic_probability_fact(CurVar) ->
|
||||
problog:grounding_is_known(Goal, Grounding_ID),
|
||||
@ -1198,16 +1227,17 @@ make_bdd_var(V, VName):-
|
||||
get_var_name(V, VName),
|
||||
add_to_vars(V).
|
||||
|
||||
|
||||
add_to_vars(V):-
|
||||
clause(get_used_vars(Vars, _Cnt), true),
|
||||
memberchk(V, Vars),!.
|
||||
clause(get_used_vars(Vars, _Cnt), true),
|
||||
memberchk(V, Vars),!.
|
||||
add_to_vars(V):-
|
||||
clause(get_used_vars(Vars, Cnt), true), !,
|
||||
retract(get_used_vars(Vars, Cnt)),
|
||||
NewCnt is Cnt + 1,
|
||||
assertz(get_used_vars([V|Vars], NewCnt)).
|
||||
clause(get_used_vars(Vars, Cnt), true), !,
|
||||
retract(get_used_vars(Vars, Cnt)),
|
||||
NewCnt is Cnt + 1,
|
||||
assertz(get_used_vars([V|Vars], NewCnt)).
|
||||
add_to_vars(V):-
|
||||
assertz(get_used_vars([V], 1)).
|
||||
assertz(get_used_vars([V], 1)).
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%% depth breadth builtin support %%%%%%%%%%%%%%%%%
|
||||
@ -1310,7 +1340,8 @@ is_state(true).
|
||||
is_state(false).
|
||||
|
||||
nested_trie_to_bdd_trie(A, B, OutputFile, OptimizationLevel, FileParam):-
|
||||
trie_nested_to_depth_breadth_trie(A, B, LL, OptimizationLevel, problog:problog_chktabled),
|
||||
% trie_nested_to_depth_breadth_trie(A, B, LL, OptimizationLevel, problog:problog_chktabled),
|
||||
nested_trie_to_depth_breadth_trie(A, B, LL, OptimizationLevel),
|
||||
(is_label(LL) ->
|
||||
retractall(deref(_,_)),
|
||||
(problog_flag(deref_terms, true) ->
|
||||
@ -1352,16 +1383,24 @@ nested_trie_to_bdd_trie(A, B, OutputFile, OptimizationLevel, FileParam):-
|
||||
;
|
||||
Edges = [LL]
|
||||
),
|
||||
writeln(Edges),
|
||||
tell(FileParam),
|
||||
bdd_vars_script(Edges),
|
||||
simplify_list(Edges, SEdges),
|
||||
bdd_vars_script(SEdges),
|
||||
told,
|
||||
tell(OutputFile),
|
||||
write('@BDD1'), nl,
|
||||
write(1), nl,
|
||||
write(0), nl,
|
||||
write(1), nl,
|
||||
get_var_name(LL, NLL),
|
||||
write('L1 = '),write(NLL),nl,
|
||||
(LL = not(_) ->
|
||||
write('L1 = ~')
|
||||
;
|
||||
write('L1 = ')
|
||||
),
|
||||
simplify(LL, FLL),
|
||||
get_var_name(FLL, NLL),
|
||||
write(NLL),nl,
|
||||
write('L1'), nl,
|
||||
told
|
||||
).
|
||||
@ -1792,7 +1831,6 @@ seperate([H|T], Labels, [H|Vars]):-
|
||||
|
||||
ptree_decomposition(Trie, BDDFileName, VarFileName) :-
|
||||
tmpnam(TmpFile1),
|
||||
tmpnam(TmpFile2),
|
||||
nb_setval(next_inter_step, 1),
|
||||
variables_in_dbtrie(Trie, T),
|
||||
length(T, VarCnt),
|
||||
@ -1815,16 +1853,8 @@ ptree_decomposition(Trie, BDDFileName, VarFileName) :-
|
||||
write('L1'), nl
|
||||
),
|
||||
told,
|
||||
tell(TmpFile2),
|
||||
write('@BDD1'),nl,
|
||||
write(VarCnt),nl,
|
||||
write('0'),nl,
|
||||
write(LCnt),nl,
|
||||
told,
|
||||
atomic_concat(['cat ', TmpFile2, ' ', TmpFile1, ' > ', BDDFileName], CMD),
|
||||
shell(CMD),
|
||||
delete_file(TmpFile1),
|
||||
delete_file(TmpFile2).
|
||||
create_bdd_file_with_header(BDDFileName,VarCnt,LCnt,TmpFile1),
|
||||
delete_file_silent(TmpFile1).
|
||||
|
||||
get_next_inter_step(I):-
|
||||
nb_getval(next_inter_step, I),
|
||||
@ -2012,3 +2042,22 @@ mark_deref(DB_Trie):-
|
||||
mark_deref(_).
|
||||
|
||||
% end of Theo
|
||||
|
||||
create_bdd_file_with_header(BDD_File_Name,VarCount,IntermediateSteps,TmpFile) :-
|
||||
open(BDD_File_Name,write,H),
|
||||
% this is the header of the BDD script for problogbdd
|
||||
format(H, '@BDD1~n~q~n0~n~q~n',[VarCount,IntermediateSteps]),
|
||||
|
||||
% append the content of the file TmpFile
|
||||
open(TmpFile,read,H2),
|
||||
|
||||
(
|
||||
repeat,
|
||||
get_byte(H2,C),
|
||||
put_byte(H,C),
|
||||
at_end_of_stream(H2),
|
||||
!
|
||||
),
|
||||
close(H2),
|
||||
|
||||
close(H).
|
257
packages/ProbLog/problog/utils.yap
Normal file
257
packages/ProbLog/problog/utils.yap
Normal file
@ -0,0 +1,257 @@
|
||||
%%% -*- Mode: Prolog; -*-
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-10-20 18:06:47 +0200 (Wed, 20 Oct 2010) $
|
||||
% $Revision: 4969 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
%
|
||||
% ProbLog was developed at Katholieke Universiteit Leuven
|
||||
%
|
||||
% Copyright 2008, 2009, 2010
|
||||
% Katholieke Universiteit Leuven
|
||||
%
|
||||
% Main authors of this file:
|
||||
% Bernd Gutmann
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% Artistic License 2.0
|
||||
%
|
||||
% Copyright (c) 2000-2006, The Perl Foundation.
|
||||
%
|
||||
% Everyone is permitted to copy and distribute verbatim copies of this
|
||||
% license document, but changing it is not allowed. Preamble
|
||||
%
|
||||
% This license establishes the terms under which a given free software
|
||||
% Package may be copied, modified, distributed, and/or
|
||||
% redistributed. The intent is that the Copyright Holder maintains some
|
||||
% artistic control over the development of that Package while still
|
||||
% keeping the Package available as open source and free software.
|
||||
%
|
||||
% You are always permitted to make arrangements wholly outside of this
|
||||
% license directly with the Copyright Holder of a given Package. If the
|
||||
% terms of this license do not permit the full use that you propose to
|
||||
% make of the Package, you should contact the Copyright Holder and seek
|
||||
% a different licensing arrangement. Definitions
|
||||
%
|
||||
% "Copyright Holder" means the individual(s) or organization(s) named in
|
||||
% the copyright notice for the entire Package.
|
||||
%
|
||||
% "Contributor" means any party that has contributed code or other
|
||||
% material to the Package, in accordance with the Copyright Holder's
|
||||
% procedures.
|
||||
%
|
||||
% "You" and "your" means any person who would like to copy, distribute,
|
||||
% or modify the Package.
|
||||
%
|
||||
% "Package" means the collection of files distributed by the Copyright
|
||||
% Holder, and derivatives of that collection and/or of those files. A
|
||||
% given Package may consist of either the Standard Version, or a
|
||||
% Modified Version.
|
||||
%
|
||||
% "Distribute" means providing a copy of the Package or making it
|
||||
% accessible to anyone else, or in the case of a company or
|
||||
% organization, to others outside of your company or organization.
|
||||
%
|
||||
% "Distributor Fee" means any fee that you charge for Distributing this
|
||||
% Package or providing support for this Package to another party. It
|
||||
% does not mean licensing fees.
|
||||
%
|
||||
% "Standard Version" refers to the Package if it has not been modified,
|
||||
% or has been modified only in ways explicitly requested by the
|
||||
% Copyright Holder.
|
||||
%
|
||||
% "Modified Version" means the Package, if it has been changed, and such
|
||||
% changes were not explicitly requested by the Copyright Holder.
|
||||
%
|
||||
% "Original License" means this Artistic License as Distributed with the
|
||||
% Standard Version of the Package, in its current version or as it may
|
||||
% be modified by The Perl Foundation in the future.
|
||||
%
|
||||
% "Source" form means the source code, documentation source, and
|
||||
% configuration files for the Package.
|
||||
%
|
||||
% "Compiled" form means the compiled bytecode, object code, binary, or
|
||||
% any other form resulting from mechanical transformation or translation
|
||||
% of the Source form.
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% Permission for Use and Modification Without Distribution
|
||||
%
|
||||
% (1) You are permitted to use the Standard Version and create and use
|
||||
% Modified Versions for any purpose without restriction, provided that
|
||||
% you do not Distribute the Modified Version.
|
||||
%
|
||||
% Permissions for Redistribution of the Standard Version
|
||||
%
|
||||
% (2) You may Distribute verbatim copies of the Source form of the
|
||||
% Standard Version of this Package in any medium without restriction,
|
||||
% either gratis or for a Distributor Fee, provided that you duplicate
|
||||
% all of the original copyright notices and associated disclaimers. At
|
||||
% your discretion, such verbatim copies may or may not include a
|
||||
% Compiled form of the Package.
|
||||
%
|
||||
% (3) You may apply any bug fixes, portability changes, and other
|
||||
% modifications made available from the Copyright Holder. The resulting
|
||||
% Package will still be considered the Standard Version, and as such
|
||||
% will be subject to the Original License.
|
||||
%
|
||||
% Distribution of Modified Versions of the Package as Source
|
||||
%
|
||||
% (4) You may Distribute your Modified Version as Source (either gratis
|
||||
% or for a Distributor Fee, and with or without a Compiled form of the
|
||||
% Modified Version) provided that you clearly document how it differs
|
||||
% from the Standard Version, including, but not limited to, documenting
|
||||
% any non-standard features, executables, or modules, and provided that
|
||||
% you do at least ONE of the following:
|
||||
%
|
||||
% (a) make the Modified Version available to the Copyright Holder of the
|
||||
% Standard Version, under the Original License, so that the Copyright
|
||||
% Holder may include your modifications in the Standard Version. (b)
|
||||
% ensure that installation of your Modified Version does not prevent the
|
||||
% user installing or running the Standard Version. In addition, the
|
||||
% modified Version must bear a name that is different from the name of
|
||||
% the Standard Version. (c) allow anyone who receives a copy of the
|
||||
% Modified Version to make the Source form of the Modified Version
|
||||
% available to others under (i) the Original License or (ii) a license
|
||||
% that permits the licensee to freely copy, modify and redistribute the
|
||||
% Modified Version using the same licensing terms that apply to the copy
|
||||
% that the licensee received, and requires that the Source form of the
|
||||
% Modified Version, and of any works derived from it, be made freely
|
||||
% available in that license fees are prohibited but Distributor Fees are
|
||||
% allowed.
|
||||
%
|
||||
% Distribution of Compiled Forms of the Standard Version or
|
||||
% Modified Versions without the Source
|
||||
%
|
||||
% (5) You may Distribute Compiled forms of the Standard Version without
|
||||
% the Source, provided that you include complete instructions on how to
|
||||
% get the Source of the Standard Version. Such instructions must be
|
||||
% valid at the time of your distribution. If these instructions, at any
|
||||
% time while you are carrying out such distribution, become invalid, you
|
||||
% must provide new instructions on demand or cease further
|
||||
% distribution. If you provide valid instructions or cease distribution
|
||||
% within thirty days after you become aware that the instructions are
|
||||
% invalid, then you do not forfeit any of your rights under this
|
||||
% license.
|
||||
%
|
||||
% (6) You may Distribute a Modified Version in Compiled form without the
|
||||
% Source, provided that you comply with Section 4 with respect to the
|
||||
% Source of the Modified Version.
|
||||
%
|
||||
% Aggregating or Linking the Package
|
||||
%
|
||||
% (7) You may aggregate the Package (either the Standard Version or
|
||||
% Modified Version) with other packages and Distribute the resulting
|
||||
% aggregation provided that you do not charge a licensing fee for the
|
||||
% Package. Distributor Fees are permitted, and licensing fees for other
|
||||
% components in the aggregation are permitted. The terms of this license
|
||||
% apply to the use and Distribution of the Standard or Modified Versions
|
||||
% as included in the aggregation.
|
||||
%
|
||||
% (8) You are permitted to link Modified and Standard Versions with
|
||||
% other works, to embed the Package in a larger work of your own, or to
|
||||
% build stand-alone binary or bytecode versions of applications that
|
||||
% include the Package, and Distribute the result without restriction,
|
||||
% provided the result does not expose a direct interface to the Package.
|
||||
%
|
||||
% Items That are Not Considered Part of a Modified Version
|
||||
%
|
||||
% (9) Works (including, but not limited to, modules and scripts) that
|
||||
% merely extend or make use of the Package, do not, by themselves, cause
|
||||
% the Package to be a Modified Version. In addition, such works are not
|
||||
% considered parts of the Package itself, and are not subject to the
|
||||
% terms of this license.
|
||||
%
|
||||
% General Provisions
|
||||
%
|
||||
% (10) Any use, modification, and distribution of the Standard or
|
||||
% Modified Versions is governed by this Artistic License. By using,
|
||||
% modifying or distributing the Package, you accept this license. Do not
|
||||
% use, modify, or distribute the Package, if you do not accept this
|
||||
% license.
|
||||
%
|
||||
% (11) If your Modified Version has been derived from a Modified Version
|
||||
% made by someone other than you, you are nevertheless required to
|
||||
% ensure that your Modified Version complies with the requirements of
|
||||
% this license.
|
||||
%
|
||||
% (12) This license does not grant you the right to use any trademark,
|
||||
% service mark, tradename, or logo of the Copyright Holder.
|
||||
%
|
||||
% (13) This license includes the non-exclusive, worldwide,
|
||||
% free-of-charge patent license to make, have made, use, offer to sell,
|
||||
% sell, import and otherwise transfer the Package with respect to any
|
||||
% patent claims licensable by the Copyright Holder that are necessarily
|
||||
% infringed by the Package. If you institute patent litigation
|
||||
% (including a cross-claim or counterclaim) against any party alleging
|
||||
% that the Package constitutes direct or contributory patent
|
||||
% infringement, then this Artistic License to you shall terminate on the
|
||||
% date that such litigation is filed.
|
||||
%
|
||||
% (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT
|
||||
% HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
% WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
% PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT
|
||||
% PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT
|
||||
% HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
% INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
|
||||
% OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
:- module(utils, [delete_file_silent/1,
|
||||
variable_in_term_exactly_once/2,
|
||||
slice_n/4]).
|
||||
|
||||
:- use_module(library(system), [delete_file/1, file_exists/1]).
|
||||
|
||||
%========================================================================
|
||||
%=
|
||||
%=
|
||||
%========================================================================
|
||||
|
||||
delete_file_silent(File) :-
|
||||
file_exists(File),
|
||||
delete_file(File),
|
||||
!.
|
||||
delete_file_silent(_).
|
||||
|
||||
%========================================================================
|
||||
%= Split a list into the first n elements and the tail
|
||||
%= +List +Integer -Prefix -Residuum
|
||||
%========================================================================
|
||||
|
||||
|
||||
slice_n([],_,[],[]) :-
|
||||
!.
|
||||
slice_n([H|T],N,[H|T2],T3) :-
|
||||
N>0,
|
||||
!,
|
||||
N2 is N-1,
|
||||
slice_n(T,N2,T2,T3).
|
||||
slice_n(L,_,[],L).
|
||||
|
||||
%========================================================================
|
||||
%= succeeds if the variable V appears exactly once in the term T
|
||||
%========================================================================
|
||||
variable_in_term_exactly_once(T,V) :-
|
||||
term_variables(T,Vars),
|
||||
var_memberchk_once(Vars,V).
|
||||
|
||||
var_memberchk_once([H|T],V) :-
|
||||
H==V,
|
||||
!,
|
||||
var_memberchk_none(T,V).
|
||||
var_memberchk_once([_|T],V) :-
|
||||
var_memberchk_once(T,V).
|
||||
|
||||
var_memberchk_none([H|T],V) :-
|
||||
H\==V,
|
||||
var_memberchk_none(T,V).
|
||||
var_memberchk_none([],_).
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-09-29 13:24:43 +0200 (Wed, 29 Sep 2010) $
|
||||
% $Revision: 4845 $
|
||||
% $Date: 2010-10-20 18:06:47 +0200 (Wed, 20 Oct 2010) $
|
||||
% $Revision: 4969 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
@ -205,9 +205,7 @@
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
:- module(utils_learning, [empty_bdd_directory/0,
|
||||
empty_output_directory/0,
|
||||
delete_file_silent/1,
|
||||
slice_n/4]).
|
||||
empty_output_directory/0]).
|
||||
|
||||
|
||||
% load library modules
|
||||
@ -217,6 +215,7 @@
|
||||
% load our own modules
|
||||
:- use_module(os).
|
||||
:- use_module(flags).
|
||||
:- use_module(utils).
|
||||
|
||||
%========================================================================
|
||||
%=
|
||||
@ -246,19 +245,8 @@ empty_output_directory :-
|
||||
concat_path_with_filename(Path,'log.dat',F1),
|
||||
concat_path_with_filename(Path,'out.dat',F2),
|
||||
|
||||
(
|
||||
file_exists(F1)
|
||||
->
|
||||
delete_file_silent(F1);
|
||||
true
|
||||
),
|
||||
|
||||
(
|
||||
file_exists(F2)
|
||||
->
|
||||
delete_file_silent(F2);
|
||||
true
|
||||
),
|
||||
delete_file_silent(F1),
|
||||
delete_file_silent(F2),
|
||||
|
||||
atom_codes('values_', PF1), % 'values_*_q_*.dat'
|
||||
atom_codes('factprobs_', PF2), % 'factprobs_*.pl'
|
||||
@ -272,16 +260,7 @@ empty_output_directory :-
|
||||
empty_output_directory :-
|
||||
throw(error(problog_flag_does_not_exist(output_directory))).
|
||||
|
||||
%========================================================================
|
||||
%=
|
||||
%=
|
||||
%========================================================================
|
||||
|
||||
delete_file_silent(File) :-
|
||||
file_exists(File),
|
||||
delete_file(File),
|
||||
!.
|
||||
delete_file_silent(_).
|
||||
|
||||
%========================================================================
|
||||
%=
|
||||
@ -304,17 +283,3 @@ delete_files_with_matching_prefix([Name|T],Path,Prefixes) :-
|
||||
|
||||
delete_files_with_matching_prefix(T,Path,Prefixes).
|
||||
|
||||
%========================================================================
|
||||
%= Split a list into the first n elements and the tail
|
||||
%= +List +Integer -Prefix -Residuum
|
||||
%========================================================================
|
||||
|
||||
|
||||
slice_n([],_,[],[]) :-
|
||||
!.
|
||||
slice_n([H|T],N,[H|T2],T3) :-
|
||||
N>0,
|
||||
!,
|
||||
N2 is N-1,
|
||||
slice_n(T,N2,T2,T3).
|
||||
slice_n(L,_,[],L).
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-10-05 16:52:13 +0200 (Tue, 05 Oct 2010) $
|
||||
% $Revision: 4869 $
|
||||
% $Date: 2010-10-20 18:06:47 +0200 (Wed, 20 Oct 2010) $
|
||||
% $Revision: 4969 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
@ -225,6 +225,7 @@
|
||||
:- use_module('problog/os').
|
||||
:- use_module('problog/print_learning').
|
||||
:- use_module('problog/utils_learning').
|
||||
:- use_module('problog/utils').
|
||||
|
||||
% used to indicate the state of the system
|
||||
:- dynamic(values_correct/0).
|
||||
@ -549,11 +550,12 @@ init_learning :-
|
||||
!.
|
||||
init_learning :-
|
||||
check_examples,
|
||||
|
||||
|
||||
empty_output_directory,
|
||||
logger_write_header,
|
||||
|
||||
format_learning(1,'Initializing everything~n',[]),
|
||||
empty_output_directory,
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Delete the BDDs from the previous run if they should
|
||||
@ -1031,6 +1033,7 @@ mse_testset :-
|
||||
(
|
||||
format_learning(2,'MSE_Test ',[]),
|
||||
update_values,
|
||||
bb_put(llh_test_queries,0.0),
|
||||
findall(SquaredError,
|
||||
(user:test_example(QueryID,_Query,QueryProb,Type),
|
||||
once(update_query(QueryID,'+',probability)),
|
||||
@ -1041,7 +1044,10 @@ mse_testset :-
|
||||
->
|
||||
SquaredError is (CurrentProb-QueryProb)**2;
|
||||
SquaredError = 0.0
|
||||
)
|
||||
),
|
||||
bb_get(llh_test_queries,Old_LLH_Test_Queries),
|
||||
New_LLH_Test_Queries is Old_LLH_Test_Queries+log(CurrentProb),
|
||||
bb_put(llh_test_queries,New_LLH_Test_Queries)
|
||||
),
|
||||
AllSquaredErrors),
|
||||
|
||||
@ -1050,10 +1056,12 @@ mse_testset :-
|
||||
min_list(AllSquaredErrors,MinError),
|
||||
max_list(AllSquaredErrors,MaxError),
|
||||
MSE is SumAllSquaredErrors/Length,
|
||||
bb_delete(llh_test_queries,LLH_Test_Queries),
|
||||
|
||||
logger_set_variable(mse_testset,MSE),
|
||||
logger_set_variable(mse_min_testset,MinError),
|
||||
logger_set_variable(mse_max_testset,MaxError),
|
||||
logger_set_variable(llh_test_queries,LLH_Test_Queries),
|
||||
format_learning(2,' (~8f)~n',[MSE])
|
||||
); true
|
||||
).
|
||||
@ -1232,6 +1240,7 @@ gradient_descent :-
|
||||
bb_put(mse_train_sum, 0.0),
|
||||
bb_put(mse_train_min, 0.0),
|
||||
bb_put(mse_train_max, 0.0),
|
||||
bb_put(llh_training_queries, 0.0),
|
||||
|
||||
problog_flag(alpha,Alpha),
|
||||
logger_set_variable(alpha,Alpha),
|
||||
@ -1267,12 +1276,15 @@ gradient_descent :-
|
||||
bb_get(mse_train_sum,Old_MSE_Train_Sum),
|
||||
bb_get(mse_train_min,Old_MSE_Train_Min),
|
||||
bb_get(mse_train_max,Old_MSE_Train_Max),
|
||||
bb_get(llh_training_queries,Old_LLH_Training_Queries),
|
||||
New_MSE_Train_Sum is Old_MSE_Train_Sum+Squared_Error,
|
||||
New_MSE_Train_Min is min(Old_MSE_Train_Min,Squared_Error),
|
||||
New_MSE_Train_Max is max(Old_MSE_Train_Max,Squared_Error),
|
||||
New_LLH_Training_Queries is Old_LLH_Training_Queries+log(BDDProb),
|
||||
bb_put(mse_train_sum,New_MSE_Train_Sum),
|
||||
bb_put(mse_train_min,New_MSE_Train_Min),
|
||||
bb_put(mse_train_max,New_MSE_Train_Max),
|
||||
bb_put(llh_training_queries,New_LLH_Training_Queries),
|
||||
|
||||
|
||||
|
||||
@ -1368,11 +1380,13 @@ gradient_descent :-
|
||||
bb_delete(mse_train_sum,MSE_Train_Sum),
|
||||
bb_delete(mse_train_min,MSE_Train_Min),
|
||||
bb_delete(mse_train_max,MSE_Train_Max),
|
||||
bb_delete(llh_training_queries,LLH_Training_Queries),
|
||||
MSE is MSE_Train_Sum/Example_Count,
|
||||
|
||||
logger_set_variable(mse_trainingset,MSE),
|
||||
logger_set_variable(mse_min_trainingset,MSE_Train_Min),
|
||||
logger_set_variable(mse_max_trainingset,MSE_Train_Max),
|
||||
logger_set_variable(llh_training_queries,LLH_Training_Queries),
|
||||
|
||||
format_learning(2,'~n',[]),
|
||||
|
||||
@ -1670,7 +1684,9 @@ init_logger :-
|
||||
logger_define_variable(ground_truth_mindiff,float),
|
||||
logger_define_variable(ground_truth_maxdiff,float),
|
||||
logger_define_variable(learning_rate,float),
|
||||
logger_define_variable(alpha,float).
|
||||
logger_define_variable(alpha,float),
|
||||
logger_define_variable(llh_training_queries,float),
|
||||
logger_define_variable(llh_test_queries,float).
|
||||
|
||||
:- initialization(init_flags).
|
||||
:- initialization(init_logger).
|
||||
|
@ -30,8 +30,9 @@ PL=@INSTALL_ENV@ $(DESTDIR)$(BINDIR)/yap $(DESTDIR)$(YAPLIBDIR)/startup.yss
|
||||
LN_S=@LN_S@
|
||||
#
|
||||
#
|
||||
DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1
|
||||
CC=@CC@
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -D_YAP_NOT_INSTALLED_=1 -DHAVE_CONFIG_H=1 -I$(srcdir) -I../.. -I$(srcdir)/../../include -I. -I$(srcdir)/maildrop/rfc2045 -I$(srcdir)/maildrop/rfc822 @CPPFLAGS@
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include -I. -I$(srcdir)/maildrop/rfc2045 -I$(srcdir)/maildrop/rfc822 @CPPFLAGS@
|
||||
MKINDEX=true
|
||||
NETLIBS=@CLIB_NETLIBS@
|
||||
CRYPTLIBS=@CLIB_CRYPTLIBS@
|
||||
|
@ -39,7 +39,7 @@
|
||||
/* Include files where endian defines and byteswap functions may reside */
|
||||
#if defined(__sun__)
|
||||
# include <sys/isa_defs.h>
|
||||
#elif defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined( __NetBSD__ )
|
||||
#elif defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined( __NetBSD__ ) || defined( __DragonFly__ )
|
||||
# include <sys/endian.h>
|
||||
#elif defined( BSD ) && ( BSD >= 199103 ) || defined( __APPLE__ ) || \
|
||||
defined( __CYGWIN32__ ) || defined( __DJGPP__ ) || defined( __osf__ )
|
||||
|
@ -21,6 +21,7 @@ YAPLIBDIR=${exec_prefix}/lib/Yap
|
||||
SHAREDIR=$(ROOTDIR)/share/Yap
|
||||
#
|
||||
#
|
||||
DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1
|
||||
CC=@CC@
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I$(srcdir)/../../include @CPPFLAGS@
|
||||
#
|
||||
|
@ -27,8 +27,9 @@ EXDIR=$(YAPLIBDIR)/examples/http
|
||||
LN_S=@LN_S@
|
||||
#
|
||||
#
|
||||
DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1
|
||||
CC=@CC@
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -D_YAP_NOT_INSTALLED_=1 -I$(srcdir) -I../.. -I$(srcdir)/../../include @CPPFLAGS@
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include @CPPFLAGS@
|
||||
MKINDEX=true
|
||||
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit f11e3d43683f708fe7011dff7cd8f9b495cfda17
|
||||
Subproject commit 73e4e086d06c54210100f0faaeccbea276c707eb
|
@ -36,8 +36,9 @@ EXDIR=$(YAPLIBDIR)/examples/http
|
||||
LN_S=@LN_S@
|
||||
#
|
||||
#
|
||||
DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1
|
||||
CC=@CC@
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -D_YAP_NOT_INSTALLED_=1 -I$(srcdir) -I../.. -I$(srcdir)/../../include @CPPFLAGS@
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include @CPPFLAGS@
|
||||
MKINDEX=true
|
||||
|
||||
|
||||
|
@ -28,8 +28,9 @@ EXDIR=$(CHRDIR)/examples/chr
|
||||
LN_S=@LN_S@
|
||||
#
|
||||
#
|
||||
DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1
|
||||
CC=@CC@
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -D_YAP_NOT_INSTALLED_=1 -I$(srcdir) -I../.. -I$(srcdir)/../../include @CPPFLAGS@
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include @CPPFLAGS@
|
||||
MKINDEX=true
|
||||
|
||||
LD=$(CC)
|
||||
|
@ -19,9 +19,10 @@ LIBDIR=@libdir@
|
||||
YAPLIBDIR=@libdir@/Yap
|
||||
#
|
||||
#
|
||||
DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1
|
||||
CC=@CC@
|
||||
CXX=@CXX@
|
||||
CXXFLAGS= @SHLIB_CXXFLAGS@ $(YAP_EXTRAS) $(DEFS) -D_YAP_NOT_INSTALLED_=1 -I$(srcdir) -I../../.. -I$(srcdir)/../../../include @CPPFLAGS@
|
||||
CXXFLAGS= @SHLIB_CXXFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../../.. -I$(srcdir)/../../../include @CPPFLAGS@
|
||||
#
|
||||
#
|
||||
# You shouldn't need to change what follows.
|
||||
|
@ -18,8 +18,9 @@ LIBDIR=@libdir@
|
||||
YAPLIBDIR=@libdir@/Yap
|
||||
#
|
||||
#
|
||||
DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1
|
||||
CC=@CC@
|
||||
CFLAGS= @SHLIB_CFLAGS@ -D_YAP_NOT_INSTALLED_=1 $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include -I$(srcdir)/../PLStream
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include -I$(srcdir)/../PLStream
|
||||
#
|
||||
#
|
||||
# You shouldn't need to change what follows.
|
||||
|
@ -25,7 +25,8 @@ AR=@AR@
|
||||
RANLIB=@RANLIB@
|
||||
ifeq (@PROLOG_SYSTEM@,yap)
|
||||
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -D_YAP_NOT_INSTALLED_=1 -I$(srcdir) -I../.. -I$(srcdir)/../../include @CPPFLAGS@ @JAVAINCPATH@
|
||||
DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../../.. -I$(srcdir)/../../include @CPPFLAGS@ @JAVAINCPATH@
|
||||
|
||||
else
|
||||
|
||||
|
@ -33,8 +33,9 @@ EXDIR=$(YAPLIBDIR)/examples/http
|
||||
LN_S=@LN_S@
|
||||
#
|
||||
#
|
||||
DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1
|
||||
CC=@CC@
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -D_YAP_NOT_INSTALLED_=1 -I$(srcdir) -I../.. -I$(srcdir)/../../include @CPPFLAGS@
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include @CPPFLAGS@
|
||||
MKINDEX=true
|
||||
LIBS=@ZLIBS@
|
||||
|
||||
|
@ -354,6 +354,8 @@ domain_error(stream, Opt) --> !,
|
||||
[ '~w is not a stream' - [Opt] ].
|
||||
domain_error(stream_or_alias, Opt) --> !,
|
||||
[ '~w is not a stream (or alias)' - [Opt] ].
|
||||
domain_error(stream_encoding, Opt) --> !,
|
||||
[ '~w is not a supported stream encoding' - [Opt] ].
|
||||
domain_error(stream_position, Opt) --> !,
|
||||
[ '~w is not a stream position' - [Opt] ].
|
||||
domain_error(stream_property, Opt) --> !,
|
||||
|
@ -877,8 +877,9 @@ predicate_statistics(P,NCls,Sz,ISz) :-
|
||||
'$predicate_statistics'(P,M,NCls,Sz,ISz) :-
|
||||
'$static_pred_statistics'(P,M,NCls,Sz,ISz).
|
||||
|
||||
predicate_erased_statistics(V,NCls,Sz,ISz) :- var(V), !,
|
||||
'$do_error'(instantiation_error,predicate_statistics(V,NCls,Sz,ISz)).
|
||||
predicate_erased_statistics(P,NCls,Sz,ISz) :-
|
||||
current_predicate(_,P),
|
||||
predicate_erased_statistics(P,NCls,Sz,ISz).
|
||||
predicate_erased_statistics(M:P,NCls,Sz,ISz) :- !,
|
||||
'$predicate_erased_statistics'(M:P,NCls,Sz,_,ISz).
|
||||
predicate_erased_statistics(P,NCls,Sz,ISz) :-
|
||||
|
@ -15,6 +15,12 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
|
||||
% hook predicate, taken from SWI-Prolog, for converting possibly explicitly-
|
||||
% qualified callable terms into an atom that can be used as a label for
|
||||
% describing a predicate; used e.g. on the tick profiler defined below
|
||||
:- multifile(user:prolog_predicate_name/2).
|
||||
|
||||
:- meta_predicate profile_data(:,+,-).
|
||||
|
||||
profile_data(M:D, Parm, Data) :-!,
|
||||
@ -58,16 +64,11 @@ profile_reset :-
|
||||
fail.
|
||||
profile_reset.
|
||||
|
||||
showprofres :-
|
||||
'$proftype'(offline), !,
|
||||
'$offline_showprofres'.
|
||||
showprofres :-
|
||||
showprofres(-1).
|
||||
|
||||
showprofres(A) :-
|
||||
'$proftype'(offline), !,
|
||||
'$offline_showprofres'(A).
|
||||
showprofres(A) :-
|
||||
('$proftype'(offline) -> '$offline_showprofres' ; true),
|
||||
('$profison' -> profoff, Stop = true ; Stop = false),
|
||||
'$profglobs'(Tot,GCs,HGrows,SGrows,Mallocs,ProfOns),
|
||||
% root node has no useful info.
|
||||
@ -125,9 +126,19 @@ showprofres(A) :-
|
||||
'$display_preds'([NSum-P|Ps], Tot, SoFar, I, N) :-
|
||||
Sum is -NSum,
|
||||
Perc is (100*Sum)/Tot,
|
||||
Next is SoFar+Sum,
|
||||
Next is SoFar+Sum,
|
||||
NextP is (100*Next)/Tot,
|
||||
format(user_error,'~|~t~d.~7+ ~|~w:~t~d~50+ (~|~t~2f~6+%) |~|~t~2f~6+%|~n',[I,P,Sum,Perc,NextP]),
|
||||
( ( P = M:F/A ->
|
||||
G = M:H
|
||||
; P = F/A,
|
||||
G = H
|
||||
),
|
||||
functor(H, F, A),
|
||||
user:prolog_predicate_name(G, PL) ->
|
||||
true
|
||||
; PL = P
|
||||
),
|
||||
format(user_error,'~|~t~d.~7+ ~|~w:~t~d~50+ (~|~t~2f~6+%) |~|~t~2f~6+%|~n',[I,PL,Sum,Perc,NextP]),
|
||||
I1 is I+1,
|
||||
'$display_preds'(Ps,Tot,Next,I1, N).
|
||||
|
||||
|
Reference in New Issue
Block a user