From 1febfedc9dce0e5aee3bcda994d31f26f60d4f12 Mon Sep 17 00:00:00 2001 From: rslopes Date: Fri, 21 Mar 2003 16:18:42 +0000 Subject: [PATCH] added Low Profiler to yap git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@804 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/amasm.c | 9 +++++++++ C/compiler.c | 29 +++++++++++++++++++++++++++++ C/sysbits.c | 8 ++++++++ configure | 14 ++++++++++++++ 4 files changed, 60 insertions(+) diff --git a/C/amasm.c b/C/amasm.c index 41463a596..585a85528 100644 --- a/C/amasm.c +++ b/C/amasm.c @@ -106,6 +106,10 @@ STATIC_PROTO(void a_fetch_cv, (void)); STATIC_PROTO(void a_fetch_vc, (void)); STATIC_PROTO(void a_f2, (int)); +#ifdef LOW_PROF + int PROFSIZE; +#endif + #define CELLSIZE sizeof(CELL) #define MaxLabels 2048 @@ -2614,6 +2618,11 @@ Yap_assemble(int mode) YAPLeaveCriticalSection(); { Clause *cl = (Clause *)code_addr; /* lcc, why? */ + +#ifdef LOW_PROF + PROFSIZE=code_p; +#endif + return(cl->ClCode); } } diff --git a/C/compiler.c b/C/compiler.c index 064b22331..31c32cace 100644 --- a/C/compiler.c +++ b/C/compiler.c @@ -2896,6 +2896,35 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod) #endif /* phase 3: assemble code */ acode = Yap_assemble(ASSEMBLING_CLAUSE); + +#ifdef LOW_PROF + { + static int pred_count=0; + FILE *f,*init; + extern int PROFSIZE; + + if (!pred_count++) { + f=fopen("PROFPREDS","w"); + init=fopen("PROFINIT","r"); + if (init!=NULL) { + size_t nc; char buffer[4100]; + do { + nc=fread(buffer,1,4096,init); + fwrite(buffer,1,nc,f); + } while(nc>0); + fclose(init); + } + } else { + f=fopen("PROFPREDS","a"); + } + if (f!=NULL) { + fprintf(f,"%x - %x - Pred(%d) - %s/%d\n",acode,PROFSIZE, CodeStart->rnd1, RepAtom(AtomOfTerm(MkAtomTerm((Atom) CodeStart->rnd1)))->StrOfAE, CodeStart->rnd2); + fclose(f); + } + } +#endif + + /* check first if there was space for us */ if (acode == NIL) { /* make sure we have enough space */ diff --git a/C/sysbits.c b/C/sysbits.c index de7f733ae..89686bb36 100644 --- a/C/sysbits.c +++ b/C/sysbits.c @@ -1323,6 +1323,10 @@ MSCHandleSignal(DWORD dwCtrlType) { static void InitSignals (void) { +#ifdef LOW_PROF + return; +#endif + #if !defined(LIGHT) && !_MSC_VER && !defined(__MINGW32__) && !defined(LIGHT) my_signal (SIGQUIT, ReceiveSignal); my_signal (SIGKILL, ReceiveSignal); @@ -2001,7 +2005,11 @@ p_alarm(void) Int left; Term tout; +#ifdef LOW_PROF + left=0; +#else left = alarm(IntegerOfTerm(t)); +#endif tout = MkIntegerTerm(left); return(Yap_unify(ARG2,tout)); } diff --git a/configure b/configure index 17873cbff..c62addc7e 100755 --- a/configure +++ b/configure @@ -832,6 +832,7 @@ Optional Features: --enable-wam-profile support low level profiling of abstract machine --enable-depth-limit support depth-bound computation --enable-or-parallelism support or-parallelism as: env-copy,sba,a-cow + --enable-low-profile support for low-level profiling --enable-low-level-tracer support support for procedure-call tracing --enable-tabling support tabling as: batched,local --enable-threads support system threads @@ -2005,6 +2006,13 @@ if test "${enable_depth_limit+set}" = set; then else depthlimit=no fi; +#check whether --enable-low-profile or --disable-low-profile was given. +if test "${enable_low_profile+set}" = set; then + enableval="$enable_low_profile" + lowprofile="$enableval" +else + lowprofile=no +fi; # Check whether --enable-or-parallelism or --disable-or-parallelism was given. if test "${enable_or_parallelism+set}" = set; then enableval="$enable_or_parallelism" @@ -4915,6 +4923,12 @@ if test "$depthlimit" = "yes" YAP_EXTRAS="$YAP_EXTRAS -DDEPTH_LIMIT=1" fi +if test "$lowprofile" = "yes" + then + YAP_EXTRAS="$YAP_EXTRAS -DLOW_PROF=1" +fi + + if test "$use_april" = "yes" then YAP_EXTRAS="$YAP_EXTRAS -DDEPTH_LIMIT=1 -DAPRIL"