diff --git a/C/amasm.c b/C/amasm.c index e4dbb51a6..d69b68b47 100644 --- a/C/amasm.c +++ b/C/amasm.c @@ -2590,7 +2590,4 @@ Yap_InitComma(void) code_p->opc = opcode(_p_execute_tail); GONEXT(e); } -#ifdef LOW_PROF - Yap_inform_profiler_of_clause(COMMA_CODE, code_p, RepPredProp(Yap_GetPredPropByFunc(FunctorComma,2))); -#endif } diff --git a/C/cdmgr.c b/C/cdmgr.c index 4a63d329a..91053bccb 100644 --- a/C/cdmgr.c +++ b/C/cdmgr.c @@ -2565,6 +2565,17 @@ add_code_in_pred(PredEntry *pp) { READ_LOCK(pp->PRWLock); /* check if the codeptr comes from the indexing code */ + + if (pp->PredFlags & (CPredFlag|AsmPredFlag)) { + char *code_end; + StaticClause *cl; + + clcode = pp->CodeOfPred; + cl = ClauseCodeToStaticClause(clcode); + code_end = (char *)cl + Yap_SizeOfBlock((CODEADDR)cl); + inform_profiler_of_clause(clcode, (yamop *)code_end, pp); + return; + } clcode = pp->cs.p_code.TrueCodeOfPred; if (pp->PredFlags & IndexedPredFlag) { char *code_end; @@ -2590,7 +2601,7 @@ add_code_in_pred(PredEntry *pp) { } else { cl = (CODEADDR)ClauseCodeToStaticClause(clcode); } - code_end = (char *)cl + Yap_SizeOfBlock((CODEADDR)cl); + code_end = cl + Yap_SizeOfBlock((CODEADDR)cl); inform_profiler_of_clause(clcode, (yamop *)code_end, pp); if (clcode == pp->cs.p_code.LastClause) break; @@ -2608,10 +2619,22 @@ Yap_dump_code_area_for_profiler(void) { for (i_table = NoOfModules-1; i_table >= 0; --i_table) { PredEntry *pp = ModulePred[i_table]; while (pp != NULL) { + if (pp->ArityOfPE) { + fprintf(stderr,"%s/%d %p\n", + RepAtom(NameOfFunctor(pp->FunctorOfPred))->StrOfAE, + pp->ArityOfPE, + pp); + } else { + fprintf(stderr,"%s %p\n", + RepAtom((Atom)(pp->FunctorOfPred))->StrOfAE, + pp); + } add_code_in_pred(pp); pp = pp->NextPredOfModule; } } + inform_profiler_of_clause(COMMA_CODE, FAILCODE, RepPredProp(Yap_GetPredPropByFunc(FunctorComma,0))); + inform_profiler_of_clause(FAILCODE, FAILCODE+1, RepPredProp(Yap_GetPredPropByAtom(AtomFail,0))); } #endif /* LOW_PROF */ diff --git a/C/stdpreds.c b/C/stdpreds.c index 4d5b506f4..aba2f67a8 100644 --- a/C/stdpreds.c +++ b/C/stdpreds.c @@ -205,10 +205,9 @@ static void search_pc_pred(yamop *pc_ptr,clauseentry *beg, clauseentry *end) { /* binary search, dynamic clauses not supported yet */ Int i, j, f, l; - f = 0; l = (end-beg)-1; + f = 0; l = (end-beg); i = l/2; while (TRUE) { - printf("i %d\n", i); if (beg[i].beg > pc_ptr) { l = i-1; if (l < f) {