more fixes to call_counter: try to keep on counting system builtins.
This commit is contained in:
parent
50f7a80546
commit
d47560342c
36
C/absmi.c
36
C/absmi.c
@ -968,7 +968,16 @@ Yap_absmi(int inp)
|
|||||||
* Profiled try - retry - trust instructions *
|
* Profiled try - retry - trust instructions *
|
||||||
*****************************************************************/
|
*****************************************************************/
|
||||||
|
|
||||||
/* profiled_retry Label,NArgs */
|
/* profiled_enter_me Pred */
|
||||||
|
Op(enter_profiling, p);
|
||||||
|
LOCK(PREG->u.p.p->StatisticsForPred.lock);
|
||||||
|
PREG->u.p.p->StatisticsForPred.NOfEntries++;
|
||||||
|
UNLOCK(PREG->u.p.p->StatisticsForPred.lock);
|
||||||
|
PREG = NEXTOP(PREG, p);
|
||||||
|
GONext();
|
||||||
|
ENDOp();
|
||||||
|
|
||||||
|
/* profiled_retry Label,NArgs */
|
||||||
Op(retry_profiled, p);
|
Op(retry_profiled, p);
|
||||||
LOCK(PREG->u.p.p->StatisticsForPred.lock);
|
LOCK(PREG->u.p.p->StatisticsForPred.lock);
|
||||||
PREG->u.p.p->StatisticsForPred.NOfRetries++;
|
PREG->u.p.p->StatisticsForPred.NOfRetries++;
|
||||||
@ -1170,6 +1179,29 @@ Yap_absmi(int inp)
|
|||||||
* Call count instructions *
|
* Call count instructions *
|
||||||
*****************************************************************/
|
*****************************************************************/
|
||||||
|
|
||||||
|
/* count_enter_me Label,NArgs */
|
||||||
|
Op(count_call, p);
|
||||||
|
LOCK(PREG->u.p.p->StatisticsForPred.lock);
|
||||||
|
PREG->u.p.p->StatisticsForPred.NOfEntries++;
|
||||||
|
UNLOCK(PREG->u.p.p->StatisticsForPred.lock);
|
||||||
|
ReductionsCounter--;
|
||||||
|
if (ReductionsCounter == 0 && ReductionsCounterOn) {
|
||||||
|
saveregs();
|
||||||
|
Yap_Error(CALL_COUNTER_UNDERFLOW,TermNil,"");
|
||||||
|
setregs();
|
||||||
|
JMPNext();
|
||||||
|
}
|
||||||
|
PredEntriesCounter--;
|
||||||
|
if (PredEntriesCounter == 0 && PredEntriesCounterOn) {
|
||||||
|
saveregs();
|
||||||
|
Yap_Error(PRED_ENTRY_COUNTER_UNDERFLOW,TermNil,"");
|
||||||
|
setregs();
|
||||||
|
JMPNext();
|
||||||
|
}
|
||||||
|
PREG = NEXTOP(PREG, p);
|
||||||
|
GONext();
|
||||||
|
ENDOp();
|
||||||
|
|
||||||
/* count_retry Label,NArgs */
|
/* count_retry Label,NArgs */
|
||||||
Op(count_retry, p);
|
Op(count_retry, p);
|
||||||
LOCK(PREG->u.p.p->StatisticsForPred.lock);
|
LOCK(PREG->u.p.p->StatisticsForPred.lock);
|
||||||
@ -8019,8 +8051,8 @@ Yap_absmi(int inp)
|
|||||||
UNLOCK(pe->StatisticsForPred.lock);
|
UNLOCK(pe->StatisticsForPred.lock);
|
||||||
if (!(pe->PredFlags & SpiedPredFlag)) {
|
if (!(pe->PredFlags & SpiedPredFlag)) {
|
||||||
PREG = pe->cs.p_code.TrueCodeOfPred;
|
PREG = pe->cs.p_code.TrueCodeOfPred;
|
||||||
|
JMPNext();
|
||||||
}
|
}
|
||||||
JMPNext();
|
|
||||||
}
|
}
|
||||||
if (!DebugOn) {
|
if (!DebugOn) {
|
||||||
PREG = pe->cs.p_code.TrueCodeOfPred;
|
PREG = pe->cs.p_code.TrueCodeOfPred;
|
||||||
|
18
C/amasm.c
18
C/amasm.c
@ -3664,9 +3664,27 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
|||||||
case f_0_op:
|
case f_0_op:
|
||||||
code_p = a_f2(TRUE, &cmp_info, code_p, pass_no, cip);
|
code_p = a_f2(TRUE, &cmp_info, code_p, pass_no, cip);
|
||||||
break;
|
break;
|
||||||
|
case enter_profiling_op:
|
||||||
|
{
|
||||||
|
PredEntry *pe = (PredEntry *)(cip->cpc->rnd1);
|
||||||
|
if ((pe->PredFlags & (CPredFlag|UserCPredFlag|AsmPredFlag)) ||
|
||||||
|
!pe->ModuleOfPred) {
|
||||||
|
code_p = a_pl(_enter_profiling, pe, code_p, pass_no);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case retry_profiled_op:
|
case retry_profiled_op:
|
||||||
code_p = a_pl(_retry_profiled, (PredEntry *)(cip->cpc->rnd1), code_p, pass_no);
|
code_p = a_pl(_retry_profiled, (PredEntry *)(cip->cpc->rnd1), code_p, pass_no);
|
||||||
break;
|
break;
|
||||||
|
case count_call_op:
|
||||||
|
{
|
||||||
|
PredEntry *pe = (PredEntry *)(cip->cpc->rnd1);
|
||||||
|
if ((pe->PredFlags & (CPredFlag|UserCPredFlag|AsmPredFlag)) ||
|
||||||
|
!pe->ModuleOfPred) {
|
||||||
|
code_p = a_pl(_count_call, (PredEntry *)(cip->cpc->rnd1), code_p, pass_no);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case count_retry_op:
|
case count_retry_op:
|
||||||
code_p = a_pl(_count_retry, (PredEntry *)(cip->cpc->rnd1), code_p, pass_no);
|
code_p = a_pl(_count_retry, (PredEntry *)(cip->cpc->rnd1), code_p, pass_no);
|
||||||
break;
|
break;
|
||||||
|
24
C/cdmgr.c
24
C/cdmgr.c
@ -1587,6 +1587,10 @@ retract_all(PredEntry *p, int in_use)
|
|||||||
p->PredFlags |= ProfiledPredFlag;
|
p->PredFlags |= ProfiledPredFlag;
|
||||||
} else
|
} else
|
||||||
p->PredFlags &= ~ProfiledPredFlag;
|
p->PredFlags &= ~ProfiledPredFlag;
|
||||||
|
if (CALL_COUNTING) {
|
||||||
|
p->PredFlags |= CountPredFlag;
|
||||||
|
} else
|
||||||
|
p->PredFlags &= ~CountPredFlag;
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
if (SEQUENTIAL_IS_DEFAULT) {
|
if (SEQUENTIAL_IS_DEFAULT) {
|
||||||
p->PredFlags |= SequentialPredFlag;
|
p->PredFlags |= SequentialPredFlag;
|
||||||
@ -1636,8 +1640,16 @@ add_first_static(PredEntry *p, yamop *cp, int spy_flag)
|
|||||||
p->StatisticsForPred.NOfRetries = 0;
|
p->StatisticsForPred.NOfRetries = 0;
|
||||||
if (PROFILING) {
|
if (PROFILING) {
|
||||||
p->PredFlags |= ProfiledPredFlag;
|
p->PredFlags |= ProfiledPredFlag;
|
||||||
} else
|
spy_flag = TRUE;
|
||||||
|
} else {
|
||||||
p->PredFlags &= ~ProfiledPredFlag;
|
p->PredFlags &= ~ProfiledPredFlag;
|
||||||
|
}
|
||||||
|
if (CALL_COUNTING) {
|
||||||
|
p->PredFlags |= CountPredFlag;
|
||||||
|
spy_flag = TRUE;
|
||||||
|
} else {
|
||||||
|
p->PredFlags &= ~CountPredFlag;
|
||||||
|
}
|
||||||
if (spy_flag) {
|
if (spy_flag) {
|
||||||
p->OpcodeOfPred = Yap_opcode(_spy_pred);
|
p->OpcodeOfPred = Yap_opcode(_spy_pred);
|
||||||
p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred));
|
p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred));
|
||||||
@ -1666,8 +1678,16 @@ add_first_dynamic(PredEntry *p, yamop *cp, int spy_flag)
|
|||||||
p->StatisticsForPred.NOfRetries = 0;
|
p->StatisticsForPred.NOfRetries = 0;
|
||||||
if (PROFILING) {
|
if (PROFILING) {
|
||||||
p->PredFlags |= ProfiledPredFlag;
|
p->PredFlags |= ProfiledPredFlag;
|
||||||
} else
|
spy_flag = TRUE;
|
||||||
|
} else {
|
||||||
p->PredFlags &= ~ProfiledPredFlag;
|
p->PredFlags &= ~ProfiledPredFlag;
|
||||||
|
}
|
||||||
|
if (CALL_COUNTING) {
|
||||||
|
p->PredFlags |= CountPredFlag;
|
||||||
|
spy_flag = TRUE;
|
||||||
|
} else {
|
||||||
|
p->PredFlags &= ~CountPredFlag;
|
||||||
|
}
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
p->PredFlags |= SequentialPredFlag;
|
p->PredFlags |= SequentialPredFlag;
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
33
C/compiler.c
33
C/compiler.c
@ -1090,6 +1090,10 @@ c_bifun(Int Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler_struct
|
|||||||
save_machine_regs();
|
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);
|
||||||
|
else if (call_counting)
|
||||||
|
Yap_emit(count_call_op, (CELL)RepPredProp(p0), Zero, &cglobs->cint);
|
||||||
c_args(Goal, 0, cglobs);
|
c_args(Goal, 0, cglobs);
|
||||||
Yap_emit(safe_call_op, (CELL)p0 , Zero, &cglobs->cint);
|
Yap_emit(safe_call_op, (CELL)p0 , Zero, &cglobs->cint);
|
||||||
Yap_emit(empty_call_op, Zero, Zero, &cglobs->cint);
|
Yap_emit(empty_call_op, Zero, Zero, &cglobs->cint);
|
||||||
@ -1325,6 +1329,10 @@ c_functor(Term Goal, Term mod, compiler_struct *cglobs)
|
|||||||
save_machine_regs();
|
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);
|
||||||
|
else if (call_counting)
|
||||||
|
Yap_emit(count_call_op, (CELL)RepPredProp(p0), Zero, &cglobs->cint);
|
||||||
c_args(Goal, 0, cglobs);
|
c_args(Goal, 0, cglobs);
|
||||||
Yap_emit(safe_call_op, (CELL)p0 , Zero, &cglobs->cint);
|
Yap_emit(safe_call_op, (CELL)p0 , Zero, &cglobs->cint);
|
||||||
Yap_emit(empty_call_op, Zero, Zero, &cglobs->cint);
|
Yap_emit(empty_call_op, Zero, Zero, &cglobs->cint);
|
||||||
@ -1461,6 +1469,10 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (atom == AtomCut) {
|
else if (atom == AtomCut) {
|
||||||
|
if (profiling)
|
||||||
|
Yap_emit(enter_profiling_op, (CELL)RepPredProp(PredPropByAtom(AtomCut,0)), Zero, &cglobs->cint);
|
||||||
|
else if (call_counting)
|
||||||
|
Yap_emit(count_call_op, (CELL)RepPredProp(PredPropByAtom(AtomCut,0)), Zero, &cglobs->cint);
|
||||||
if (cglobs->onlast) {
|
if (cglobs->onlast) {
|
||||||
/* never a problem here with a -> b, !, c ; d */
|
/* never a problem here with a -> b, !, c ; d */
|
||||||
Yap_emit(deallocate_op, Zero, Zero, &cglobs->cint);
|
Yap_emit(deallocate_op, Zero, Zero, &cglobs->cint);
|
||||||
@ -1493,6 +1505,10 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
|||||||
|
|
||||||
/* I need an either_me */
|
/* I need an either_me */
|
||||||
cglobs->needs_env = TRUE;
|
cglobs->needs_env = TRUE;
|
||||||
|
if (profiling)
|
||||||
|
Yap_emit(enter_profiling_op, (CELL)RepPredProp(PredPropByAtom(AtomRepeat,0)), Zero, &cglobs->cint);
|
||||||
|
else if (call_counting)
|
||||||
|
Yap_emit(count_call_op, (CELL)RepPredProp(PredPropByAtom(AtomRepeat,0)), Zero, &cglobs->cint);
|
||||||
cglobs->or_found = TRUE;
|
cglobs->or_found = TRUE;
|
||||||
push_branch(cglobs->onbranch, TermNil, cglobs);
|
push_branch(cglobs->onbranch, TermNil, cglobs);
|
||||||
cglobs->curbranch++;
|
cglobs->curbranch++;
|
||||||
@ -1532,6 +1548,11 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
|||||||
save_machine_regs();
|
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)
|
||||||
|
Yap_emit(enter_profiling_op, (CELL)p, Zero, &cglobs->cint);
|
||||||
|
if (call_counting)
|
||||||
|
Yap_emit(count_call_op, (CELL)p, Zero, &cglobs->cint);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
f = FunctorOfTerm(Goal);
|
f = FunctorOfTerm(Goal);
|
||||||
@ -1742,6 +1763,10 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (f == FunctorEq) {
|
else if (f == FunctorEq) {
|
||||||
|
if (profiling)
|
||||||
|
Yap_emit(enter_profiling_op, (CELL)p, Zero, &cglobs->cint);
|
||||||
|
else if (call_counting)
|
||||||
|
Yap_emit(count_call_op, (CELL)p, Zero, &cglobs->cint);
|
||||||
c_eq(ArgOfTerm(1, Goal), ArgOfTerm(2, Goal), cglobs);
|
c_eq(ArgOfTerm(1, Goal), ArgOfTerm(2, Goal), cglobs);
|
||||||
if (cglobs->onlast) {
|
if (cglobs->onlast) {
|
||||||
Yap_emit(deallocate_op, Zero, Zero, &cglobs->cint);
|
Yap_emit(deallocate_op, Zero, Zero, &cglobs->cint);
|
||||||
@ -1767,6 +1792,10 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
|||||||
else if (p->PredFlags & AsmPredFlag) {
|
else if (p->PredFlags & AsmPredFlag) {
|
||||||
int op = p->PredFlags & 0x7f;
|
int op = p->PredFlags & 0x7f;
|
||||||
|
|
||||||
|
if (profiling)
|
||||||
|
Yap_emit(enter_profiling_op, (CELL)p, Zero, &cglobs->cint);
|
||||||
|
else if (call_counting)
|
||||||
|
Yap_emit(count_call_op, (CELL)p, Zero, &cglobs->cint);
|
||||||
if (op >= _atom && op <= _primitive) {
|
if (op >= _atom && op <= _primitive) {
|
||||||
c_test(op, ArgOfTerm(1, Goal), cglobs);
|
c_test(op, ArgOfTerm(1, Goal), cglobs);
|
||||||
if (cglobs->onlast) {
|
if (cglobs->onlast) {
|
||||||
@ -1895,6 +1924,10 @@ c_goal(Term Goal, Term mod, compiler_struct *cglobs)
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
if (profiling)
|
||||||
|
Yap_emit(enter_profiling_op, (CELL)p, Zero, &cglobs->cint);
|
||||||
|
else if (call_counting)
|
||||||
|
Yap_emit(count_call_op, (CELL)p, Zero, &cglobs->cint);
|
||||||
if (f == FunctorExecuteInMod) {
|
if (f == FunctorExecuteInMod) {
|
||||||
/* compile the first argument only */
|
/* compile the first argument only */
|
||||||
c_arg(1, ArgOfTerm(1,Goal), 1, 0, cglobs);
|
c_arg(1, ArgOfTerm(1,Goal), 1, 0, cglobs);
|
||||||
|
@ -696,7 +696,9 @@ static char *opformat[] =
|
|||||||
"fetch_reg_constant\t%l,%N",
|
"fetch_reg_constant\t%l,%N",
|
||||||
"fetch_integer_reg\t%d,%N",
|
"fetch_integer_reg\t%d,%N",
|
||||||
"fetch_reg_integer\t%d,%N",
|
"fetch_reg_integer\t%d,%N",
|
||||||
|
"enter_profiling\t\t%g",
|
||||||
"retry_profiled\t\t%g",
|
"retry_profiled\t\t%g",
|
||||||
|
"count_call_op\t\t%g",
|
||||||
"count_retry_op\t\t%g",
|
"count_retry_op\t\t%g",
|
||||||
"restore_temps\t\t%l",
|
"restore_temps\t\t%l",
|
||||||
"restore_temps_and_skip\t\t%l",
|
"restore_temps_and_skip\t\t%l",
|
||||||
|
6
C/exec.c
6
C/exec.c
@ -77,12 +77,6 @@ CallPredicate(PredEntry *pen, choiceptr cut_pt, yamop *code) {
|
|||||||
YENV[E_CB] = (CELL) cut_pt;
|
YENV[E_CB] = (CELL) cut_pt;
|
||||||
}
|
}
|
||||||
P = code;
|
P = code;
|
||||||
/* vsc: increment reduction counter at meta-call entry */
|
|
||||||
if (pen->PredFlags & ProfiledPredFlag) {
|
|
||||||
LOCK(pen->StatisticsForPred.lock);
|
|
||||||
pen->StatisticsForPred.NOfEntries++;
|
|
||||||
UNLOCK(pen->StatisticsForPred.lock);
|
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
C/grow.c
2
C/grow.c
@ -1027,7 +1027,9 @@ fix_compiler_instructions(PInstr *pcpc)
|
|||||||
case write_last_struct_op:
|
case write_last_struct_op:
|
||||||
case mark_initialised_pvars_op:
|
case mark_initialised_pvars_op:
|
||||||
case mark_live_regs_op:
|
case mark_live_regs_op:
|
||||||
|
case enter_profiling_op:
|
||||||
case retry_profiled_op:
|
case retry_profiled_op:
|
||||||
|
case count_call_op:
|
||||||
case count_retry_op:
|
case count_retry_op:
|
||||||
case restore_tmps_op:
|
case restore_tmps_op:
|
||||||
case restore_tmps_and_skip_op:
|
case restore_tmps_and_skip_op:
|
||||||
|
@ -7,11 +7,13 @@
|
|||||||
OPCODE(try_me ,Otapl),
|
OPCODE(try_me ,Otapl),
|
||||||
OPCODE(retry_me ,Otapl),
|
OPCODE(retry_me ,Otapl),
|
||||||
OPCODE(trust_me ,Otapl),
|
OPCODE(trust_me ,Otapl),
|
||||||
|
OPCODE(enter_profiling ,p),
|
||||||
OPCODE(retry_profiled ,p),
|
OPCODE(retry_profiled ,p),
|
||||||
OPCODE(profiled_retry_me ,Otapl),
|
OPCODE(profiled_retry_me ,Otapl),
|
||||||
OPCODE(profiled_trust_me ,Otapl),
|
OPCODE(profiled_trust_me ,Otapl),
|
||||||
OPCODE(profiled_retry_logical ,OtaLl),
|
OPCODE(profiled_retry_logical ,OtaLl),
|
||||||
OPCODE(profiled_trust_logical ,OtILl),
|
OPCODE(profiled_trust_logical ,OtILl),
|
||||||
|
OPCODE(count_call ,p),
|
||||||
OPCODE(count_retry ,p),
|
OPCODE(count_retry ,p),
|
||||||
OPCODE(count_retry_me ,Otapl),
|
OPCODE(count_retry_me ,Otapl),
|
||||||
OPCODE(count_trust_me ,Otapl),
|
OPCODE(count_trust_me ,Otapl),
|
||||||
|
@ -136,7 +136,9 @@ typedef enum compiler_op {
|
|||||||
fetch_args_vc_op,
|
fetch_args_vc_op,
|
||||||
fetch_args_iv_op,
|
fetch_args_iv_op,
|
||||||
fetch_args_vi_op,
|
fetch_args_vi_op,
|
||||||
|
enter_profiling_op,
|
||||||
retry_profiled_op,
|
retry_profiled_op,
|
||||||
|
count_call_op,
|
||||||
count_retry_op,
|
count_retry_op,
|
||||||
restore_tmps_op,
|
restore_tmps_op,
|
||||||
restore_tmps_and_skip_op,
|
restore_tmps_and_skip_op,
|
||||||
|
@ -404,8 +404,10 @@ restore_opcodes(yamop *pc)
|
|||||||
pc = NEXTOP(pc,oy);
|
pc = NEXTOP(pc,oy);
|
||||||
break;
|
break;
|
||||||
/* instructions type p */
|
/* instructions type p */
|
||||||
|
case _count_call:
|
||||||
case _count_retry:
|
case _count_retry:
|
||||||
case _deallocate:
|
case _deallocate:
|
||||||
|
case _enter_profiling:
|
||||||
case _lock_lu:
|
case _lock_lu:
|
||||||
case _procceed:
|
case _procceed:
|
||||||
case _retry_profiled:
|
case _retry_profiled:
|
||||||
|
@ -326,8 +326,10 @@
|
|||||||
clause_code = TRUE;
|
clause_code = TRUE;
|
||||||
pc = NEXTOP(pc,p);
|
pc = NEXTOP(pc,p);
|
||||||
break;
|
break;
|
||||||
|
case _count_call:
|
||||||
case _count_retry:
|
case _count_retry:
|
||||||
case _deallocate:
|
case _deallocate:
|
||||||
|
case _enter_profiling:
|
||||||
case _retry_profiled:
|
case _retry_profiled:
|
||||||
pc = NEXTOP(pc,p);
|
pc = NEXTOP(pc,p);
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user