fix counting of C-pred: it should not be in caller.

This commit is contained in:
Vitor Santos Costa 2009-02-26 00:00:23 +00:00
parent 95fc66be25
commit d7c2c74acc
3 changed files with 48 additions and 6 deletions

View File

@ -3748,12 +3748,22 @@ walk_got_lu_clause(LogUpdClause *cl, CODEADDR *startp, CODEADDR *endp)
static PredEntry * static PredEntry *
found_meta_call(CODEADDR *startp, CODEADDR *endp) found_meta_call(CODEADDR *startp, CODEADDR *endp)
{ {
PredEntry *pp = RepPredProp(Yap_GetPredPropByFunc(FunctorCall, CurrentModule)); PredEntry *pp = PredMetaCall;
*startp = (CODEADDR)&(pp->OpcodeOfPred); *startp = (CODEADDR)&(pp->OpcodeOfPred);
*endp = (CODEADDR)NEXTOP((yamop *)&(pp->OpcodeOfPred),e); *endp = (CODEADDR)NEXTOP((yamop *)&(pp->OpcodeOfPred),e);
return pp; return pp;
} }
/* intruction blocks we found ourselves at */
static PredEntry *
walk_found_c_pred(PredEntry *pp, CODEADDR *startp, CODEADDR *endp)
{
StaticClause *cl = ClauseCodeToStaticClause(pp->CodeOfPred);
*startp = (CODEADDR)&(cl->ClCode);
*endp = (CODEADDR)&(cl->ClCode)+cl->ClSize;
return pp;
}
/* we hit a mega-clause, no point in going on */ /* we hit a mega-clause, no point in going on */
static PredEntry * static PredEntry *
found_mega_clause(PredEntry *pp, CODEADDR *startp, CODEADDR *endp) found_mega_clause(PredEntry *pp, CODEADDR *startp, CODEADDR *endp)

View File

@ -27,12 +27,17 @@
pc = NEXTOP(pc,Osbmp); pc = NEXTOP(pc,Osbmp);
break; break;
/* instructions type Osbpp */ /* instructions type Osbpp */
case _call_cpred:
pp = pc->u.Osbpp.p;
return walk_found_c_pred(pp, startp, endp);
case _call_usercpred:
pp = pc->u.Osbpp.p;
return walk_found_c_pred(pp, startp, endp);
case _p_execute2: case _p_execute2:
return found_meta_call(startp, endp);
case _p_execute_tail: case _p_execute_tail:
return found_meta_call(startp, endp); return found_meta_call(startp, endp);
case _call: case _call:
case _call_cpred:
case _call_usercpred:
case _fcall: case _fcall:
clause_code = TRUE; clause_code = TRUE;
pp = pc->u.Osbpp.p0; pp = pc->u.Osbpp.p0;
@ -340,9 +345,11 @@
pc = NEXTOP(pc,plyys); pc = NEXTOP(pc,plyys);
break; break;
/* instructions type pp */ /* instructions type pp */
case _execute_cpred:
pp = pc->u.pp.p;
return walk_found_c_pred(pp, startp, endp);
case _dexecute: case _dexecute:
case _execute: case _execute:
case _execute_cpred:
clause_code = TRUE; clause_code = TRUE;
pp = pc->u.pp.p0; pp = pc->u.pp.p0;
pc = NEXTOP(pc,pp); pc = NEXTOP(pc,pp);
@ -368,8 +375,8 @@
break; break;
/* instructions type slp */ /* instructions type slp */
case _call_c_wfail: case _call_c_wfail:
pc = NEXTOP(pc,slp); pp = pc->u.slp.p;
break; return walk_found_c_pred(pp, startp, endp);
/* instructions type snll */ /* instructions type snll */
case _a_eqc_int: case _a_eqc_int:
case _gtc_int: case _gtc_int:

View File

@ -255,7 +255,9 @@ output_walk_type(T, C) :-
split_ops(Ops0,Ops1,Ops2), split_ops(Ops0,Ops1,Ops2),
( split_ops1(T, Ops1, Ops) ; Ops2 = Ops ), ( split_ops1(T, Ops1, Ops) ; Ops2 = Ops ),
Ops = [_|_], Ops = [_|_],
% first send the header
dump_ops(C,Ops), dump_ops(C,Ops),
% then the code for every instruction with this header.
output_walk(C,T,Ops). output_walk(C,T,Ops).
% separate a special group of instructions, that operate differentely from the % separate a special group of instructions, that operate differentely from the
@ -264,11 +266,16 @@ split_ops([],[],[]).
split_ops([Op|Ops0],[Op|Ops1],Ops2) :- split_ops([Op|Ops0],[Op|Ops1],Ops2) :-
special_walk_op(Op), !, special_walk_op(Op), !,
split_ops(Ops0,Ops1,Ops2). split_ops(Ops0,Ops1,Ops2).
split_ops([Op|Ops0],[Op|Ops1],Ops2) :-
c_call_op(Op), !,
split_ops(Ops0,Ops1,Ops2).
split_ops([Op|Ops0],Ops1,[Op|Ops2]) :- split_ops([Op|Ops0],Ops1,[Op|Ops2]) :-
split_ops(Ops0,Ops1,Ops2). split_ops(Ops0,Ops1,Ops2).
split_ops1("e", Ops, [M]) :- !, split_ops1("e", Ops, [M]) :- !,
member(M, Ops). member(M, Ops).
split_ops1("Osbpp", Ops, [M]) :- !,
member(M, Ops).
split_ops1(_, Ops, Ops). split_ops1(_, Ops, Ops).
% instructions which require special treatment, relative to % instructions which require special treatment, relative to
@ -290,6 +297,11 @@ special_walk_op("trust_fail").
special_walk_op("unify_idb_term"). special_walk_op("unify_idb_term").
special_walk_op("copy_idb_term"). special_walk_op("copy_idb_term").
c_call_op("call_cpred").
c_call_op("call_usercpred").
c_call_op("execute_cpred").
c_call_op("call_c_wfail").
% I field gives direct access to LU index block and to all Pred information % I field gives direct access to LU index block and to all Pred information
output_walk(C,"Ills",_) :- !, output_walk(C,"Ills",_) :- !,
format(C,' return walk_got_lu_block(pc->u.Ills.I, startp, endp);~n',[]). format(C,' return walk_got_lu_block(pc->u.Ills.I, startp, endp);~n',[]).
@ -304,11 +316,20 @@ output_walk(C,"OtaLl",_) :- !,
% ops which point at the clause's predicate. % ops which point at the clause's predicate.
output_walk(C,"Osblp",_) :- !, output_walk(C,"Osblp",_) :- !,
label_in_clause(C,"Osblp","p0"). label_in_clause(C,"Osblp","p0").
output_walk(C,"Osbpp",[Op|_]) :-
c_call_op(Op), !,
walk_to_c_code(C,"Osbpp","p").
output_walk(C,"slp",[Op|_]) :-
c_call_op(Op), !,
walk_to_c_code(C,"slp","p").
output_walk(C,"Osbpp",[Op|_]) :- output_walk(C,"Osbpp",[Op|_]) :-
special_walk_op(Op), !, special_walk_op(Op), !,
walk_to_meta_call(C). walk_to_meta_call(C).
output_walk(C,"Osbpp",_) :- !, output_walk(C,"Osbpp",_) :- !,
label_in_clause(C,"Osbpp","p0"). label_in_clause(C,"Osbpp","p0").
output_walk(C,"pp",[Op|_]) :-
c_call_op(Op), !,
walk_to_c_code(C,"pp","p").
output_walk(C,"pp",_) :- !, output_walk(C,"pp",_) :- !,
label_in_clause(C,"pp","p0"). label_in_clause(C,"pp","p0").
output_walk(C,"OtapFs",_) :- !, output_walk(C,"OtapFs",_) :- !,
@ -402,6 +423,10 @@ add_pp(C,Type,Field) :-
walk_to_meta_call(C) :- walk_to_meta_call(C) :-
format(C,' return found_meta_call(startp, endp);~n',[]). format(C,' return found_meta_call(startp, endp);~n',[]).
walk_to_c_code(C,Type,Field) :-
format(C,' pp = pc->u.~s.~s;~n',[Type,Field]),
format(C,' return walk_found_c_pred(pp, startp, endp);~n',[]).
% %
% find region % find region
% tries to find out what an instruction touches in the body % tries to find out what an instruction touches in the body