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 *
found_meta_call(CODEADDR *startp, CODEADDR *endp)
{
PredEntry *pp = RepPredProp(Yap_GetPredPropByFunc(FunctorCall, CurrentModule));
PredEntry *pp = PredMetaCall;
*startp = (CODEADDR)&(pp->OpcodeOfPred);
*endp = (CODEADDR)NEXTOP((yamop *)&(pp->OpcodeOfPred),e);
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 */
static PredEntry *
found_mega_clause(PredEntry *pp, CODEADDR *startp, CODEADDR *endp)

View File

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

View File

@ -255,7 +255,9 @@ output_walk_type(T, C) :-
split_ops(Ops0,Ops1,Ops2),
( split_ops1(T, Ops1, Ops) ; Ops2 = Ops ),
Ops = [_|_],
% first send the header
dump_ops(C,Ops),
% then the code for every instruction with this header.
output_walk(C,T,Ops).
% separate a special group of instructions, that operate differentely from the
@ -264,11 +266,16 @@ split_ops([],[],[]).
split_ops([Op|Ops0],[Op|Ops1],Ops2) :-
special_walk_op(Op), !,
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(Ops0,Ops1,Ops2).
split_ops1("e", Ops, [M]) :- !,
member(M, Ops).
split_ops1("Osbpp", Ops, [M]) :- !,
member(M, Ops).
split_ops1(_, Ops, Ops).
% 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("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
output_walk(C,"Ills",_) :- !,
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.
output_walk(C,"Osblp",_) :- !,
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|_]) :-
special_walk_op(Op), !,
walk_to_meta_call(C).
output_walk(C,"Osbpp",_) :- !,
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",_) :- !,
label_in_clause(C,"pp","p0").
output_walk(C,"OtapFs",_) :- !,
@ -402,6 +423,10 @@ add_pp(C,Type,Field) :-
walk_to_meta_call(C) :-
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
% tries to find out what an instruction touches in the body