comparison src/profile.c @ 424:11054d720c21 r21-2-20

Import from CVS: tag r21-2-20
author cvs
date Mon, 13 Aug 2007 11:26:11 +0200
parents 697ef44129c6
children
comparison
equal deleted inserted replaced
423:28d9c139be4c 424:11054d720c21
55 independent of the SIGPROF-driven one. It uses the Lisp allocation 55 independent of the SIGPROF-driven one. It uses the Lisp allocation
56 mechanism normally, since it is not called from a handler. It may 56 mechanism normally, since it is not called from a handler. It may
57 even be useful to provide a way to turn on only one profiling 57 even be useful to provide a way to turn on only one profiling
58 mechanism, but I haven't done so yet. --hniksic */ 58 mechanism, but I haven't done so yet. --hniksic */
59 59
60 struct hash_table *big_profile_table; 60 static struct hash_table *big_profile_table;
61 Lisp_Object Vcall_count_profile_table; 61 Lisp_Object Vcall_count_profile_table;
62 62
63 int default_profiling_interval; 63 int default_profiling_interval;
64 64
65 int profiling_active; 65 int profiling_active;
66 66
67 /* The normal flag in_display is used as a critical-section flag 67 /* The normal flag in_display is used as a critical-section flag
68 and is not set the whole time we're in redisplay. */ 68 and is not set the whole time we're in redisplay. */
69 int profiling_redisplay_flag; 69 int profiling_redisplay_flag;
70 70
71 Lisp_Object QSin_redisplay; 71 static Lisp_Object QSin_redisplay;
72 Lisp_Object QSin_garbage_collection; 72 static Lisp_Object QSin_garbage_collection;
73 Lisp_Object QSprocessing_events_at_top_level; 73 static Lisp_Object QSprocessing_events_at_top_level;
74 Lisp_Object QSunknown; 74 static Lisp_Object QSunknown;
75 75
76 /* We use inside_profiling to prevent the handler from writing to 76 /* We use inside_profiling to prevent the handler from writing to
77 the table while another routine is operating on it. We also set 77 the table while another routine is operating on it. We also set
78 inside_profiling in case the timeout between signal calls is short 78 inside_profiling in case the timeout between signal calls is short
79 enough to catch us while we're already in there. */ 79 enough to catch us while we're already in there. */
117 fun = QSin_garbage_collection; 117 fun = QSin_garbage_collection;
118 else if (backtrace_list) 118 else if (backtrace_list)
119 { 119 {
120 fun = *backtrace_list->function; 120 fun = *backtrace_list->function;
121 121
122 if (!GC_SYMBOLP (fun) && 122 if (!SYMBOLP (fun) &&
123 !GC_COMPILED_FUNCTIONP (fun) && 123 !COMPILED_FUNCTIONP (fun) &&
124 !GC_SUBRP (fun)) 124 !SUBRP (fun))
125 fun = QSunknown; 125 fun = QSunknown;
126 } 126 }
127 else 127 else
128 fun = QSprocessing_events_at_top_level; 128 fun = QSprocessing_events_at_top_level;
129 129
260 unbind_to (count, Qnil); 260 unbind_to (count, Qnil);
261 } 261 }
262 return closure.accum; 262 return closure.accum;
263 } 263 }
264 264
265 struct mark_profiling_info_closure
266 {
267 void (*markfun) (Lisp_Object);
268 };
269
270 static int 265 static int
271 mark_profiling_info_maphash (CONST void *void_key, 266 mark_profiling_info_maphash (CONST void *void_key,
272 void *void_val, 267 void *void_val,
273 void *void_closure) 268 void *void_closure)
274 { 269 {
275 Lisp_Object key; 270 Lisp_Object key;
276 271
277 CVOID_TO_LISP (key, void_key); 272 CVOID_TO_LISP (key, void_key);
278 (((struct mark_profiling_info_closure *) void_closure)->markfun) (key); 273 mark_object (key);
279 return 0; 274 return 0;
280 } 275 }
281 276
282 void 277 void
283 mark_profiling_info (void (*markfun) (Lisp_Object)) 278 mark_profiling_info (void)
284 { 279 {
285 /* This function does not GC (if markfun doesn't) */ 280 /* This function does not GC */
286 struct mark_profiling_info_closure closure;
287
288 closure.markfun = markfun;
289 if (big_profile_table) 281 if (big_profile_table)
290 { 282 {
291 inside_profiling = 1; 283 inside_profiling = 1;
292 maphash (mark_profiling_info_maphash, big_profile_table, &closure); 284 maphash (mark_profiling_info_maphash, big_profile_table, 0);
293 inside_profiling = 0; 285 inside_profiling = 0;
294 } 286 }
295 } 287 }
296 288
297 DEFUN ("clear-profiling-info", Fclear_profiling_info, 0, 0, "", /* 289 DEFUN ("clear-profiling-info", Fclear_profiling_info, 0, 0, "", /*