comparison src/gc.c @ 3313:509d2981ffea

[xemacs-hg @ 2006-03-28 17:43:43 by crestani] EMACS_INT -> double for gc_state, gc_state related clean up
author crestani
date Tue, 28 Mar 2006 17:43:54 +0000
parents a0de8be91f1b
children 4cc26ec3f0de
comparison
equal deleted inserted replaced
3312:b145b32294ff 3313:509d2981ffea
123 }; 123 };
124 124
125 struct 125 struct
126 { 126 {
127 enum gc_phase phase; 127 enum gc_phase phase;
128 EMACS_INT n_gc[GC_STAT_COUNT]; 128 double n_gc[GC_STAT_COUNT];
129 EMACS_INT n_cycles[GC_STAT_COUNT]; 129 double n_cycles[GC_STAT_COUNT];
130 EMACS_INT enqueued[GC_STAT_COUNT]; 130 double enqueued[GC_STAT_COUNT];
131 EMACS_INT dequeued[GC_STAT_COUNT]; 131 double dequeued[GC_STAT_COUNT];
132 EMACS_INT repushed[GC_STAT_COUNT]; 132 double repushed[GC_STAT_COUNT];
133 EMACS_INT enqueued2[GC_STAT_COUNT]; 133 double enqueued2[GC_STAT_COUNT];
134 EMACS_INT dequeued2[GC_STAT_COUNT]; 134 double dequeued2[GC_STAT_COUNT];
135 EMACS_INT finalized[GC_STAT_COUNT]; 135 double finalized[GC_STAT_COUNT];
136 EMACS_INT freed[GC_STAT_COUNT]; 136 double freed[GC_STAT_COUNT];
137 EMACS_INT explicitly_freed;
138 EMACS_INT explicitly_tried_freed;
139 } gc_state; 137 } gc_state;
140 #endif /* ERROR_CHECK_GC */ 138 #endif /* ERROR_CHECK_GC */
141 139
142 #define GC_PHASE gc_state.phase 140 #define GC_PHASE gc_state.phase
143 #define GC_SET_PHASE(p) GC_PHASE = p 141 #define GC_SET_PHASE(p) GC_PHASE = p
224 gc_stat_freed (void) 222 gc_stat_freed (void)
225 { 223 {
226 GC_STAT_TICK (freed); 224 GC_STAT_TICK (freed);
227 } 225 }
228 226
229 void
230 gc_stat_explicitly_freed (void)
231 {
232 gc_state.explicitly_freed++;
233 }
234
235 void
236 gc_stat_explicitly_tried_freed (void)
237 {
238 gc_state.explicitly_tried_freed++;
239 }
240
241 #define GC_STAT_PRINT_ONE(stat) \
242 printf (" | %9s %10d %10d %10d %10d %10d\n", \
243 #stat, \
244 (int) gc_state.stat[GC_STAT_TOTAL], \
245 (int) gc_state.stat[GC_STAT_IN_LAST_GC], \
246 (int) gc_state.stat[GC_STAT_IN_THIS_GC], \
247 (int) gc_state.stat[GC_STAT_IN_LAST_CYCLE], \
248 (int) gc_state.stat[GC_STAT_IN_THIS_CYCLE])
249
250 void
251 gc_stat_print_stats (void)
252 {
253 printf (" | PHASE %d TOTAL_GC %d\n",
254 (int) GC_PHASE,
255 (int) gc_state.n_gc[GC_STAT_TOTAL]);
256 printf (" | %9s %10s %10s %10s %10s %10s\n",
257 "stat", "total", "last_gc", "this_gc",
258 "last_cycle", "this_cycle");
259 printf (" | %9s %10d %10d %10d \n",
260 "cycle", (int) gc_state.n_cycles[GC_STAT_TOTAL],
261 (int) gc_state.n_cycles[GC_STAT_IN_LAST_GC],
262 (int) gc_state.n_cycles[GC_STAT_IN_THIS_GC]);
263
264 GC_STAT_PRINT_ONE (enqueued);
265 GC_STAT_PRINT_ONE (dequeued);
266 GC_STAT_PRINT_ONE (repushed);
267 GC_STAT_PRINT_ONE (enqueued2);
268 GC_STAT_PRINT_ONE (dequeued2);
269 GC_STAT_PRINT_ONE (finalized);
270 GC_STAT_PRINT_ONE (freed);
271
272 printf (" | explicitly freed %d tried %d\n",
273 (int) gc_state.explicitly_freed,
274 (int) gc_state.explicitly_tried_freed);
275 }
276
277 DEFUN("gc-stats", Fgc_stats, 0, 0 ,"", /* 227 DEFUN("gc-stats", Fgc_stats, 0, 0 ,"", /*
278 Return statistics about garbage collection cycles in a property list. 228 Return statistics about garbage collection cycles in a property list.
279 */ 229 */
280 ()) 230 ())
281 { 231 {
282 Lisp_Object pl = Qnil; 232 Lisp_Object pl = Qnil;
283 #define PL(name,value) \ 233 #define PL(name,value) \
284 pl = cons3 (intern (name), make_int ((int) gc_state.value), pl) 234 pl = cons3 (intern (name), make_float (gc_state.value), pl)
285 235
286 PL ("explicitly-tried-freed", explicitly_tried_freed);
287 PL ("explicitly-freed", explicitly_freed);
288 PL ("freed-in-this-cycle", freed[GC_STAT_IN_THIS_CYCLE]); 236 PL ("freed-in-this-cycle", freed[GC_STAT_IN_THIS_CYCLE]);
289 PL ("freed-in-this-gc", freed[GC_STAT_IN_THIS_GC]); 237 PL ("freed-in-this-gc", freed[GC_STAT_IN_THIS_GC]);
290 PL ("freed-in-last-cycle", freed[GC_STAT_IN_LAST_CYCLE]); 238 PL ("freed-in-last-cycle", freed[GC_STAT_IN_LAST_CYCLE]);
291 PL ("freed-in-last-gc", freed[GC_STAT_IN_LAST_GC]); 239 PL ("freed-in-last-gc", freed[GC_STAT_IN_LAST_GC]);
292 PL ("freed-total", freed[GC_STAT_TOTAL]); 240 PL ("freed-total", freed[GC_STAT_TOTAL]);