more fixes to profiling code.

This commit is contained in:
Vitor Santos Costa 2009-02-25 22:15:18 +00:00
parent 083b7c9b92
commit 95fc66be25
4 changed files with 44 additions and 12 deletions

View File

@ -3779,10 +3779,10 @@ found_idb_clause(yamop *pc, CODEADDR *startp, CODEADDR *endp)
static PredEntry *
found_expand_index(yamop *pc, CODEADDR *startp, CODEADDR *endp, yamop *codeptr)
{
PredEntry *pp = ((PredEntry *)(Unsigned(pc)-(CELL)(&(((PredEntry *)NULL)->cs.p_code.ExpandCode))));
PredEntry *pp = codeptr->u.sssllp.p;
if (pc == codeptr) {
*startp = (CODEADDR)&(pp->cs.p_code.ExpandCode);
*endp = (CODEADDR)&(pp->cs.p_code.ExpandCode);
*startp = (CODEADDR)codeptr;
*endp = (CODEADDR)NEXTOP(codeptr,sssllp);
}
return pp;
}
@ -3806,6 +3806,16 @@ found_owner_op(yamop *pc, CODEADDR *startp, CODEADDR *endp)
return pp;
}
/* we hit a expand_index, no point in going on */
static PredEntry *
found_expand(yamop *pc, CODEADDR *startp, CODEADDR *endp)
{
PredEntry *pp = ((PredEntry *)(Unsigned(pc)-(CELL)(&(((PredEntry *)NULL)->cs.p_code.ExpandCode))));
*startp = (CODEADDR)&(pp->cs.p_code.ExpandCode);
*endp = (CODEADDR)NEXTOP((yamop *)&(pp->cs.p_code.ExpandCode),e);
return pp;
}
static PredEntry *
found_ystop(yamop *pc, int clause_code, CODEADDR *startp, CODEADDR *endp, PredEntry *pp)
{

View File

@ -939,7 +939,7 @@ prof_alrm(int signo, siginfo_t *si, void *scv)
void * oldpc= NULL;
#endif
#else
#ifdef __APPLE__
#if defined(__APPLE__) && defined(i386)
#ifdef __darwin__
ucontext_t *sc = (ucontext_t *)scv;
void * oldpc=(void *) sc->uc_mcontext->ss.srr0; /* 14= POWER PC */
@ -947,7 +947,7 @@ prof_alrm(int signo, siginfo_t *si, void *scv)
void * oldpc=(void *) CONTEXT_PC;
#endif
#else
void *NULL;
void *oldpc = NULL;
#endif
#endif
rb_red_blk_node *node = NULL;
@ -1005,6 +1005,9 @@ prof_alrm(int signo, siginfo_t *si, void *scv)
if (oop == _call_cpred || oop == _call_usercpred) {
/* doing C-code */
current_p = PREVOP(P,Osbpp)->u.Osbpp.p->CodeOfPred;
} else if ((oop = Yap_op_from_opcode(PREVOP(P,pp)->opc)) == _execute_cpred) {
/* doing C-code */
current_p = PREVOP(P,pp)->u.pp.p->CodeOfPred;
} else {
current_p = P;
}
@ -1051,7 +1054,7 @@ prof_alrm(int signo, siginfo_t *si, void *scv)
if (start < (CODEADDR)Yap_HeapBase || start > (CODEADDR)HeapTop ||
end < (CODEADDR)Yap_HeapBase || end > (CODEADDR)HeapTop) {
#if DEBUG
fprintf(stderr,"Oops2: %p, %p\n", start, end);
fprintf(stderr,"Oops2: %p->%d %p, %p\n", current_p, current_p->opc, start, end);
#endif
return;
}

View File

@ -49,6 +49,7 @@
case _retry_logical:
case _try_logical:
pc = pc->u.OtaLl.n;
break;
/* instructions type OtapFs */
#ifdef CUT_C
case _cut_c:
@ -80,7 +81,7 @@
case _try_and_mark:
case _try_clause:
case _try_me:
clause_code = TRUE;
clause_code = FALSE;
pp = pc->u.Otapl.p;
pc = NEXTOP(pc,Otapl);
break;
@ -122,6 +123,7 @@
case _copy_idb_term:
return found_idb_clause(pc, startp, endp);
case _expand_index:
return found_expand(pc, startp, endp);
case _index_pred:
return found_owner_op(pc, startp, endp);
case _lock_pred:
@ -651,7 +653,7 @@
case _getwork:
case _getwork_seq:
case _sync:
clause_code = TRUE;
clause_code = FALSE;
pp = pc->u.Otapl.p;
pc = NEXTOP(pc,Otapl);
break;
@ -673,7 +675,7 @@
case _table_try_answer:
case _table_try_me:
case _table_try_single:
clause_code = TRUE;
clause_code = FALSE;
pp = pc->u.Otapl.p;
pc = NEXTOP(pc,Otapl);
break;

View File

@ -300,7 +300,7 @@ output_walk(C,"L",_) :- !,
format(C,' return walk_got_lu_clause(pc->u.L.ClBase, startp, endp);~n',[]).
% we cannot jump to clause code.
output_walk(C,"OtaLl",_) :- !,
format(C,' pc = pc->u.OtaLl.n;~n',[]).
format(C,' pc = pc->u.OtaLl.n;~n break;~n',[]).
% ops which point at the clause's predicate.
output_walk(C,"Osblp",_) :- !,
label_in_clause(C,"Osblp","p0").
@ -314,7 +314,10 @@ output_walk(C,"pp",_) :- !,
output_walk(C,"OtapFs",_) :- !,
label_in_clause(C,"OtapFs","p").
output_walk(C,"Otapl",_) :- !,
label_in_clause(C,"Otapl","p").
label_in_index(C,"Otapl","p").
output_walk(C,"p",["retry_profiled"|_]) :- !,
add_pi(C,"p","p"),
format(C,' break;~n',[]).
output_walk(C,"p",[Op|_]) :-
special_walk_op(Op), !,
add_pp(C,"p","p"),
@ -350,6 +353,9 @@ output_ewalks(C,["undef_p"|Ops]) :-
output_ewalks(C,["spy_pred"|Ops]) :-
format(C,' return found_owner_op(pc, startp, endp);~n',[]),
output_ewalks(C,Ops).
output_ewalks(C,["expand_index"|Ops]) :-
format(C,' return found_expand(pc, startp, endp);~n',[]),
output_ewalks(C,Ops).
output_ewalks(C,["index_pred"|Ops]) :-
format(C,' return found_owner_op(pc, startp, endp);~n',[]),
output_ewalks(C,Ops).
@ -375,6 +381,17 @@ label_in_clause(C,Type,Field) :-
format(C,' pc = NEXTOP(pc,~s);
break;~n',[Type]).
label_in_index(C,Type,Field) :-
format(C,' clause_code = FALSE;~n',[]),
format(C,' pp = pc->u.~s.~s;~n',[Type,Field]),
format(C,' pc = NEXTOP(pc,~s);
break;~n',[Type]).
add_pi(C,Type,Field) :-
format(C,' pp = pc->u.~s.~s;~n',[Type,Field]),
format(C,' clause_code = FALSE;~n',[]),
format(C,' pc = NEXTOP(pc,~s);~n',[Type]).
add_pp(C,Type,Field) :-
format(C,' pp = pc->u.~s.~s;~n',[Type,Field]),
format(C,' if (pp->PredFlags & MegaClausePredFlag)~n',[]),