1 /* GC statistics. */ 2 3 /* -------------------------- Specification ---------------------------- */ 4 5 /* Number of GCs executed so far in this process. */ 6 extern uintL gc_count; 7 8 /* Increment the number of GCs so far. 9 inc_gc_count(); */ 10 11 /* Number of bytes collected by GCs so far in this process. */ 12 extern uintL2 gc_space; 13 14 /* Accumulate the number of bytes collected by a GC. 15 inc_gc_space(freed); */ 16 17 /* Time used by GC so far in this process. */ 18 extern internal_time_t gc_time; 19 20 /* Toggle the GC timer on/off: gc_timer_on(); ... gc_timer_off(); 21 The time elapsed in between the two calls is added to gc_time. */ 22 23 /* -------------------------- Implementation --------------------------- */ 24 25 global uintL gc_count = 0; 26 27 #define inc_gc_count() gc_count++ 28 29 global uintL2 gc_space = 30 #ifdef intQsize 31 0 32 #else 33 {0,0} 34 #endif 35 ; 36 37 #ifdef intQsize 38 #define inc_gc_space(freed) gc_space += (uintM)(freed) 39 #else 40 #define inc_gc_space(freed) \ 41 do { gc_space.lo += (uintM)(freed); \ 42 if (gc_space.lo < (uintM)(freed)) /* carry forward? */ \ 43 gc_space.hi += 1; \ 44 } while(0) 45 #endif 46 47 global internal_time_t gc_time = {0,0}; 48 49 #define gc_timer_on() \ 50 { var internal_time_t gcstart_time; \ 51 get_run_time(&gcstart_time); /* get current elapsed time and store */ 52 #define gc_timer_off() \ 53 { var internal_time_t gcend_time; \ 54 get_run_time(&gcend_time); \ 55 /* calculate difference between gcend_time and gcstart_time: */ \ 56 sub_internal_time(gcend_time,gcstart_time, gcend_time); \ 57 /* add this difference to gc_time: */ \ 58 add_internal_time(gc_time,gcend_time, gc_time); \ 59 }} 60