diff src/profile.c @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents 74fd4e045ea6
children 11054d720c21
line wrap: on
line diff
--- a/src/profile.c	Mon Aug 13 11:19:22 2007 +0200
+++ b/src/profile.c	Mon Aug 13 11:20:41 2007 +0200
@@ -57,7 +57,7 @@
    even be useful to provide a way to turn on only one profiling
    mechanism, but I haven't done so yet.  --hniksic */
 
-static struct hash_table *big_profile_table;
+struct hash_table *big_profile_table;
 Lisp_Object Vcall_count_profile_table;
 
 int default_profiling_interval;
@@ -68,10 +68,10 @@
    and is not set the whole time we're in redisplay. */
 int profiling_redisplay_flag;
 
-static Lisp_Object QSin_redisplay;
-static Lisp_Object QSin_garbage_collection;
-static Lisp_Object QSprocessing_events_at_top_level;
-static Lisp_Object QSunknown;
+Lisp_Object QSin_redisplay;
+Lisp_Object QSin_garbage_collection;
+Lisp_Object QSprocessing_events_at_top_level;
+Lisp_Object QSunknown;
 
 /* We use inside_profiling to prevent the handler from writing to
    the table while another routine is operating on it.  We also set
@@ -119,10 +119,9 @@
 	{
 	  fun = *backtrace_list->function;
 
-	  if (!SYMBOLP (fun)
-	      && !COMPILED_FUNCTIONP (fun)
-	      && !SUBRP (fun)
-	      && !CONSP (fun))
+	  if (!GC_SYMBOLP	     (fun) &&
+	      !GC_COMPILED_FUNCTIONP (fun) &&
+	      !GC_SUBRP		     (fun))
 	     fun = QSunknown;
 	}
       else
@@ -135,14 +134,14 @@
 	   lose because of this.  Even worse, if the memory allocation
 	   fails, the `error' generated whacks everything hard. */
 	long count;
-	const void *vval;
+	CONST void *vval;
 
 	if (gethash (LISP_TO_VOID (fun), big_profile_table, &vval))
 	  count = (long) vval;
 	else
 	  count = 0;
 	count++;
-	vval = (const void *) count;
+	vval = (CONST void *) count;
 	puthash (LISP_TO_VOID (fun), (void *) vval, big_profile_table);
       }
 
@@ -226,7 +225,7 @@
 };
 
 static int
-get_profiling_info_maphash (const void *void_key,
+get_profiling_info_maphash (CONST void *void_key,
 			    void *void_val,
 			    void *void_closure)
 {
@@ -263,26 +262,34 @@
   return closure.accum;
 }
 
+struct mark_profiling_info_closure
+{
+  void (*markfun) (Lisp_Object);
+};
+
 static int
-mark_profiling_info_maphash (const void *void_key,
+mark_profiling_info_maphash (CONST void *void_key,
 			     void *void_val,
 			     void *void_closure)
 {
   Lisp_Object key;
 
   CVOID_TO_LISP (key, void_key);
-  mark_object (key);
+  (((struct mark_profiling_info_closure *) void_closure)->markfun) (key);
   return 0;
 }
 
 void
-mark_profiling_info (void)
+mark_profiling_info (void (*markfun) (Lisp_Object))
 {
-  /* This function does not GC */
+  /* This function does not GC (if markfun doesn't) */
+  struct mark_profiling_info_closure closure;
+
+  closure.markfun = markfun;
   if (big_profile_table)
     {
       inside_profiling = 1;
-      maphash (mark_profiling_info_maphash, big_profile_table, 0);
+      maphash (mark_profiling_info_maphash, big_profile_table, &closure);
       inside_profiling = 0;
     }
 }